@@ -30,11 +30,13 @@ import TokenCreateJson from '../contracts/TokenCreateContract.json';
3030// local resources
3131import parentContractJson from '../contracts/Parent.json' ;
3232import basicContractJson from '../contracts/Basic.json' ;
33+ import storageContractJson from '../contracts/Storage.json' ;
3334import reverterContractJson from '../contracts/Reverter.json' ;
3435import logsContractJson from '../contracts/Logs.json' ;
3536import { predefined } from '../../../relay/src/lib/errors/JsonRpcError' ;
3637import { EthImpl } from '@hashgraph/json-rpc-relay/src/lib/eth' ;
3738import constants from '@hashgraph/json-rpc-relay/src/lib/constants' ;
39+ import { resourceLimits } from 'worker_threads' ;
3840
3941describe ( '@api RPC Server Acceptance Tests' , function ( ) {
4042 this . timeout ( 240 * 1000 ) ; // 240 seconds
@@ -1162,6 +1164,52 @@ describe('@api RPC Server Acceptance Tests', function () {
11621164 } ) ;
11631165 } ) ;
11641166
1167+ // Test state changes with getStorageAt
1168+ describe ( 'eth_getStorageAt' , ( ) => {
1169+ let storageContract , contractId , evmAddress ;
1170+ const STORAGE_CONTRACT_UPDATE = "0x2de4e884" ;
1171+
1172+ before ( async ( ) => {
1173+ storageContract = await servicesNode . deployContract ( storageContractJson ) ;
1174+ // Wait for creation to propagate
1175+ await mirrorNode . get ( `/contracts/${ storageContract . contractId } ` ) ;
1176+
1177+ contractId = storageContract . contractId ;
1178+ evmAddress = `0x${ storageContract . contractId . toSolidityAddress ( ) } ` ;
1179+ } ) ;
1180+
1181+ it ( 'should execute "eth_getStorageAt" request to get state changes' , async function ( ) {
1182+ const BEGIN_EXPECTED_STORAGE_VAL = "0x000000000000000000000000000000000000000000000000000000000000000f" ;
1183+ const END_EXPECTED_STORAGE_VAL = "0x0000000000000000000000000000000000000000000000000000000000000008" ;
1184+
1185+ const beginStorageVal = await relay . call ( 'eth_getStorageAt' , [ `${ contractId } ` , '0x' , 'latest' ] ) ;
1186+ expect ( beginStorageVal ) . to . eq ( BEGIN_EXPECTED_STORAGE_VAL )
1187+
1188+ const gasPrice = await relay . gasPrice ( ) ;
1189+ const transaction = {
1190+ value : 0 ,
1191+ gasLimit : 50000 ,
1192+ chainId : Number ( CHAIN_ID ) ,
1193+ to : evmAddress ,
1194+ nonce : await relay . getAccountNonce ( accounts [ 1 ] . address ) ,
1195+ gasPrice : gasPrice ,
1196+ data : STORAGE_CONTRACT_UPDATE ,
1197+ maxPriorityFeePerGas : gasPrice ,
1198+ maxFeePerGas : gasPrice ,
1199+ type : 2
1200+ } ;
1201+
1202+ const signedTx = await accounts [ 1 ] . wallet . signTransaction ( transaction ) ;
1203+ await relay . call ( 'eth_sendRawTransaction' , [ signedTx ] ) ;
1204+
1205+ // wait for the transaction to propogate to mirror node
1206+ await new Promise ( r => setTimeout ( r , 2000 ) ) ;
1207+
1208+ const storageVal = await relay . call ( 'eth_getStorageAt' , [ `${ contractId } ` , '0x' , 'latest' ] ) ;
1209+ expect ( storageVal ) . to . eq ( END_EXPECTED_STORAGE_VAL )
1210+ } ) ;
1211+ } ) ;
1212+
11651213 // Only run the following tests against a local node since they only work with the genesis account
11661214 if ( process . env . LOCAL_NODE && process . env . LOCAL_NODE !== 'false' ) {
11671215 describe ( 'Gas Price related RPC endpoints' , ( ) => {
0 commit comments