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
91b73495
Commit
91b73495
authored
Sep 11, 2019
by
Martin Holst Swende
Committed by
Felix Lange
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: expose internal RunNoVerify method (#20051)
parent
52a967cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
state_test_util.go
tests/state_test_util.go
+22
-12
No files found.
tests/state_test_util.go
View file @
91b73495
...
...
@@ -144,11 +144,29 @@ func (t *StateTest) Subtests() []StateSubtest {
return
sub
}
// Run executes a specific subtest
.
// Run executes a specific subtest
and verifies the post-state and logs
func
(
t
*
StateTest
)
Run
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
)
(
*
state
.
StateDB
,
error
)
{
statedb
,
root
,
err
:=
t
.
RunNoVerify
(
subtest
,
vmconfig
)
if
err
!=
nil
{
return
statedb
,
err
}
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
// N.B: We need to do this in a two-step process, because the first Commit takes care
// of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
if
root
!=
common
.
Hash
(
post
.
Root
)
{
return
statedb
,
fmt
.
Errorf
(
"post state root mismatch: got %x, want %x"
,
root
,
post
.
Root
)
}
if
logs
:=
rlpHash
(
statedb
.
Logs
());
logs
!=
common
.
Hash
(
post
.
Logs
)
{
return
statedb
,
fmt
.
Errorf
(
"post state logs hash mismatch: got %x, want %x"
,
logs
,
post
.
Logs
)
}
return
statedb
,
nil
}
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
func
(
t
*
StateTest
)
RunNoVerify
(
subtest
StateSubtest
,
vmconfig
vm
.
Config
)
(
*
state
.
StateDB
,
common
.
Hash
,
error
)
{
config
,
eips
,
err
:=
getVMConfig
(
subtest
.
Fork
)
if
err
!=
nil
{
return
nil
,
UnsupportedForkError
{
subtest
.
Fork
}
return
nil
,
common
.
Hash
{},
UnsupportedForkError
{
subtest
.
Fork
}
}
vmconfig
.
ExtraEips
=
eips
block
:=
t
.
genesis
(
config
)
.
ToBlock
(
nil
)
...
...
@@ -157,7 +175,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
post
:=
t
.
json
.
Post
[
subtest
.
Fork
][
subtest
.
Index
]
msg
,
err
:=
t
.
json
.
Tx
.
toMessage
(
post
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
common
.
Hash
{},
err
}
context
:=
core
.
NewEVMContext
(
msg
,
block
.
Header
(),
nil
,
&
t
.
json
.
Env
.
Coinbase
)
context
.
GetHash
=
vmTestBlockHash
...
...
@@ -179,15 +197,7 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config) (*state.StateD
statedb
.
AddBalance
(
block
.
Coinbase
(),
new
(
big
.
Int
))
// And _now_ get the state root
root
:=
statedb
.
IntermediateRoot
(
config
.
IsEIP158
(
block
.
Number
()))
// N.B: We need to do this in a two-step process, because the first Commit takes care
// of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
if
root
!=
common
.
Hash
(
post
.
Root
)
{
return
statedb
,
fmt
.
Errorf
(
"post state root mismatch: got %x, want %x"
,
root
,
post
.
Root
)
}
if
logs
:=
rlpHash
(
statedb
.
Logs
());
logs
!=
common
.
Hash
(
post
.
Logs
)
{
return
statedb
,
fmt
.
Errorf
(
"post state logs hash mismatch: got %x, want %x"
,
logs
,
post
.
Logs
)
}
return
statedb
,
nil
return
statedb
,
root
,
nil
}
func
(
t
*
StateTest
)
gasLimit
(
subtest
StateSubtest
)
uint64
{
...
...
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