internal/ethapi: make tests a bit more complex

This commit is contained in:
Péter Szilágyi 2023-11-07 12:04:45 +02:00
parent de24a7a612
commit 5f39342a76

View file

@ -680,41 +680,44 @@ func TestEstimateGas(t *testing.T) {
}, },
// Test for a bug where the gas price was set to zero but the basefee non-zero // Test for a bug where the gas price was set to zero but the basefee non-zero
// //
// contract Tipper { // contract BasefeeChecker {
// constructor() { // constructor() {
// tx.gasprice - block.basefee; // require(tx.gasprice >= block.basefee);
// if (tx.gasprice > 0) {
// require(block.basefee > 0);
// }
// } // }
// } //}
{ {
blockNumber: rpc.LatestBlockNumber, blockNumber: rpc.LatestBlockNumber,
call: TransactionArgs{ call: TransactionArgs{
From: &accounts[0].addr, From: &accounts[0].addr,
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"), Input: hex2Bytes("6080604052348015600f57600080fd5b50483a1015601c57600080fd5b60003a111560315760004811603057600080fd5b5b603f80603e6000396000f3fe6080604052600080fdfea264697066735822122060729c2cee02b10748fae5200f1c9da4661963354973d9154c13a8e9ce9dee1564736f6c63430008130033"),
GasPrice: (*hexutil.Big)(big.NewInt(1_000_000_000)), // Legacy as pricing GasPrice: (*hexutil.Big)(big.NewInt(1_000_000_000)), // Legacy as pricing
}, },
expectErr: nil, expectErr: nil,
want: 68757, want: 67617,
}, },
{ {
blockNumber: rpc.LatestBlockNumber, blockNumber: rpc.LatestBlockNumber,
call: TransactionArgs{ call: TransactionArgs{
From: &accounts[0].addr, From: &accounts[0].addr,
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"), Input: hex2Bytes("6080604052348015600f57600080fd5b50483a1015601c57600080fd5b60003a111560315760004811603057600080fd5b5b603f80603e6000396000f3fe6080604052600080fdfea264697066735822122060729c2cee02b10748fae5200f1c9da4661963354973d9154c13a8e9ce9dee1564736f6c63430008130033"),
MaxFeePerGas: (*hexutil.Big)(big.NewInt(1_000_000_000)), // 1559 gas pricing MaxFeePerGas: (*hexutil.Big)(big.NewInt(1_000_000_000)), // 1559 gas pricing
}, },
expectErr: nil, expectErr: nil,
want: 68757, want: 67617,
}, },
{ {
blockNumber: rpc.LatestBlockNumber, blockNumber: rpc.LatestBlockNumber,
call: TransactionArgs{ call: TransactionArgs{
From: &accounts[0].addr, From: &accounts[0].addr,
Input: hex2Bytes("6080604052348015600f57600080fd5b50483a601a91906058565b506085565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000606182601f565b9150606a83601f565b9250828203905081811115607f57607e6029565b5b92915050565b603f8060926000396000f3fe6080604052600080fdfea2646970667358221220389a4956b32bb784f6afd2e9db61cef06edaed0e2609234a291e7830e025853364736f6c63430008160033"), Input: hex2Bytes("6080604052348015600f57600080fd5b50483a1015601c57600080fd5b60003a111560315760004811603057600080fd5b5b603f80603e6000396000f3fe6080604052600080fdfea264697066735822122060729c2cee02b10748fae5200f1c9da4661963354973d9154c13a8e9ce9dee1564736f6c63430008130033"),
GasPrice: nil, // No legacy gas pricing GasPrice: nil, // No legacy gas pricing
MaxFeePerGas: nil, // No 1559 gas pricing MaxFeePerGas: nil, // No 1559 gas pricing
}, },
expectErr: nil, expectErr: nil,
want: 68757, want: 67595,
}, },
} }
for i, tc := range testSuite { for i, tc := range testSuite {