Skip to content

Commit c0cc563

Browse files
committed
Add E2E tests for state override functionality on eth_call
1 parent 742085b commit c0cc563

15 files changed

Lines changed: 469 additions & 85 deletions

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/holiman/uint256 v1.3.2
1414
github.com/onflow/atree v0.10.0
1515
github.com/onflow/cadence v1.7.0-preview.1
16-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19
16+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9
1717
github.com/onflow/flow-go-sdk v1.7.0
1818
github.com/prometheus/client_golang v1.20.5
1919
github.com/rs/cors v1.8.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3
573573
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
574574
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
575575
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
576-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19 h1:LeUxtxxvdZ+JHNokfpo/GjEtjDeuSfcQhnMvGR0Y8Io=
577-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
576+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9 h1:rWsQ6Oh/gbZpUfIHg2THircETCOgUeAdbe6oY5xZMXE=
577+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
578578
github.com/onflow/flow-go-sdk v1.7.0 h1:kSw94LZ+0ppt5ELqzixk7jjzkcrOR0Lh4mOgyu+KTOI=
579579
github.com/onflow/flow-go-sdk v1.7.0/go.mod h1:a5JyRWg1mT6MoixnjTl/E/6AO95u/r2BBy7U/CycvUM=
580580
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 h1:gWJgSSgIGo0qWOqr90+khQ69VoYF9vNlqzF+Yh6YYy4=

tests/e2e_web3js_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func TestWeb3_E2E(t *testing.T) {
7474
runWeb3Test(t, "eth_deploy_contract_and_interact_test")
7575
})
7676

77+
t.Run("apply state overrides", func(t *testing.T) {
78+
runWeb3Test(t, "eth_state_overrides_test")
79+
})
80+
7781
t.Run("test retrieval of contract storage slots", func(t *testing.T) {
7882
runWeb3Test(t, "eth_get_storage_at_test")
7983
})

tests/fixtures/storage.byte

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/fixtures/storage.sol

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ contract Storage {
1111
error MyCustomError(uint value, string message);
1212

1313
uint256 number;
14+
address deployer = 0xea02F564664A477286B93712829180be4764fAe2;
1415

1516
constructor() payable {
1617
number = 1337;
@@ -30,10 +31,18 @@ contract Storage {
3031
revert();
3132
}
3233

33-
function retrieve() public view returns (uint256){
34+
function retrieve() public view returns (uint256) {
3435
return number;
3536
}
3637

38+
function getDeployer() public view returns (address) {
39+
return deployer;
40+
}
41+
42+
function getBalance(address addr) public view returns (uint256) {
43+
return addr.balance;
44+
}
45+
3746
function sum(int A, int B) public returns (int) {
3847
int s = A+B;
3948
emit Calculated(msg.sender, A, B, s);
@@ -64,11 +73,11 @@ contract Storage {
6473
selfdestruct(payable(msg.sender));
6574
}
6675

67-
function assertError() public pure{
76+
function assertError() public pure {
6877
require(false, "Assert Error Message");
6978
}
7079

71-
function customError() public pure{
80+
function customError() public pure {
7281
revert MyCustomError(5, "Value is too low");
7382
}
7483

@@ -86,14 +95,14 @@ contract Storage {
8695
return output;
8796
}
8897

89-
function verifyArchCallToFlowBlockHeight() public view returns (uint64){
98+
function verifyArchCallToFlowBlockHeight() public view returns (uint64) {
9099
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("flowBlockHeight()"));
91100
require(ok, "unsuccessful call to arch ");
92101
uint64 output = abi.decode(data, (uint64));
93102
return output;
94103
}
95104

96-
function verifyArchCallToVerifyCOAOwnershipProof(address arg0 , bytes32 arg1 , bytes memory arg2 ) public view returns (bool){
105+
function verifyArchCallToVerifyCOAOwnershipProof(address arg0, bytes32 arg1, bytes memory arg2) public view returns (bool) {
97106
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("verifyCOAOwnershipProof(address,bytes32,bytes)", arg0, arg1, arg2));
98107
require(ok, "unsuccessful call to arch");
99108
bool output = abi.decode(data, (bool));

tests/fixtures/storageABI.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,38 @@
162162
"stateMutability": "nonpayable",
163163
"type": "function"
164164
},
165+
{
166+
"inputs": [
167+
{
168+
"internalType": "address",
169+
"name": "addr",
170+
"type": "address"
171+
}
172+
],
173+
"name": "getBalance",
174+
"outputs": [
175+
{
176+
"internalType": "uint256",
177+
"name": "",
178+
"type": "uint256"
179+
}
180+
],
181+
"stateMutability": "view",
182+
"type": "function"
183+
},
184+
{
185+
"inputs": [],
186+
"name": "getDeployer",
187+
"outputs": [
188+
{
189+
"internalType": "address",
190+
"name": "",
191+
"type": "address"
192+
}
193+
],
194+
"stateMutability": "view",
195+
"type": "function"
196+
},
165197
{
166198
"inputs": [],
167199
"name": "random",

tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/onflow/crypto v0.25.3
1212
github.com/onflow/flow-emulator v1.7.0-preview.2
1313
github.com/onflow/flow-evm-gateway v0.0.0-20240201154855-4d4d3d3f19c7
14-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19
14+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9
1515
github.com/onflow/flow-go-sdk v1.7.0
1616
github.com/rs/zerolog v1.33.0
1717
github.com/stretchr/testify v1.10.0

tests/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3
829829
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
830830
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
831831
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
832-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19 h1:LeUxtxxvdZ+JHNokfpo/GjEtjDeuSfcQhnMvGR0Y8Io=
833-
github.com/onflow/flow-go v0.42.3-util-fix.0.20250819165158-ea886bab7c19/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
832+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9 h1:rWsQ6Oh/gbZpUfIHg2THircETCOgUeAdbe6oY5xZMXE=
833+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
834834
github.com/onflow/flow-go-sdk v1.7.0 h1:kSw94LZ+0ppt5ELqzixk7jjzkcrOR0Lh4mOgyu+KTOI=
835835
github.com/onflow/flow-go-sdk v1.7.0/go.mod h1:a5JyRWg1mT6MoixnjTl/E/6AO95u/r2BBy7U/CycvUM=
836836
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 h1:gWJgSSgIGo0qWOqr90+khQ69VoYF9vNlqzF+Yh6YYy4=

tests/web3js/build_evm_state_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ it('should handle a large number of EVM interactions', async () => {
165165
gas: 55_000,
166166
gasPrice: conf.minGasPrice
167167
}, latest)
168-
assert.equal(estimatedGas, 26811n)
168+
assert.equal(estimatedGas, 26789n)
169169

170170
// Add calls to verify correctness of eth_getCode on historical heights
171171
let code = await web3.eth.getCode(contractAddress, 82n)
172172
assert.equal(code, '0x')
173173

174174
code = await web3.eth.getCode(contractAddress, latest)
175-
assert.lengthOf(code, 9806)
175+
assert.lengthOf(code, 10236)
176176

177177
// Add calls to verify correctness of eth_call on historical heights
178178
let callRetrieve = deployed.contract.methods.retrieve().encodeABI()

0 commit comments

Comments
 (0)