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
aaddc99c
Commit
aaddc99c
authored
Jun 17, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/state: fixed state tests
parent
a977f3c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
state_test.go
core/state/state_test.go
+10
-13
No files found.
core/state/state_test.go
View file @
aaddc99c
...
...
@@ -70,37 +70,34 @@ func TestNull(t *testing.T) {
address
:=
common
.
HexToAddress
(
"0x823140710bf13990e4500136726d8b55"
)
state
.
CreateAccount
(
address
)
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
va
lue
:=
make
([]
byte
,
16
)
va
r
value
common
.
Hash
state
.
SetState
(
address
,
common
.
Hash
{},
value
)
state
.
Update
()
state
.
Sync
()
value
=
state
.
GetState
(
address
,
common
.
Hash
{})
if
!
common
.
EmptyHash
(
value
)
{
t
.
Errorf
(
"expected empty hash. got %x"
,
value
)
}
}
func
(
s
*
StateSuite
)
TestSnapshot
(
c
*
checker
.
C
)
{
stateobjaddr
:=
toAddr
([]
byte
(
"aa"
))
storageaddr
:=
common
.
Big
(
"0"
)
data1
:=
common
.
NewValue
(
42
)
data2
:=
common
.
NewValue
(
43
)
var
storageaddr
common
.
Hash
data1
:=
common
.
BytesToHash
([]
byte
{
42
}
)
data2
:=
common
.
BytesToHash
([]
byte
{
43
}
)
// get state object
stateObject
:=
s
.
state
.
GetOrNewStateObject
(
stateobjaddr
)
// set inital state object value
s
tateObject
.
SetStorage
(
storageaddr
,
data1
)
s
.
state
.
SetState
(
stateobjaddr
,
storageaddr
,
data1
)
// get snapshot of current state
snapshot
:=
s
.
state
.
Copy
()
// get state object. is this strictly necessary?
stateObject
=
s
.
state
.
GetStateObject
(
stateobjaddr
)
// set new state object value
s
tateObject
.
SetStorage
(
storageaddr
,
data2
)
s
.
state
.
SetState
(
stateobjaddr
,
storageaddr
,
data2
)
// restore snapshot
s
.
state
.
Set
(
snapshot
)
// get state object
stateObject
=
s
.
state
.
GetStateObject
(
stateobjaddr
)
// get state storage value
res
:=
s
tateObject
.
GetStorage
(
storageaddr
)
res
:=
s
.
state
.
GetState
(
stateobjaddr
,
storageaddr
)
c
.
Assert
(
data1
,
checker
.
DeepEquals
,
res
)
}
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