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
ac0637c4
Commit
ac0637c4
authored
Jun 10, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More consistent test interfaces + test skipping
parent
b6d40a93
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
78 deletions
+108
-78
block_test.go
tests/block_test.go
+40
-10
block_test_util.go
tests/block_test_util.go
+16
-11
init.go
tests/init.go
+5
-0
state_test_util.go
tests/state_test_util.go
+18
-18
transaction_test.go
tests/transaction_test.go
+3
-22
transaction_test_util.go
tests/transaction_test_util.go
+18
-9
vm_test_util.go
tests/vm_test_util.go
+8
-8
No files found.
tests/block_test.go
View file @
ac0637c4
...
@@ -6,38 +6,68 @@ import (
...
@@ -6,38 +6,68 @@ import (
)
)
func
TestBcValidBlockTests
(
t
*
testing
.
T
)
{
func
TestBcValidBlockTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcValidBlockTest.json"
),
[]
string
{
"SimpleTx3"
})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcValidBlockTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcUncleTests
(
t
*
testing
.
T
)
{
func
TestBcUncleTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcUncleTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcUncleTest.json"
))
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcBruncleTest.json"
),
[]
string
{})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcBruncleTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcUncleHeaderValidityTests
(
t
*
testing
.
T
)
{
func
TestBcUncleHeaderValidityTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcUncleHeaderValiditiy.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcUncleHeaderValiditiy.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcInvalidHeaderTests
(
t
*
testing
.
T
)
{
func
TestBcInvalidHeaderTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcInvalidHeaderTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcInvalidHeaderTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcInvalidRLPTests
(
t
*
testing
.
T
)
{
func
TestBcInvalidRLPTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcInvalidRLPTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcInvalidRLPTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcRPCAPITests
(
t
*
testing
.
T
)
{
func
TestBcRPCAPITests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcRPC_API_Test.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcRPC_API_Test.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcForkBlockTests
(
t
*
testing
.
T
)
{
func
TestBcForkBlockTests
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcForkBlockTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcForkBlockTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcTotalDifficulty
(
t
*
testing
.
T
)
{
func
TestBcTotalDifficulty
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcTotalDifficultyTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcTotalDifficultyTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
func
TestBcWallet
(
t
*
testing
.
T
)
{
func
TestBcWallet
(
t
*
testing
.
T
)
{
runBlockTestsInFile
(
filepath
.
Join
(
blockTestDir
,
"bcWalletTest.json"
),
[]
string
{})
err
:=
RunBlockTest
(
filepath
.
Join
(
blockTestDir
,
"bcWalletTest.json"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
tests/block_test_util.go
View file @
ac0637c4
...
@@ -86,28 +86,35 @@ type btTransaction struct {
...
@@ -86,28 +86,35 @@ type btTransaction struct {
Value
string
Value
string
}
}
func
runBlockTestsInFile
(
filepath
string
,
snafus
[]
string
)
error
{
func
RunBlockTest
(
filepath
string
)
error
{
bt
,
err
:=
LoadBlockTests
(
filepath
)
bt
,
err
:=
LoadBlockTests
(
filepath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
return
nil
}
}
notWorking
:=
make
(
map
[
string
]
bool
,
100
)
// map skipped tests to boolean set
for
_
,
name
:=
range
snafus
{
skipTest
:=
make
(
map
[
string
]
bool
,
len
(
blockSkipTests
))
notWorking
[
name
]
=
true
for
_
,
name
:=
range
blockSkipTests
{
skipTest
[
name
]
=
true
}
}
for
name
,
test
:=
range
bt
{
for
name
,
test
:=
range
bt
{
if
!
notWorking
[
name
]
{
// if the test should be skipped, return
if
err
:=
runBlockTest
(
name
,
test
);
err
!=
nil
{
if
skipTest
[
name
]
{
return
err
fmt
.
Println
(
"Skipping state test"
,
name
)
}
return
nil
}
// test the block
if
err
:=
testBlock
(
test
);
err
!=
nil
{
return
err
}
}
fmt
.
Println
(
"Block test passed: "
,
name
)
}
}
return
nil
return
nil
}
}
func
runBlockTest
(
name
string
,
test
*
BlockTest
)
error
{
func
testBlock
(
test
*
BlockTest
)
error
{
cfg
:=
testEthConfig
()
cfg
:=
testEthConfig
()
ethereum
,
err
:=
eth
.
New
(
cfg
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -136,8 +143,6 @@ func runBlockTest(name string, test *BlockTest) error {
...
@@ -136,8 +143,6 @@ func runBlockTest(name string, test *BlockTest) error {
if
err
=
test
.
ValidatePostState
(
statedb
);
err
!=
nil
{
if
err
=
test
.
ValidatePostState
(
statedb
);
err
!=
nil
{
return
fmt
.
Errorf
(
"post state validation failed: %v"
,
err
)
return
fmt
.
Errorf
(
"post state validation failed: %v"
,
err
)
}
}
fmt
.
Println
(
"Block test passed: "
,
name
)
// t.Log("Block test passed: ", name)
return
nil
return
nil
}
}
...
...
tests/init.go
View file @
ac0637c4
...
@@ -15,6 +15,11 @@ var (
...
@@ -15,6 +15,11 @@ var (
stateTestDir
=
filepath
.
Join
(
baseDir
,
"StateTests"
)
stateTestDir
=
filepath
.
Join
(
baseDir
,
"StateTests"
)
transactionTestDir
=
filepath
.
Join
(
baseDir
,
"TransactionTests"
)
transactionTestDir
=
filepath
.
Join
(
baseDir
,
"TransactionTests"
)
vmTestDir
=
filepath
.
Join
(
baseDir
,
"VMTests"
)
vmTestDir
=
filepath
.
Join
(
baseDir
,
"VMTests"
)
blockSkipTests
=
[]
string
{}
transSkipTests
=
[]
string
{
"TransactionWithHihghNonce256"
}
stateSkipTests
=
[]
string
{
"mload32bitBound_return"
,
"mload32bitBound_return2"
}
vmSkipTests
=
[]
string
{}
)
)
func
readJSON
(
reader
io
.
Reader
,
value
interface
{})
error
{
func
readJSON
(
reader
io
.
Reader
,
value
interface
{})
error
{
...
...
tests/state_test_util.go
View file @
ac0637c4
...
@@ -15,19 +15,19 @@ import (
...
@@ -15,19 +15,19 @@ import (
)
)
func
RunStateTest
(
p
string
)
error
{
func
RunStateTest
(
p
string
)
error
{
skipTest
:=
make
(
map
[
string
]
bool
,
len
(
stateSkipTests
))
for
_
,
name
:=
range
stateSkipTests
{
skipTest
[
name
]
=
true
}
tests
:=
make
(
map
[
string
]
VmTest
)
tests
:=
make
(
map
[
string
]
VmTest
)
CreateFileTests
(
p
,
&
tests
)
CreateFileTests
(
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
/*
if
skipTest
[
name
]
{
vm.Debug = true
fmt
.
Println
(
"Skipping state test"
,
name
)
glog.SetV(4)
return
nil
glog.SetToStderr(true)
}
if name != "Call50000_sha256" {
continue
}
*/
db
,
_
:=
ethdb
.
NewMemDatabase
()
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
...
@@ -60,17 +60,17 @@ func RunStateTest(p string) error {
...
@@ -60,17 +60,17 @@ func RunStateTest(p string) error {
ret
,
logs
,
_
,
_
=
RunState
(
statedb
,
env
,
test
.
Transaction
)
ret
,
logs
,
_
,
_
=
RunState
(
statedb
,
env
,
test
.
Transaction
)
// Compare expected and actual return
// // Compare expected and actual return
switch
name
{
// switch name {
// the memory required for these tests (4294967297 bytes) would take too much time.
// // the memory required for these tests (4294967297 bytes) would take too much time.
// on 19 May 2015 decided to skip these tests their output.
// // on 19 May 2015 decided to skip these tests their output.
case
"mload32bitBound_return"
,
"mload32bitBound_return2"
:
// case "mload32bitBound_return", "mload32bitBound_return2":
default
:
// default:
rexp
:=
common
.
FromHex
(
test
.
Out
)
rexp
:=
common
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
return
fmt
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
return
fmt
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
}
}
}
// }
// check post state
// check post state
for
addr
,
account
:=
range
test
.
Post
{
for
addr
,
account
:=
range
test
.
Post
{
...
...
tests/transaction_test.go
View file @
ac0637c4
...
@@ -6,40 +6,21 @@ import (
...
@@ -6,40 +6,21 @@ import (
)
)
func
TestTransactions
(
t
*
testing
.
T
)
{
func
TestTransactions
(
t
*
testing
.
T
)
{
notWorking
:=
make
(
map
[
string
]
bool
,
100
)
err
:=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"ttTransactionTest.json"
))
// TODO: all these tests should work! remove them from the array when they work
snafus
:=
[]
string
{
"TransactionWithHihghNonce256"
,
// fails due to testing upper bound of 256 bit nonce
}
for
_
,
name
:=
range
snafus
{
notWorking
[
name
]
=
true
}
var
err
error
err
=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"ttTransactionTest.json"
),
notWorking
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
}
}
func
TestWrongRLPTransactions
(
t
*
testing
.
T
)
{
func
TestWrongRLPTransactions
(
t
*
testing
.
T
)
{
notWorking
:=
make
(
map
[
string
]
bool
,
100
)
err
:=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"ttWrongRLPTransaction.json"
))
var
err
error
err
=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"ttWrongRLPTransaction.json"
),
notWorking
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
}
}
func
Test10MBtx
(
t
*
testing
.
T
)
{
func
Test10MBtx
(
t
*
testing
.
T
)
{
notWorking
:=
make
(
map
[
string
]
bool
,
100
)
err
:=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"tt10mbDataField.json"
))
var
err
error
err
=
RunTransactionTests
(
filepath
.
Join
(
transactionTestDir
,
"tt10mbDataField.json"
),
notWorking
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
tests/transaction_test_util.go
View file @
ac0637c4
...
@@ -30,20 +30,29 @@ type TransactionTest struct {
...
@@ -30,20 +30,29 @@ type TransactionTest struct {
Transaction
TtTransaction
Transaction
TtTransaction
}
}
func
RunTransactionTests
(
file
string
,
notWorking
map
[
string
]
bool
)
error
{
func
RunTransactionTests
(
file
string
)
error
{
skipTest
:=
make
(
map
[
string
]
bool
,
len
(
transSkipTests
))
for
_
,
name
:=
range
transSkipTests
{
skipTest
[
name
]
=
true
}
bt
:=
make
(
map
[
string
]
TransactionTest
)
bt
:=
make
(
map
[
string
]
TransactionTest
)
if
err
:=
LoadJSON
(
file
,
&
bt
);
err
!=
nil
{
if
err
:=
LoadJSON
(
file
,
&
bt
);
err
!=
nil
{
return
err
return
err
}
}
for
name
,
in
:=
range
bt
{
var
err
error
for
name
,
test
:=
range
bt
{
// TODO: remove this, we currently ignore some tests which are broken
// if the test should be skipped, return
if
!
notWorking
[
name
]
{
if
skipTest
[
name
]
{
if
err
=
runTest
(
in
);
err
!=
nil
{
fmt
.
Println
(
"Skipping state test"
,
name
)
return
fmt
.
Errorf
(
"bad test %s: %v"
,
name
,
err
)
return
nil
}
}
fmt
.
Println
(
"Transaction test passed:"
,
name
)
// test the block
if
err
:=
runTest
(
test
);
err
!=
nil
{
return
err
}
}
fmt
.
Println
(
"Transaction test passed: "
,
name
)
}
}
return
nil
return
nil
}
}
...
...
tests/vm_test_util.go
View file @
ac0637c4
...
@@ -13,6 +13,10 @@ import (
...
@@ -13,6 +13,10 @@ import (
)
)
func
RunVmTest
(
p
string
)
error
{
func
RunVmTest
(
p
string
)
error
{
skipTest
:=
make
(
map
[
string
]
bool
,
len
(
vmSkipTests
))
for
_
,
name
:=
range
vmSkipTests
{
skipTest
[
name
]
=
true
}
tests
:=
make
(
map
[
string
]
VmTest
)
tests
:=
make
(
map
[
string
]
VmTest
)
err
:=
CreateFileTests
(
p
,
&
tests
)
err
:=
CreateFileTests
(
p
,
&
tests
)
...
@@ -21,14 +25,10 @@ func RunVmTest(p string) error {
...
@@ -21,14 +25,10 @@ func RunVmTest(p string) error {
}
}
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
/*
if
skipTest
[
name
]
{
vm.Debug = true
fmt
.
Println
(
"Skipping state test"
,
name
)
glog.SetV(4)
return
nil
glog.SetToStderr(true)
}
if name != "Call50000_sha256" {
continue
}
*/
db
,
_
:=
ethdb
.
NewMemDatabase
()
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
statedb
:=
state
.
New
(
common
.
Hash
{},
db
)
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
...
...
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