Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a59dd393
Commit
a59dd393
authored
Mar 18, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix tests
parent
b5b83db4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
19 deletions
+13
-19
block_processor_test.go
core/block_processor_test.go
+3
-2
chain_manager_test.go
core/chain_manager_test.go
+4
-5
genesis.go
core/genesis.go
+0
-4
transaction_pool.go
core/transaction_pool.go
+1
-1
transaction_pool_test.go
core/transaction_pool_test.go
+5
-7
No files found.
core/block_processor_test.go
View file @
a59dd393
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"math/big"
"math/big"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow/ezp"
"github.com/ethereum/go-ethereum/pow/ezp"
...
@@ -19,7 +20,7 @@ func proc() (*BlockProcessor, *ChainManager) {
...
@@ -19,7 +20,7 @@ func proc() (*BlockProcessor, *ChainManager) {
func
TestNumber
(
t
*
testing
.
T
)
{
func
TestNumber
(
t
*
testing
.
T
)
{
bp
,
chain
:=
proc
()
bp
,
chain
:=
proc
()
block1
:=
chain
.
NewBlock
(
nil
)
block1
:=
chain
.
NewBlock
(
common
.
Address
{}
)
block1
.
Header
()
.
Number
=
big
.
NewInt
(
3
)
block1
.
Header
()
.
Number
=
big
.
NewInt
(
3
)
err
:=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
err
:=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
...
@@ -27,7 +28,7 @@ func TestNumber(t *testing.T) {
...
@@ -27,7 +28,7 @@ func TestNumber(t *testing.T) {
t
.
Errorf
(
"expected block number error"
)
t
.
Errorf
(
"expected block number error"
)
}
}
block1
=
chain
.
NewBlock
(
nil
)
block1
=
chain
.
NewBlock
(
common
.
Address
{}
)
err
=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
err
=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
if
err
==
BlockNumberErr
{
if
err
==
BlockNumberErr
{
t
.
Errorf
(
"didn't expect block number error"
)
t
.
Errorf
(
"didn't expect block number error"
)
...
...
core/chain_manager_test.go
View file @
a59dd393
package
core
package
core
import
(
import
(
"bytes"
"fmt"
"fmt"
"math/big"
"math/big"
"os"
"os"
...
@@ -35,7 +34,7 @@ func testFork(t *testing.T, bman *BlockProcessor, i, N int, f func(td1, td2 *big
...
@@ -35,7 +34,7 @@ func testFork(t *testing.T, bman *BlockProcessor, i, N int, f func(td1, td2 *big
// asert the bmans have the same block at i
// asert the bmans have the same block at i
bi1
:=
bman
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
bi1
:=
bman
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
bi2
:=
bman2
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
bi2
:=
bman2
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
if
b
ytes
.
Compare
(
bi1
,
bi2
)
!=
0
{
if
b
i1
!=
bi2
{
t
.
Fatal
(
"chains do not have the same hash at height"
,
i
)
t
.
Fatal
(
"chains do not have the same hash at height"
,
i
)
}
}
...
@@ -270,11 +269,11 @@ func TestChainInsertions(t *testing.T) {
...
@@ -270,11 +269,11 @@ func TestChainInsertions(t *testing.T) {
<-
done
<-
done
}
}
if
bytes
.
Equal
(
chain2
[
len
(
chain2
)
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chain2
[
len
(
chain2
)
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"chain2 is canonical and shouldn't be"
)
t
.
Error
(
"chain2 is canonical and shouldn't be"
)
}
}
if
!
bytes
.
Equal
(
chain1
[
len
(
chain1
)
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chain1
[
len
(
chain1
)
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"chain1 isn't canonical and should be"
)
t
.
Error
(
"chain1 isn't canonical and should be"
)
}
}
}
}
...
@@ -320,7 +319,7 @@ func TestChainMultipleInsertions(t *testing.T) {
...
@@ -320,7 +319,7 @@ func TestChainMultipleInsertions(t *testing.T) {
<-
done
<-
done
}
}
if
!
bytes
.
Equal
(
chains
[
longest
][
len
(
chains
[
longest
])
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chains
[
longest
][
len
(
chains
[
longest
])
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"Invalid canonical chain"
)
t
.
Error
(
"Invalid canonical chain"
)
}
}
}
}
...
...
core/genesis.go
View file @
a59dd393
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
)
)
...
@@ -19,9 +18,6 @@ import (
...
@@ -19,9 +18,6 @@ import (
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash160
=
make
([]
byte
,
20
)
var
ZeroHash160
=
make
([]
byte
,
20
)
var
ZeroHash512
=
make
([]
byte
,
64
)
var
ZeroHash512
=
make
([]
byte
,
64
)
var
EmptyShaList
=
crypto
.
Sha3
(
common
.
Encode
([]
interface
{}{}))
var
EmptyListRoot
=
crypto
.
Sha3
(
common
.
Encode
(
""
))
var
GenesisDiff
=
big
.
NewInt
(
131072
)
var
GenesisDiff
=
big
.
NewInt
(
131072
)
var
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
var
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
...
...
core/transaction_pool.go
View file @
a59dd393
...
@@ -63,7 +63,7 @@ func NewTxPool(eventMux *event.TypeMux) *TxPool {
...
@@ -63,7 +63,7 @@ func NewTxPool(eventMux *event.TypeMux) *TxPool {
func
(
pool
*
TxPool
)
ValidateTransaction
(
tx
*
types
.
Transaction
)
error
{
func
(
pool
*
TxPool
)
ValidateTransaction
(
tx
*
types
.
Transaction
)
error
{
// Validate sender
// Validate sender
if
_
,
err
:=
tx
.
From
();
err
!=
nil
{
if
_
,
err
:=
tx
.
From
();
err
!=
nil
{
return
er
r
return
ErrInvalidSende
r
}
}
// Validate curve param
// Validate curve param
v
,
_
,
_
:=
tx
.
Curve
()
v
,
_
,
_
:=
tx
.
Curve
()
...
...
core/transaction_pool_test.go
View file @
a59dd393
...
@@ -4,10 +4,10 @@ import (
...
@@ -4,10 +4,10 @@ import (
"crypto/ecdsa"
"crypto/ecdsa"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
)
)
...
@@ -21,11 +21,11 @@ func SQ() stateQuery {
...
@@ -21,11 +21,11 @@ func SQ() stateQuery {
}
}
func
(
self
stateQuery
)
GetAccount
(
addr
[]
byte
)
*
state
.
StateObject
{
func
(
self
stateQuery
)
GetAccount
(
addr
[]
byte
)
*
state
.
StateObject
{
return
state
.
NewStateObject
(
addr
,
self
.
db
)
return
state
.
NewStateObject
(
common
.
BytesToAddress
(
addr
)
,
self
.
db
)
}
}
func
transaction
()
*
types
.
Transaction
{
func
transaction
()
*
types
.
Transaction
{
return
types
.
NewTransactionMessage
(
make
([]
byte
,
20
)
,
common
.
Big0
,
common
.
Big0
,
common
.
Big0
,
nil
)
return
types
.
NewTransactionMessage
(
common
.
Address
{}
,
common
.
Big0
,
common
.
Big0
,
common
.
Big0
,
nil
)
}
}
func
setup
()
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
func
setup
()
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
...
@@ -88,10 +88,8 @@ func TestRemoveInvalid(t *testing.T) {
...
@@ -88,10 +88,8 @@ func TestRemoveInvalid(t *testing.T) {
func
TestInvalidSender
(
t
*
testing
.
T
)
{
func
TestInvalidSender
(
t
*
testing
.
T
)
{
pool
,
_
:=
setup
()
pool
,
_
:=
setup
()
tx
:=
new
(
types
.
Transaction
)
err
:=
pool
.
ValidateTransaction
(
new
(
types
.
Transaction
))
tx
.
V
=
28
err
:=
pool
.
ValidateTransaction
(
tx
)
if
err
!=
ErrInvalidSender
{
if
err
!=
ErrInvalidSender
{
t
.
Error
(
"expected %v, got %v"
,
ErrInvalidSender
,
err
)
t
.
Error
f
(
"expected %v, got %v"
,
ErrInvalidSender
,
err
)
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment