|
|
@ -628,12 +628,14 @@ func TestEstimateGas(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
// Initialize test accounts
|
|
|
|
// Initialize test accounts
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
accounts = newAccounts(2) |
|
|
|
accounts = newAccounts(4) |
|
|
|
genesis = &core.Genesis{ |
|
|
|
genesis = &core.Genesis{ |
|
|
|
Config: params.MergedTestChainConfig, |
|
|
|
Config: params.MergedTestChainConfig, |
|
|
|
Alloc: types.GenesisAlloc{ |
|
|
|
Alloc: types.GenesisAlloc{ |
|
|
|
accounts[0].addr: {Balance: big.NewInt(params.Ether)}, |
|
|
|
accounts[0].addr: {Balance: big.NewInt(params.Ether)}, |
|
|
|
accounts[1].addr: {Balance: big.NewInt(params.Ether)}, |
|
|
|
accounts[1].addr: {Balance: big.NewInt(params.Ether)}, |
|
|
|
|
|
|
|
accounts[2].addr: {Balance: big.NewInt(params.Ether), Code: append(types.DelegationPrefix, accounts[3].addr.Bytes()...)}, |
|
|
|
|
|
|
|
// accounts[3].addr: {Code: []byte{byte(vm.ADDRESS), byte(vm.PUSH0), byte(vm.SSTORE)}},
|
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
genBlocks = 10 |
|
|
|
genBlocks = 10 |
|
|
@ -758,6 +760,26 @@ func TestEstimateGas(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
want: 21000, |
|
|
|
want: 21000, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// Should be able to send to an EIP-7702 delegated account.
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
blockNumber: rpc.LatestBlockNumber, |
|
|
|
|
|
|
|
call: TransactionArgs{ |
|
|
|
|
|
|
|
From: &accounts[0].addr, |
|
|
|
|
|
|
|
To: &accounts[2].addr, |
|
|
|
|
|
|
|
Value: (*hexutil.Big)(big.NewInt(1)), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
want: 21000, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// Should be able to send as EIP-7702 delegated account.
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
blockNumber: rpc.LatestBlockNumber, |
|
|
|
|
|
|
|
call: TransactionArgs{ |
|
|
|
|
|
|
|
From: &accounts[2].addr, |
|
|
|
|
|
|
|
To: &accounts[1].addr, |
|
|
|
|
|
|
|
Value: (*hexutil.Big)(big.NewInt(1)), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
want: 21000, |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
for i, tc := range testSuite { |
|
|
|
for i, tc := range testSuite { |
|
|
|
result, err := api.EstimateGas(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides) |
|
|
|
result, err := api.EstimateGas(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides) |
|
|
|