aboutsummaryrefslogtreecommitdiffstats
path: root/core/state
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-17 18:53:22 +0800
committerobscuren <geffobscura@gmail.com>2015-06-17 18:53:22 +0800
commitaaddc99c35f1fcc9b5d7198dd6571dfa43718ae8 (patch)
treeec342e067b16f6c0ed41ca34b71a303f4766a435 /core/state
parenta977f3c0dc050463e2b3c8622d289a23f0d1ce02 (diff)
downloaddexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar.gz
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar.bz2
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar.lz
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar.xz
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.tar.zst
dexon-aaddc99c35f1fcc9b5d7198dd6571dfa43718ae8.zip
core/state: fixed state tests
Diffstat (limited to 'core/state')
-rw-r--r--core/state/state_test.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/core/state/state_test.go b/core/state/state_test.go
index 09a65de54..00e133dab 100644
--- a/core/state/state_test.go
+++ b/core/state/state_test.go
@@ -70,37 +70,34 @@ func TestNull(t *testing.T) {
address := common.HexToAddress("0x823140710bf13990e4500136726d8b55")
state.CreateAccount(address)
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
- value := make([]byte, 16)
+ var 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
- stateObject.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
- stateObject.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 := stateObject.GetStorage(storageaddr)
+ res := s.state.GetState(stateobjaddr, storageaddr)
c.Assert(data1, checker.DeepEquals, res)
}