@@ -81,8 +81,6 @@ func TestTransactions(t *testing.T) {
8181}
8282
8383func TestTypedTransactions (t * testing.T ) {
84- t .Skip ()
85-
8684 var transactions []struct {
8785 Name string `json:"name"`
8886 AccountAddress ethgo.Address `json:"address"`
@@ -91,62 +89,68 @@ func TestTypedTransactions(t *testing.T) {
9189
9290 Tx struct {
9391 Type ethgo.TransactionType
94- Data * ethgo.ArgBytes `json:"data,omitempty"`
95- GasLimit * ethgo.ArgBig `json:"gasLimit,omitempty"`
96- MaxPriorityFeePerGas * ethgo.ArgBig `json:"maxPriorityFeePerGas,omitempty"`
97- MaxFeePerGas * ethgo.ArgBig `json:"maxFeePerGas,omitempty"`
98- Nonce uint64 `json:"nonce,omitempty"`
99- To * ethgo.Address `json:"to,omitempty"`
100- Value * ethgo.ArgBig `json:"value,omitempty"`
101- GasPrice * ethgo.ArgBig `json:"gasPrice,omitempty"`
102- ChainID uint64 `json:"chainId,omitempty"`
92+ Data * ethgo.ArgBytes `json:"data,omitempty"`
93+ GasLimit * ethgo.ArgBig `json:"gasLimit,omitempty"`
94+ MaxPriorityFeePerGas * ethgo.ArgBig `json:"maxPriorityFeePerGas,omitempty"`
95+ MaxFeePerGas * ethgo.ArgBig `json:"maxFeePerGas,omitempty"`
96+ Nonce uint64 `json:"nonce,omitempty"`
97+ To * ethgo.Address `json:"to,omitempty"`
98+ Value * ethgo.ArgBig `json:"value,omitempty"`
99+ GasPrice * ethgo.ArgBig `json:"gasPrice,omitempty"`
100+ ChainID uint64 `json:"chainId,omitempty"`
101+ AccessList ethgo.AccessList `json:"accessList,omitempty"`
103102 }
104103 }
105104 ReadTestCase (t , "typed-transactions" , & transactions )
106105
107106 for _ , c := range transactions {
108- key , err := wallet .NewWalletFromPrivKey (c .Key )
109- assert .NoError (t , err )
110- assert .Equal (t , key .Address (), c .AccountAddress )
111-
112- txn := & ethgo.Transaction {
113- ChainID : big .NewInt (0 ),
114- Type : c .Tx .Type ,
115- MaxPriorityFeePerGas : (* big .Int )(c .Tx .MaxPriorityFeePerGas ),
116- MaxFeePerGas : (* big .Int )(c .Tx .MaxFeePerGas ),
117- }
118- if c .Tx .Data != nil {
119- txn .Input = * c .Tx .Data
120- }
121- if c .Tx .Value != nil {
122- txn .Value = (* big .Int )(c .Tx .Value )
123- }
124- if c .Tx .To != nil {
125- txn .To = c .Tx .To
126- }
127- if c .Tx .GasLimit != nil {
128- gasLimit , isUint64 := getUint64FromBigInt (c .Tx .GasLimit )
129- if ! isUint64 {
130- return
107+ t .Run (c .Name , func (t * testing.T ) {
108+ key , err := wallet .NewWalletFromPrivKey (c .Key )
109+ assert .NoError (t , err )
110+ assert .Equal (t , key .Address (), c .AccountAddress )
111+
112+ chainID := big .NewInt (int64 (c .Tx .ChainID ))
113+
114+ txn := & ethgo.Transaction {
115+ ChainID : chainID ,
116+ Type : c .Tx .Type ,
117+ MaxPriorityFeePerGas : (* big .Int )(c .Tx .MaxPriorityFeePerGas ),
118+ MaxFeePerGas : (* big .Int )(c .Tx .MaxFeePerGas ),
119+ AccessList : c .Tx .AccessList ,
131120 }
132- txn .Gas = gasLimit
133- }
134- txn .Nonce = c .Tx .Nonce
135- if c .Tx .GasPrice != nil {
136- gasPrice , isUint64 := getUint64FromBigInt (c .Tx .GasPrice )
137- if ! isUint64 {
138- return
121+ if c .Tx .Data != nil {
122+ txn .Input = * c .Tx .Data
123+ }
124+ if c .Tx .Value != nil {
125+ txn .Value = (* big .Int )(c .Tx .Value )
126+ }
127+ if c .Tx .To != nil {
128+ txn .To = c .Tx .To
129+ }
130+ if c .Tx .GasLimit != nil {
131+ gasLimit , isUint64 := getUint64FromBigInt (c .Tx .GasLimit )
132+ if ! isUint64 {
133+ return
134+ }
135+ txn .Gas = gasLimit
136+ }
137+ txn .Nonce = c .Tx .Nonce
138+ if c .Tx .GasPrice != nil {
139+ gasPrice , isUint64 := getUint64FromBigInt (c .Tx .GasPrice )
140+ if ! isUint64 {
141+ return
142+ }
143+ txn .GasPrice = gasPrice
139144 }
140- txn .GasPrice = gasPrice
141- }
142145
143- signer := wallet .NewEIP155Signer (0 )
144- signedTxn , err := signer .SignTx (txn , key )
145- assert .NoError (t , err )
146+ signer := wallet .NewEIP155Signer (chainID . Uint64 () )
147+ signedTxn , err := signer .SignTx (txn , key )
148+ assert .NoError (t , err )
146149
147- txnRaw , err := signedTxn .MarshalRLPTo (nil )
148- assert .NoError (t , err )
150+ txnRaw , err := signedTxn .MarshalRLPTo (nil )
151+ assert .NoError (t , err )
149152
150- t .Log (txnRaw )
153+ assert .Equal (t , txnRaw , c .Signed .Bytes ())
154+ })
151155 }
152156}
0 commit comments