Skip to content

Commit 4611fd6

Browse files
aaronbuchwaldatif-konasl
authored andcommitted
core/state: remove toAddr helper in tests (ethereum#22772)
1 parent 29d76d7 commit 4611fd6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

core/state/state_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"github.com/ethereum/go-ethereum/ethdb"
2828
)
2929

30-
var toAddr = common.BytesToAddress
31-
3230
type stateTest struct {
3331
db ethdb.Database
3432
state *StateDB
@@ -46,11 +44,11 @@ func TestDump(t *testing.T) {
4644
s := &stateTest{db: db, state: sdb}
4745

4846
// generate a few entries
49-
obj1 := s.state.GetOrNewStateObject(toAddr([]byte{0x01}))
47+
obj1 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x01}))
5048
obj1.AddBalance(big.NewInt(22))
51-
obj2 := s.state.GetOrNewStateObject(toAddr([]byte{0x01, 0x02}))
49+
obj2 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x01, 0x02}))
5250
obj2.SetCode(crypto.Keccak256Hash([]byte{3, 3, 3, 3, 3, 3, 3}), []byte{3, 3, 3, 3, 3, 3, 3})
53-
obj3 := s.state.GetOrNewStateObject(toAddr([]byte{0x02}))
51+
obj3 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x02}))
5452
obj3.SetBalance(big.NewInt(44))
5553

5654
// write some of them to the trie
@@ -108,7 +106,7 @@ func TestNull(t *testing.T) {
108106
}
109107

110108
func TestSnapshot(t *testing.T) {
111-
stateobjaddr := toAddr([]byte("aa"))
109+
stateobjaddr := common.BytesToAddress([]byte("aa"))
112110
var storageaddr common.Hash
113111
data1 := common.BytesToHash([]byte{42})
114112
data2 := common.BytesToHash([]byte{43})
@@ -150,8 +148,8 @@ func TestSnapshotEmpty(t *testing.T) {
150148
func TestSnapshot2(t *testing.T) {
151149
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()), nil)
152150

153-
stateobjaddr0 := toAddr([]byte("so0"))
154-
stateobjaddr1 := toAddr([]byte("so1"))
151+
stateobjaddr0 := common.BytesToAddress([]byte("so0"))
152+
stateobjaddr1 := common.BytesToAddress([]byte("so1"))
155153
var storageaddr common.Hash
156154

157155
data0 := common.BytesToHash([]byte{17})

core/state/statedb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ func TestDeleteCreateRevert(t *testing.T) {
672672
// Create an initial state with a single contract
673673
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()), nil)
674674

675-
addr := toAddr([]byte("so"))
675+
addr := common.BytesToAddress([]byte("so"))
676676
state.SetBalance(addr, big.NewInt(1))
677677

678678
root, _ := state.Commit(false)
@@ -705,11 +705,11 @@ func TestMissingTrieNodes(t *testing.T) {
705705
db := NewDatabase(memDb)
706706
var root common.Hash
707707
state, _ := New(common.Hash{}, db, nil)
708-
addr := toAddr([]byte("so"))
708+
addr := common.BytesToAddress([]byte("so"))
709709
{
710710
state.SetBalance(addr, big.NewInt(1))
711711
state.SetCode(addr, []byte{1, 2, 3})
712-
a2 := toAddr([]byte("another"))
712+
a2 := common.BytesToAddress([]byte("another"))
713713
state.SetBalance(a2, big.NewInt(100))
714714
state.SetCode(a2, []byte{1, 2, 4})
715715
root, _ = state.Commit(false)

0 commit comments

Comments
 (0)