internal/ethapi: merge CallArgs and SendTxArgs (#22718)

There are two transaction parameter structures defined in
the codebase, although for different purposes. But most of
the parameters are shared. So it's nice to reduce the code
duplication by merging them together.

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
gary rong
2021-05-26 04:30:21 +08:00
committed by GitHub
parent 836c647bdd
commit 51b32cc7e4
5 changed files with 236 additions and 223 deletions

View File

@ -198,7 +198,7 @@ func TestTraceCall(t *testing.T) {
var testSuite = []struct {
blockNumber rpc.BlockNumber
call ethapi.CallArgs
call ethapi.TransactionArgs
config *TraceCallConfig
expectErr error
expect interface{}
@ -206,7 +206,7 @@ func TestTraceCall(t *testing.T) {
// Standard JSON trace upon the genesis, plain transfer.
{
blockNumber: rpc.BlockNumber(0),
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -223,7 +223,7 @@ func TestTraceCall(t *testing.T) {
// Standard JSON trace upon the head, plain transfer.
{
blockNumber: rpc.BlockNumber(genBlocks),
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -240,7 +240,7 @@ func TestTraceCall(t *testing.T) {
// Standard JSON trace upon the non-existent block, error expects
{
blockNumber: rpc.BlockNumber(genBlocks + 1),
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -252,7 +252,7 @@ func TestTraceCall(t *testing.T) {
// Standard JSON trace upon the latest block
{
blockNumber: rpc.LatestBlockNumber,
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -269,7 +269,7 @@ func TestTraceCall(t *testing.T) {
// Standard JSON trace upon the pending block
{
blockNumber: rpc.PendingBlockNumber,
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -329,7 +329,7 @@ func TestOverridenTraceCall(t *testing.T) {
var testSuite = []struct {
blockNumber rpc.BlockNumber
call ethapi.CallArgs
call ethapi.TransactionArgs
config *TraceCallConfig
expectErr error
expect *callTrace
@ -337,7 +337,7 @@ func TestOverridenTraceCall(t *testing.T) {
// Succcessful call with state overriding
{
blockNumber: rpc.PendingBlockNumber,
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &randomAccounts[0].addr,
To: &randomAccounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -361,7 +361,7 @@ func TestOverridenTraceCall(t *testing.T) {
// Invalid call without state overriding
{
blockNumber: rpc.PendingBlockNumber,
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &randomAccounts[0].addr,
To: &randomAccounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
@ -390,7 +390,7 @@ func TestOverridenTraceCall(t *testing.T) {
// }
{
blockNumber: rpc.PendingBlockNumber,
call: ethapi.CallArgs{
call: ethapi.TransactionArgs{
From: &randomAccounts[0].addr,
To: &randomAccounts[2].addr,
Data: newRPCBytes(common.Hex2Bytes("8381f58a")), // call number()