github.com/onflow/flow-go@v0.33.17/fvm/evm/handler/addressAllocator_test.go (about) 1 package handler_test 2 3 import ( 4 "testing" 5 6 gethCommon "github.com/ethereum/go-ethereum/common" 7 "github.com/stretchr/testify/require" 8 9 "github.com/onflow/flow-go/fvm/evm/handler" 10 "github.com/onflow/flow-go/fvm/evm/testutils" 11 "github.com/onflow/flow-go/fvm/evm/types" 12 "github.com/onflow/flow-go/model/flow" 13 ) 14 15 func TestAddressAllocator(t *testing.T) { 16 17 testutils.RunWithTestBackend(t, func(backend *testutils.TestBackend) { 18 testutils.RunWithTestFlowEVMRootAddress(t, backend, func(root flow.Address) { 19 aa, err := handler.NewAddressAllocator(backend, root) 20 require.NoError(t, err) 21 22 // test default value fall back 23 adr, err := aa.AllocateAddress() 24 require.NoError(t, err) 25 expectedAddress := types.NewAddress(gethCommon.HexToAddress("0x00000000000000000001")) 26 require.Equal(t, expectedAddress, adr) 27 28 // continous allocation logic 29 adr, err = aa.AllocateAddress() 30 require.NoError(t, err) 31 expectedAddress = types.NewAddress(gethCommon.HexToAddress("0x00000000000000000002")) 32 require.Equal(t, expectedAddress, adr) 33 }) 34 35 }) 36 37 }