@@ -4,31 +4,40 @@ const conf = require('./config')
44const helpers = require ( './helpers' )
55const web3 = conf . web3
66
7- it ( 'updates the gas price ' , async ( ) => {
7+ it ( 'should update the value of eth_gasPrice ' , async ( ) => {
88 let gasPrice = await web3 . eth . getGasPrice ( )
9+ // The surge factor was set to 2.0
910 assert . equal ( gasPrice , 2n * conf . minGasPrice )
11+ } )
1012
11- let receiver = web3 . eth . accounts . create ( )
12-
13- // make sure receiver balance is initially 0
14- let receiverWei = await web3 . eth . getBalance ( receiver . address )
15- assert . equal ( receiverWei , 0n )
13+ it ( 'should update the value of eth_MaxPriorityFeePerGas' , async ( ) => {
14+ let response = await helpers . callRPCMethod (
15+ 'eth_maxPriorityFeePerGas' ,
16+ [ ]
17+ )
18+ assert . equal ( response . status , 200 )
19+ assert . isDefined ( response . body . result )
20+ let maxPriorityFeePerGas = utils . hexToNumber ( response . body . result )
21+ // The surge factor was set to 2.0
22+ assert . equal ( maxPriorityFeePerGas , 2n * conf . minGasPrice )
23+ } )
1624
17- // get sender balance
18- let senderBalance = await web3 . eth . getBalance ( conf . eoa . address )
19- assert . equal ( senderBalance , utils . toWei ( conf . fundedAmount , 'ether' ) )
25+ it ( 'should reject transactions with gas price lower than the updated value' , async ( ) => {
26+ let receiver = web3 . eth . accounts . create ( )
27+ let transferValue = utils . toWei ( '2.5' , 'ether' )
2028
21- let txCount = await web3 . eth . getTransactionCount ( conf . eoa . address )
22- assert . equal ( 0n , txCount )
29+ let gasPrice = await web3 . eth . getGasPrice ( )
30+ // The surge factor was set to 2.0
31+ assert . equal ( gasPrice , 2n * conf . minGasPrice )
2332
24- let transferValue = utils . toWei ( '2.5' , 'ether' )
25- // assert that the minimum acceptable gas price has been multiplied by the surge factor
33+ // assert that the minimum acceptable gas price
34+ // has been multiplied by the surge factor
2635 try {
27- let transfer = await helpers . signAndSend ( {
36+ await helpers . signAndSend ( {
2837 from : conf . eoa . address ,
2938 to : receiver . address ,
3039 value : transferValue ,
31- gasPrice : gasPrice - 10n ,
40+ gasPrice : gasPrice - 10n , // provide a lower gas price
3241 gasLimit : 55_000 ,
3342 } )
3443 assert . fail ( 'should not have gotten here' )
@@ -38,12 +47,21 @@ it('updates the gas price', async () => {
3847 `the minimum accepted gas price for transactions is: ${ gasPrice } `
3948 )
4049 }
50+ } )
51+
52+ it ( 'should accept transactions with the updated gas price' , async ( ) => {
53+ let receiver = web3 . eth . accounts . create ( )
54+ let transferValue = utils . toWei ( '2.5' , 'ether' )
55+
56+ let gasPrice = await web3 . eth . getGasPrice ( )
57+ // The surge factor was set to 2.0
58+ assert . equal ( gasPrice , 2n * conf . minGasPrice )
4159
4260 let transfer = await helpers . signAndSend ( {
4361 from : conf . eoa . address ,
4462 to : receiver . address ,
4563 value : transferValue ,
46- gasPrice : gasPrice ,
64+ gasPrice : gasPrice , // provide the updated gas price
4765 gasLimit : 55_000 ,
4866 } )
4967 assert . equal ( transfer . receipt . status , conf . successStatus )
0 commit comments