@@ -7,7 +7,7 @@ let deployed = null
77let contractAddress = null
88
99before ( async ( ) => {
10- deployed = await helpers . deployContract ( 'storage ' )
10+ deployed = await helpers . deployContract ( 'blockOverrides ' )
1111 contractAddress = deployed . receipt . contractAddress
1212
1313 assert . equal ( deployed . receipt . status , conf . successStatus )
@@ -20,14 +20,14 @@ it('should apply block overrides on eth_estimateGas', async () => {
2020 assert . equal ( receipt . contractAddress , contractAddress )
2121
2222 // Check the `block.number` value, without overrides
23- let blockNumberSelector = deployed . contract . methods . blockNumber ( ) . encodeABI ( )
23+ let testFuncSelector = deployed . contract . methods . test ( ) . encodeABI ( )
2424 let txArgs = {
2525 from : conf . eoa . address ,
2626 to : contractAddress ,
27- gas : '0x75ab ' ,
27+ gas : '0x493E0 ' ,
2828 gasPrice : web3 . utils . toHex ( conf . minGasPrice ) ,
2929 value : '0x0' ,
30- data : blockNumberSelector ,
30+ data : testFuncSelector ,
3131 }
3232
3333 let response = await helpers . callRPCMethod (
@@ -36,28 +36,25 @@ it('should apply block overrides on eth_estimateGas', async () => {
3636 )
3737 assert . equal ( response . status , 200 )
3838 assert . isDefined ( response . body )
39- assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21651n )
39+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21473n )
4040
41- // Override the `block.number` value to `2 `.
41+ // Override the `block.number` value to `9090 `.
4242 response = await helpers . callRPCMethod (
4343 'eth_estimateGas' ,
44- [ txArgs , 'latest' , null , { number : '0x2 ' } ]
44+ [ txArgs , 'latest' , null , { number : '0x2382 ' } ]
4545 )
4646 assert . equal ( response . status , 200 )
4747 assert . isDefined ( response . body )
48- assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21651n )
48+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 273693n )
4949
5050 // Check the `block.timestamp` value, without overrides
51- let blockTimeSelector = deployed . contract . methods . blockTime ( ) . encodeABI ( )
52- txArgs . data = blockTimeSelector
53-
5451 response = await helpers . callRPCMethod (
5552 'eth_estimateGas' ,
5653 [ txArgs , 'latest' , null , null ]
5754 )
5855 assert . equal ( response . status , 200 )
5956 assert . isDefined ( response . body )
60- assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21607n )
57+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21473n )
6158
6259 // Override the `block.timestamp` value to `0x674DB1E1`.
6360 response = await helpers . callRPCMethod (
@@ -66,18 +63,16 @@ it('should apply block overrides on eth_estimateGas', async () => {
6663 )
6764 assert . equal ( response . status , 200 )
6865 assert . isDefined ( response . body )
69- assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21607n )
66+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 273693n )
7067
7168 // Check the `block.prevrandao` value, without overrides
72- let randomSelector = deployed . contract . methods . random ( ) . encodeABI ( )
73- txArgs . data = randomSelector
74-
7569 response = await helpers . callRPCMethod (
7670 'eth_estimateGas' ,
7771 [ txArgs , 'latest' , null , null ]
7872 )
7973 assert . equal ( response . status , 200 )
8074 assert . isDefined ( response . body )
75+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21473n )
8176
8277 // Override the `block.prevrandao` value to `0x7914bb5b13bac6f621bc37bbf6e406fbf4472aaaaf17ec2f309a92aca4e27fc0`.
8378 let random = '0x7914bb5b13bac6f621bc37bbf6e406fbf4472aaaaf17ec2f309a92aca4e27fc0'
@@ -87,5 +82,23 @@ it('should apply block overrides on eth_estimateGas', async () => {
8782 )
8883 assert . equal ( response . status , 200 )
8984 assert . isDefined ( response . body )
90- assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21584n )
85+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 273693n )
86+
87+ // Check the `block.coinbase` value, without overrides
88+ response = await helpers . callRPCMethod (
89+ 'eth_estimateGas' ,
90+ [ txArgs , 'latest' , null , null ]
91+ )
92+ assert . equal ( response . status , 200 )
93+ assert . isDefined ( response . body )
94+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 21473n )
95+
96+ // Override the `block.coinbase` value to `0x658Bdf435d810C91414eC09147DAA6DB62406379`.
97+ response = await helpers . callRPCMethod (
98+ 'eth_estimateGas' ,
99+ [ txArgs , 'latest' , null , { coinbase : '0x658Bdf435d810C91414eC09147DAA6DB62406379' } ]
100+ )
101+ assert . equal ( response . status , 200 )
102+ assert . isDefined ( response . body )
103+ assert . equal ( web3 . utils . hexToNumber ( response . body . result ) , 273693n )
91104} )
0 commit comments