diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-19 17:57:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-19 17:57:02 +0800 |
commit | d7ab716eea1d1892e3358b1dece6b0e2cd31fce8 (patch) | |
tree | c0fe4ca2dc47ff8512065f3601b9f3ab6b21dd43 /state | |
parent | e67d32b46744928b07b4d964ae3dede9a1ffdddf (diff) | |
download | go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar.gz go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar.bz2 go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar.lz go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar.xz go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.tar.zst go-tangerine-d7ab716eea1d1892e3358b1dece6b0e2cd31fce8.zip |
Fixed mkdnode & added some tests
Diffstat (limited to 'state')
-rw-r--r-- | state/dump.go | 1 | ||||
-rw-r--r-- | state/state_object.go | 2 | ||||
-rw-r--r-- | state/state_test.go | 20 | ||||
-rw-r--r-- | state/statedb.go | 4 |
4 files changed, 25 insertions, 2 deletions
diff --git a/state/dump.go b/state/dump.go index c5f556e1a..6db0d5074 100644 --- a/state/dump.go +++ b/state/dump.go @@ -35,6 +35,7 @@ func (self *StateDB) RawDump() World { storageIt := stateObject.State.trie.Iterator() for storageIt.Next() { + fmt.Println("value", storageIt.Value) account.Storage[common.Bytes2Hex(storageIt.Key)] = common.Bytes2Hex(storageIt.Value) } world.Accounts[common.Bytes2Hex(it.Key)] = account diff --git a/state/state_object.go b/state/state_object.go index 8be9e28fc..cdb9abf79 100644 --- a/state/state_object.go +++ b/state/state_object.go @@ -5,8 +5,8 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" ) diff --git a/state/state_test.go b/state/state_test.go index 3ecc03ae0..3a1ea225d 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -1,12 +1,14 @@ package state import ( + "fmt" "math/big" + "testing" checker "gopkg.in/check.v1" - "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethdb" ) type StateSuite struct { @@ -61,6 +63,22 @@ func (s *StateSuite) SetUpTest(c *checker.C) { s.state = New(nil, db) } +func TestNull(t *testing.T) { + db, _ := ethdb.NewMemDatabase() + state := New(nil, db) + + address := common.FromHex("0x823140710bf13990e4500136726d8b55") + state.NewStateObject(address) + //value := common.FromHex("0x823140710bf13990e4500136726d8b55") + value := make([]byte, 16) + fmt.Println("test it here", common.NewValue(value)) + state.SetState(address, []byte{0}, value) + state.Update(nil) + state.Sync() + value = state.GetState(address, []byte{0}) + fmt.Printf("res: %x\n", value) +} + func (s *StateSuite) TestSnapshot(c *checker.C) { stateobjaddr := []byte("aa") storageaddr := common.Big("0") diff --git a/state/statedb.go b/state/statedb.go index 80bbe2afd..d01b6056d 100644 --- a/state/statedb.go +++ b/state/statedb.go @@ -33,6 +33,10 @@ func New(root []byte, db common.Database) *StateDB { return &StateDB{db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: make(map[string]*big.Int)} } +func (self *StateDB) PrintRoot() { + self.trie.Trie.PrintRoot() +} + func (self *StateDB) EmptyLogs() { self.logs = nil } |