Skip to content

Commit 7feff61

Browse files
authored
core/state: remove toAddr helper in tests ethereum#22772 (#1100)
1 parent 3a6beed commit 7feff61

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

core/state/state_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ type StateSuite struct {
3636

3737
var _ = checker.Suite(&StateSuite{})
3838

39-
var toAddr = common.BytesToAddress
40-
4139
func (s *StateSuite) TestDump(c *checker.C) {
4240
// generate a few entries
43-
obj1 := s.state.GetOrNewStateObject(toAddr([]byte{0x01}))
41+
obj1 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x01}))
4442
obj1.AddBalance(big.NewInt(22))
45-
obj2 := s.state.GetOrNewStateObject(toAddr([]byte{0x01, 0x02}))
43+
obj2 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x01, 0x02}))
4644
obj2.SetCode(crypto.Keccak256Hash([]byte{3, 3, 3, 3, 3, 3, 3}), []byte{3, 3, 3, 3, 3, 3, 3})
47-
obj3 := s.state.GetOrNewStateObject(toAddr([]byte{0x02}))
45+
obj3 := s.state.GetOrNewStateObject(common.BytesToAddress([]byte{0x02}))
4846
obj3.SetBalance(big.NewInt(44))
4947

5048
// write some of them to the trie
@@ -111,7 +109,7 @@ func (s *StateSuite) TestNull(c *checker.C) {
111109
}
112110

113111
func (s *StateSuite) TestSnapshot(c *checker.C) {
114-
stateobjaddr := toAddr([]byte("aa"))
112+
stateobjaddr := common.BytesToAddress([]byte("aa"))
115113
var storageaddr common.Hash
116114
data1 := common.BytesToHash([]byte{42})
117115
data2 := common.BytesToHash([]byte{43})
@@ -146,8 +144,8 @@ func TestSnapshot2(t *testing.T) {
146144
db := rawdb.NewMemoryDatabase()
147145
state, _ := New(types.EmptyRootHash, NewDatabase(db))
148146

149-
stateobjaddr0 := toAddr([]byte("so0"))
150-
stateobjaddr1 := toAddr([]byte("so1"))
147+
stateobjaddr0 := common.BytesToAddress([]byte("so0"))
148+
stateobjaddr1 := common.BytesToAddress([]byte("so1"))
151149
var storageaddr common.Hash
152150

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

core/state/statedb_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ func TestDeleteCreateRevert(t *testing.T) {
668668
// Create an initial state with a single contract
669669
state, _ := New(common.Hash{}, NewDatabase(rawdb.NewMemoryDatabase()))
670670

671-
addr := toAddr([]byte("so"))
671+
addr := common.BytesToAddress([]byte("so"))
672672
state.SetBalance(addr, big.NewInt(1))
673673

674674
root, _ := state.Commit(false)

0 commit comments

Comments
 (0)