mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
reformed eip7702 tests for TestCall in api_test
This commit is contained in:
parent
ef19671e48
commit
cb8dab6601
1 changed files with 113 additions and 7 deletions
|
|
@ -870,7 +870,7 @@ func TestCall(t *testing.T) {
|
||||||
|
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
var (
|
var (
|
||||||
accounts = newAccounts(7)
|
accounts = newAccounts(5)
|
||||||
dad = common.HexToAddress("0x0000000000000000000000000000000000000dad")
|
dad = common.HexToAddress("0x0000000000000000000000000000000000000dad")
|
||||||
genesis = &core.Genesis{
|
genesis = &core.Genesis{
|
||||||
Config: params.MergedTestChainConfig,
|
Config: params.MergedTestChainConfig,
|
||||||
|
|
@ -878,7 +878,7 @@ func TestCall(t *testing.T) {
|
||||||
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)},
|
accounts[2].addr: {Balance: big.NewInt(params.Ether)},
|
||||||
accounts[3].addr: {Balance: big.NewInt(params.Ether) ,Code: append(types.DelegationPrefix, accounts[4].addr.Bytes()...)},
|
accounts[3].addr: {Balance: big.NewInt(params.Ether), Code: append(types.DelegationPrefix, accounts[4].addr.Bytes()...)},
|
||||||
dad: {
|
dad: {
|
||||||
Balance: big.NewInt(params.Ether),
|
Balance: big.NewInt(params.Ether),
|
||||||
Nonce: 1,
|
Nonce: 1,
|
||||||
|
|
@ -1179,6 +1179,113 @@ func TestCall(t *testing.T) {
|
||||||
},
|
},
|
||||||
want: "0x",
|
want: "0x",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-delegator-authorization",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[1].addr,
|
||||||
|
To: &accounts[2].addr,
|
||||||
|
Data: hex2Bytes("46b3353b"), // getCallerAddress()
|
||||||
|
AuthorizationList: []types.SetCodeAuthorization{
|
||||||
|
{
|
||||||
|
Address: accounts[4].addr,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
overrides: override.StateOverride{
|
||||||
|
accounts[2].addr: override.OverrideAccount{
|
||||||
|
Code: hex2Bytes("6080604052348015600e575f80fd5b50600436106026575f3560e01c806346b3353b14602a575b5f80fd5b60306044565b604051603b91906086565b60405180910390f35b5f33905090565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f607282604b565b9050919050565b608081606a565b82525050565b5f60208201905060975f8301846079565b9291505056"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: nil,
|
||||||
|
want: strings.ToLower("0x000000000000000000000000" + accounts[1].addr.Hex()[2:]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-EOA-value-transfer-to-delegated-account",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[2].addr,
|
||||||
|
To: &accounts[3].addr,
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
|
},
|
||||||
|
expectErr: nil,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-other-EOAs-call-delegated-account",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[2].addr,
|
||||||
|
To: &accounts[3].addr,
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(0)),
|
||||||
|
},
|
||||||
|
expectErr: nil,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-eth-transfer-with-authorisation-list",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[1].addr,
|
||||||
|
To: &accounts[2].addr,
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
|
AuthorizationList: []types.SetCodeAuthorization{
|
||||||
|
{
|
||||||
|
Address: accounts[4].addr,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: nil,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-eth-transfer-when-multiple-authorisation-lists",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[1].addr,
|
||||||
|
To: &accounts[2].addr,
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
|
AuthorizationList: []types.SetCodeAuthorization{
|
||||||
|
{
|
||||||
|
Address: accounts[4].addr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Address: accounts[3].addr,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: nil,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-error-when-empty-auth-list",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[1].addr,
|
||||||
|
To: &accounts[2].addr,
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(1000)),
|
||||||
|
AuthorizationList: []types.SetCodeAuthorization{}, // Empty list
|
||||||
|
},
|
||||||
|
expectErr: core.ErrEmptyAuthList,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "eip-7702-error-when-deploy-contract",
|
||||||
|
blockNumber: rpc.LatestBlockNumber,
|
||||||
|
call: TransactionArgs{
|
||||||
|
From: &accounts[1].addr,
|
||||||
|
To: nil, // No recipient for contract creation
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(0)),
|
||||||
|
Data: &hexutil.Bytes{0x60, 0x0},
|
||||||
|
AuthorizationList: []types.SetCodeAuthorization{
|
||||||
|
{
|
||||||
|
Address: accounts[4].addr,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: core.ErrSetCodeTxCreate,
|
||||||
|
want: "0x",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testSuite {
|
for _, tc := range testSuite {
|
||||||
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)
|
result, err := api.Call(context.Background(), tc.call, &rpc.BlockNumberOrHash{BlockNumber: &tc.blockNumber}, &tc.overrides, &tc.blockOverrides)
|
||||||
|
|
@ -1205,7 +1312,6 @@ func TestCall(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimulateV1(t *testing.T) {
|
func TestSimulateV1(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
// Initialize test accounts
|
// Initialize test accounts
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue