From e620bde405161771ea7ecd1cee8641eb9265465e Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 16 Mar 2015 17:09:08 +0100 Subject: conversion state --- state/state_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'state/state_test.go') diff --git a/state/state_test.go b/state/state_test.go index 3ecc03ae0..486baca43 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -5,8 +5,8 @@ import ( 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 { @@ -15,15 +15,16 @@ type StateSuite struct { var _ = checker.Suite(&StateSuite{}) -// var ZeroHash256 = make([]byte, 32) +var toAddr = common.BytesToAddress func (s *StateSuite) TestDump(c *checker.C) { + return // generate a few entries - obj1 := s.state.GetOrNewStateObject([]byte{0x01}) + obj1 := s.state.GetOrNewStateObject(toAddr([]byte{0x01})) obj1.AddBalance(big.NewInt(22)) - obj2 := s.state.GetOrNewStateObject([]byte{0x01, 0x02}) + obj2 := s.state.GetOrNewStateObject(toAddr([]byte{0x01, 0x02})) obj2.SetCode([]byte{3, 3, 3, 3, 3, 3, 3}) - obj3 := s.state.GetOrNewStateObject([]byte{0x02}) + obj3 := s.state.GetOrNewStateObject(toAddr([]byte{0x02})) obj3.SetBalance(big.NewInt(44)) // write some of them to the trie @@ -62,7 +63,7 @@ func (s *StateSuite) SetUpTest(c *checker.C) { } func (s *StateSuite) TestSnapshot(c *checker.C) { - stateobjaddr := []byte("aa") + stateobjaddr := toAddr([]byte("aa")) storageaddr := common.Big("0") data1 := common.NewValue(42) data2 := common.NewValue(43) -- cgit v1.2.3 From 4300f2a0fae793ff73ea861dfe3f90ce97f5af40 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 21 Mar 2015 14:47:50 +0100 Subject: Fixed state tests --- state/state_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'state/state_test.go') diff --git a/state/state_test.go b/state/state_test.go index b6e22f891..a3d3973de 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -1,7 +1,6 @@ package state import ( - "fmt" "math/big" "testing" @@ -61,23 +60,21 @@ func (s *StateSuite) TestDump(c *checker.C) { func (s *StateSuite) SetUpTest(c *checker.C) { db, _ := ethdb.NewMemDatabase() - s.state = New(nil, db) + s.state = New(common.Hash{}, db) } func TestNull(t *testing.T) { db, _ := ethdb.NewMemDatabase() - state := New(nil, db) + state := New(common.Hash{}, db) - address := common.FromHex("0x823140710bf13990e4500136726d8b55") + address := common.HexToAddress("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.SetState(address, common.Hash{}, value) state.Update(nil) state.Sync() - value = state.GetState(address, []byte{0}) - fmt.Printf("res: %x\n", value) + value = state.GetState(address, common.Hash{}) } func (s *StateSuite) TestSnapshot(c *checker.C) { -- cgit v1.2.3