Skip to content

Commit

Permalink
Instantiate correct tx data
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Feb 19, 2024
1 parent f546ff1 commit ba92eaa
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,11 @@ func (t *stTransaction) At(i indexes, baseFee *big.Int) (*types.Transaction, err
value = v
}

var txData types.TxData

// if tx is not dynamic and accessList is not nil, create an access list transaction
if !isDynamiFeeTx && accessList != nil {
return types.NewTx(&types.AccessListTxn{
txData = &types.AccessListTxn{
From: t.From,
To: t.To,
Nonce: t.Nonce,
Expand All @@ -345,20 +347,36 @@ func (t *stTransaction) At(i indexes, baseFee *big.Int) (*types.Transaction, err
GasPrice: gasPrice,
Input: hex.MustDecodeHex(t.Data[i.Data]),
AccessList: accessList,
}), nil
}

return types.NewTx(&types.DynamicFeeTx{
From: t.From,
To: t.To,
Nonce: t.Nonce,
Value: value,
Gas: t.GasLimit[i.Gas],
GasFeeCap: t.MaxFeePerGas,
GasTipCap: t.MaxPriorityFeePerGas,
Input: hex.MustDecodeHex(t.Data[i.Data]),
AccessList: accessList,
}), nil
}
}

if txData == nil {
if isDynamiFeeTx {
txData = &types.DynamicFeeTx{
From: t.From,
To: t.To,
Nonce: t.Nonce,
Value: value,
Gas: t.GasLimit[i.Gas],
GasFeeCap: t.MaxFeePerGas,
GasTipCap: t.MaxPriorityFeePerGas,
Input: hex.MustDecodeHex(t.Data[i.Data]),
AccessList: accessList,
}
} else {
txData = &types.LegacyTx{
From: t.From,
To: t.To,
Nonce: t.Nonce,
Value: value,
Gas: t.GasLimit[i.Gas],
GasPrice: t.GasPrice,
Input: hex.MustDecodeHex(t.Data[i.Data]),
}
}
}

return types.NewTx(txData), nil
}

func (t *stTransaction) UnmarshalJSON(input []byte) error {
Expand Down

0 comments on commit ba92eaa

Please sign in to comment.