@@ -4,31 +4,40 @@ const conf = require('./config')
4
4
const helpers = require ( './helpers' )
5
5
const web3 = conf . web3
6
6
7
- it ( 'updates the gas price ' , async ( ) => {
7
+ it ( 'should update the value of eth_gasPrice ' , async ( ) => {
8
8
let gasPrice = await web3 . eth . getGasPrice ( )
9
+ // The surge factor was set to 2.0
9
10
assert . equal ( gasPrice , 2n * conf . minGasPrice )
11
+ } )
10
12
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
+ } )
16
24
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' )
20
28
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 )
23
32
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
26
35
try {
27
- let transfer = await helpers . signAndSend ( {
36
+ await helpers . signAndSend ( {
28
37
from : conf . eoa . address ,
29
38
to : receiver . address ,
30
39
value : transferValue ,
31
- gasPrice : gasPrice - 10n ,
40
+ gasPrice : gasPrice - 10n , // provide a lower gas price
32
41
gasLimit : 55_000 ,
33
42
} )
34
43
assert . fail ( 'should not have gotten here' )
@@ -38,12 +47,21 @@ it('updates the gas price', async () => {
38
47
`the minimum accepted gas price for transactions is: ${ gasPrice } `
39
48
)
40
49
}
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 )
41
59
42
60
let transfer = await helpers . signAndSend ( {
43
61
from : conf . eoa . address ,
44
62
to : receiver . address ,
45
63
value : transferValue ,
46
- gasPrice : gasPrice ,
64
+ gasPrice : gasPrice , // provide the updated gas price
47
65
gasLimit : 55_000 ,
48
66
} )
49
67
assert . equal ( transfer . receipt . status , conf . successStatus )
0 commit comments