@@ -37,8 +37,9 @@ import {
37
37
createTempAccount ,
38
38
getSystemTestBackend ,
39
39
getSystemTestProvider ,
40
+ isGeth ,
40
41
itIf ,
41
- BACKEND
42
+ BACKEND ,
42
43
} from '../../fixtures/system_test_utils' ;
43
44
import { SimpleRevertAbi , SimpleRevertDeploymentData } from '../../fixtures/simple_revert' ;
44
45
@@ -89,9 +90,7 @@ describe('Web3Eth.sendTransaction', () => {
89
90
expect ( response . status ) . toBe ( BigInt ( 1 ) ) ;
90
91
expect ( response . events ) . toBeUndefined ( ) ;
91
92
92
- const minedTransactionData = await web3EthWithWallet . getTransaction (
93
- response . transactionHash ,
94
- ) ;
93
+ const minedTransactionData = await web3EthWithWallet . getTransaction ( response . transactionHash ) ;
95
94
96
95
expect ( minedTransactionData ) . toMatchObject ( {
97
96
from : tempAcc . address ,
@@ -120,9 +119,7 @@ describe('Web3Eth.sendTransaction', () => {
120
119
expect ( response . status ) . toBe ( BigInt ( 1 ) ) ;
121
120
expect ( response . events ) . toBeUndefined ( ) ;
122
121
123
- const minedTransactionData = await web3EthWithWallet . getTransaction (
124
- response . transactionHash ,
125
- ) ;
122
+ const minedTransactionData = await web3EthWithWallet . getTransaction ( response . transactionHash ) ;
126
123
127
124
expect ( minedTransactionData ) . toMatchObject ( {
128
125
from : tempAcc . address ,
@@ -155,9 +152,7 @@ describe('Web3Eth.sendTransaction', () => {
155
152
expect ( response . status ) . toBe ( BigInt ( 1 ) ) ;
156
153
expect ( response . events ) . toBeUndefined ( ) ;
157
154
158
- const minedTransactionData = await web3EthWithWallet . getTransaction (
159
- response . transactionHash ,
160
- ) ;
155
+ const minedTransactionData = await web3EthWithWallet . getTransaction ( response . transactionHash ) ;
161
156
162
157
expect ( minedTransactionData ) . toMatchObject ( {
163
158
from : tempAcc . address ,
@@ -411,6 +406,29 @@ describe('Web3Eth.sendTransaction', () => {
411
406
expect ( minedTransactionData ) . toMatchObject ( transaction ) ;
412
407
} ) ;
413
408
409
+ itIf ( isGeth ) (
410
+ 'should send type 0x2 transaction with maxPriorityFeePerGas got from await web3Eth.getMaxPriorityFeePerGas()' ,
411
+ async ( ) => {
412
+ const transaction : Transaction = {
413
+ from : tempAcc . address ,
414
+ to : '0x0000000000000000000000000000000000000000' ,
415
+ value : BigInt ( 1 ) ,
416
+ maxPriorityFeePerGas : await web3Eth . getMaxPriorityFeePerGas ( ) ,
417
+ } ;
418
+ const response = await web3Eth . sendTransaction ( transaction ) ;
419
+
420
+ // eslint-disable-next-line jest/no-standalone-expect
421
+ expect ( response . events ) . toBeUndefined ( ) ;
422
+ // eslint-disable-next-line jest/no-standalone-expect
423
+ expect ( response . type ) . toBe ( BigInt ( 2 ) ) ;
424
+ // eslint-disable-next-line jest/no-standalone-expect
425
+ expect ( response . status ) . toBe ( BigInt ( 1 ) ) ;
426
+ const minedTransactionData = await web3Eth . getTransaction ( response . transactionHash ) ;
427
+ // eslint-disable-next-line jest/no-standalone-expect
428
+ expect ( minedTransactionData ) . toMatchObject ( transaction ) ;
429
+ } ,
430
+ ) ;
431
+
414
432
describe ( 'Transaction PromiEvents' , ( ) => {
415
433
let transaction : Transaction ;
416
434
@@ -516,12 +534,9 @@ describe('Web3Eth.sendTransaction', () => {
516
534
from : tempAcc . address ,
517
535
data : SimpleRevertDeploymentData ,
518
536
} ;
519
- simpleRevertDeployTransaction . gas = await web3Eth . estimateGas (
520
- simpleRevertDeployTransaction ,
521
- ) ;
522
- simpleRevertContractAddress = (
523
- await web3Eth . sendTransaction ( simpleRevertDeployTransaction )
524
- ) . contractAddress as Address ;
537
+ simpleRevertDeployTransaction . gas = await web3Eth . estimateGas ( simpleRevertDeployTransaction ) ;
538
+ simpleRevertContractAddress = ( await web3Eth . sendTransaction ( simpleRevertDeployTransaction ) )
539
+ . contractAddress as Address ;
525
540
} ) ;
526
541
527
542
it ( 'Should throw TransactionRevertInstructionError because gas too low' , async ( ) => {
@@ -540,51 +555,51 @@ describe('Web3Eth.sendTransaction', () => {
540
555
? 'err: intrinsic gas too low: have 1, want 21000 (supplied gas 1)'
541
556
: 'base fee exceeds gas limit' ,
542
557
} ;
543
-
544
- if ( getSystemTestBackend ( ) !== BACKEND . HARDHAT ) {
558
+
559
+ if ( getSystemTestBackend ( ) !== BACKEND . HARDHAT ) {
545
560
await expect (
546
561
web3Eth
547
562
. sendTransaction ( transaction )
548
563
. on ( 'error' , error => expect ( error ) . toMatchObject ( expectedThrownError ) ) ,
549
564
) . rejects . toMatchObject ( expectedThrownError ) ;
550
565
} else {
551
-
552
566
try {
553
567
await web3Eth . sendTransaction ( transaction ) ;
554
- } catch ( error ) {
568
+ } catch ( error ) {
555
569
expect ( ( error as any ) . name ) . toEqual ( expectedThrownError . name ) ;
556
570
expect ( ( error as any ) . code ) . toEqual ( expectedThrownError . code ) ;
557
571
expect ( ( error as any ) . reason ) . toContain ( expectedThrownError . reason ) ;
558
- }
572
+ }
559
573
}
560
574
} ) ;
561
- itIf ( getSystemTestBackend ( ) !== BACKEND . HARDHAT ) ( 'Should throw TransactionRevertInstructionError because insufficient funds' , async ( ) => {
562
- const transaction : Transaction = {
563
- from : tempAcc . address ,
564
- to : '0x0000000000000000000000000000000000000000' ,
565
- value : BigInt ( '99999999999999999999999999999999999999999999999999999999999999999' ) ,
566
- } ;
567
-
568
- const expectedThrownError = {
569
- name : 'TransactionRevertInstructionError' ,
570
- message : 'Transaction has been reverted by the EVM' ,
571
- code : 402 ,
572
- reason :
573
- getSystemTestBackend ( ) === BACKEND . GETH
574
- ? expect . stringContaining (
575
- 'err: insufficient funds for gas * price + value: address' ,
576
- )
577
- : 'VM Exception while processing transaction: insufficient balance' ,
578
- } ;
579
-
580
- // eslint-disable-next-line jest/no-standalone-expect
581
- await expect (
582
- web3Eth
583
- . sendTransaction ( transaction )
584
- // eslint-disable-next-line jest/no-standalone-expect
585
- . on ( 'error' , error => expect ( error ) . toMatchObject ( expectedThrownError ) ) ,
586
- ) . rejects . toMatchObject ( expectedThrownError ) ;
587
- } ) ;
575
+ itIf ( getSystemTestBackend ( ) !== BACKEND . HARDHAT ) (
576
+ 'Should throw TransactionRevertInstructionError because insufficient funds' ,
577
+ async ( ) => {
578
+ const transaction : Transaction = {
579
+ from : tempAcc . address ,
580
+ to : '0x0000000000000000000000000000000000000000' ,
581
+ value : BigInt ( '99999999999999999999999999999999999999999999999999999999999999999' ) ,
582
+ } ;
583
+
584
+ const expectedThrownError = {
585
+ name : 'TransactionRevertInstructionError' ,
586
+ message : 'Transaction has been reverted by the EVM' ,
587
+ code : 402 ,
588
+ reason :
589
+ getSystemTestBackend ( ) === BACKEND . GETH
590
+ ? expect . stringContaining ( 'err: insufficient funds for gas * price + value: address' )
591
+ : 'VM Exception while processing transaction: insufficient balance' ,
592
+ } ;
593
+
594
+ // eslint-disable-next-line jest/no-standalone-expect
595
+ await expect (
596
+ web3Eth
597
+ . sendTransaction ( transaction )
598
+ // eslint-disable-next-line jest/no-standalone-expect
599
+ . on ( 'error' , error => expect ( error ) . toMatchObject ( expectedThrownError ) ) ,
600
+ ) . rejects . toMatchObject ( expectedThrownError ) ;
601
+ } ,
602
+ ) ;
588
603
589
604
it ( 'Should throw TransactionRevertInstructionError because of contract revert and return revert reason' , async ( ) => {
590
605
const transaction : Transaction = {
@@ -629,7 +644,7 @@ describe('Web3Eth.sendTransaction', () => {
629
644
reason :
630
645
getSystemTestBackend ( ) === BACKEND . GETH
631
646
? 'execution reverted'
632
- : " Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)" ,
647
+ : ' Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)' ,
633
648
signature : '0x72090e4d' ,
634
649
customErrorName : 'ErrorWithNoParams' ,
635
650
customErrorDecodedSignature : 'ErrorWithNoParams()' ,
@@ -659,7 +674,7 @@ describe('Web3Eth.sendTransaction', () => {
659
674
reason :
660
675
getSystemTestBackend ( ) === BACKEND . GETH
661
676
? 'execution reverted'
662
- : " Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)" ,
677
+ : ' Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)' ,
663
678
signature : '0xc85bda60' ,
664
679
data : '000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000' ,
665
680
customErrorName : 'ErrorWithParams' ,
@@ -697,7 +712,7 @@ describe('Web3Eth.sendTransaction', () => {
697
712
signature : '0x08c379a0' ,
698
713
data : '000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000155468697320697320612073656e64207265766572740000000000000000000000' ,
699
714
} ;
700
-
715
+
701
716
await expect (
702
717
web3Eth
703
718
. sendTransaction ( transaction )
0 commit comments