Skip to content

Commit e8999f4

Browse files
committed
Add E2E tests for state override functionality on eth_call
1 parent 733d0ab commit e8999f4

15 files changed

+492
-112
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ require (
99
github.com/hashicorp/go-multierror v1.1.1
1010
github.com/hashicorp/golang-lru/v2 v2.0.7
1111
github.com/holiman/uint256 v1.3.2
12-
github.com/onflow/atree v0.10.1
13-
github.com/onflow/cadence v1.7.0
14-
github.com/onflow/flow-go v0.43.0
15-
github.com/onflow/flow-go-sdk v1.8.1
12+
github.com/onflow/atree v0.10.0
13+
github.com/onflow/cadence v1.7.0-preview.1
14+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9
15+
github.com/onflow/flow-go-sdk v1.7.0
1616
github.com/prometheus/client_golang v1.20.5
1717
github.com/rs/cors v1.8.0
1818
github.com/rs/zerolog v1.33.0

go.sum

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -574,18 +574,16 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3
574574
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
575575
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
576576
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
577-
github.com/onflow/flow-go v0.43.0 h1:wEXSEQir6A1vT3Mu0g5gEMPYFbyOhzfXpJ9gNHuCJUk=
578-
github.com/onflow/flow-go v0.43.0/go.mod h1:AEgLUD7wvil8c1a1b5Gav20qe/IsS0H/jPG+wOYgmB4=
579-
github.com/onflow/flow-go-sdk v1.8.1 h1:BPp7p10RrpOdezQ3RJ+nheOqpalHlTB9bRocVkLsGNU=
580-
github.com/onflow/flow-go-sdk v1.8.1/go.mod h1:w6bxCznDhJJCDybn1jCUAz3rEO4/7XY9EgWRFrj0zoo=
581-
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=
582-
github.com/onflow/flow-nft/lib/go/contracts v1.3.0/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
583-
github.com/onflow/flow-nft/lib/go/templates v1.3.0 h1:uGIBy4GEY6Z9hKP7sm5nA5kwvbvLWW4nWx5NN9Wg0II=
584-
github.com/onflow/flow-nft/lib/go/templates v1.3.0/go.mod h1:gVbb5fElaOwKhV5UEUjM+JQTjlsguHg2jwRupfM/nng=
585-
github.com/onflow/flow/protobuf/go/flow v0.4.15 h1:7Xt7kkqeeygWMw/S327uKu11FPJghNm1pvam2HXbC7g=
586-
github.com/onflow/flow/protobuf/go/flow v0.4.15/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
587-
github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc=
588-
github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY=
577+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9 h1:rWsQ6Oh/gbZpUfIHg2THircETCOgUeAdbe6oY5xZMXE=
578+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
579+
github.com/onflow/flow-go-sdk v1.7.0 h1:kSw94LZ+0ppt5ELqzixk7jjzkcrOR0Lh4mOgyu+KTOI=
580+
github.com/onflow/flow-go-sdk v1.7.0/go.mod h1:a5JyRWg1mT6MoixnjTl/E/6AO95u/r2BBy7U/CycvUM=
581+
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 h1:gWJgSSgIGo0qWOqr90+khQ69VoYF9vNlqzF+Yh6YYy4=
582+
github.com/onflow/flow-nft/lib/go/contracts v1.2.4/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
583+
github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE=
584+
github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI=
585+
github.com/onflow/flow/protobuf/go/flow v0.4.11 h1:EYjaATmor1ONczbvJ6VejQAJK4elFRk5h9AapxQ7j4c=
586+
github.com/onflow/flow/protobuf/go/flow v0.4.11/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
589587
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=
590588
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk=
591589
github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k=

tests/e2e_web3js_test.go

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

81+
t.Run("apply state overrides", func(t *testing.T) {
82+
runWeb3Test(t, "eth_state_overrides_test")
83+
})
84+
8185
t.Run("test retrieval of contract storage slots", func(t *testing.T) {
8286
runWeb3Test(t, "eth_get_storage_at_test")
8387
})

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ require (
99
github.com/onflow/crypto v0.25.3
1010
github.com/onflow/flow-emulator v1.7.2-0.20250916183715-baa3aeb95f6a
1111
github.com/onflow/flow-evm-gateway v0.0.0-20240201154855-4d4d3d3f19c7
12-
github.com/onflow/flow-go v0.43.0
13-
github.com/onflow/flow-go-sdk v1.8.1
14-
github.com/rs/zerolog v1.34.0
15-
github.com/stretchr/testify v1.11.1
16-
golang.org/x/sync v0.16.0
12+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9
13+
github.com/onflow/flow-go-sdk v1.7.0
14+
github.com/rs/zerolog v1.33.0
15+
github.com/stretchr/testify v1.10.0
16+
golang.org/x/sync v0.15.0
1717
)
1818

1919
require (

tests/go.sum

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -816,18 +816,16 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3
816816
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
817817
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
818818
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
819-
github.com/onflow/flow-go v0.43.0 h1:wEXSEQir6A1vT3Mu0g5gEMPYFbyOhzfXpJ9gNHuCJUk=
820-
github.com/onflow/flow-go v0.43.0/go.mod h1:AEgLUD7wvil8c1a1b5Gav20qe/IsS0H/jPG+wOYgmB4=
821-
github.com/onflow/flow-go-sdk v1.8.1 h1:BPp7p10RrpOdezQ3RJ+nheOqpalHlTB9bRocVkLsGNU=
822-
github.com/onflow/flow-go-sdk v1.8.1/go.mod h1:w6bxCznDhJJCDybn1jCUAz3rEO4/7XY9EgWRFrj0zoo=
823-
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=
824-
github.com/onflow/flow-nft/lib/go/contracts v1.3.0/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
825-
github.com/onflow/flow-nft/lib/go/templates v1.3.0 h1:uGIBy4GEY6Z9hKP7sm5nA5kwvbvLWW4nWx5NN9Wg0II=
826-
github.com/onflow/flow-nft/lib/go/templates v1.3.0/go.mod h1:gVbb5fElaOwKhV5UEUjM+JQTjlsguHg2jwRupfM/nng=
827-
github.com/onflow/flow/protobuf/go/flow v0.4.15 h1:7Xt7kkqeeygWMw/S327uKu11FPJghNm1pvam2HXbC7g=
828-
github.com/onflow/flow/protobuf/go/flow v0.4.15/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
829-
github.com/onflow/go-ethereum v1.13.4 h1:iNO86fm8RbBbhZ87ZulblInqCdHnAQVY8okBrNsTevc=
830-
github.com/onflow/go-ethereum v1.13.4/go.mod h1:cE/gEUkAffhwbVmMJYz+t1dAfVNHNwZCgc3BWtZxBGY=
819+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9 h1:rWsQ6Oh/gbZpUfIHg2THircETCOgUeAdbe6oY5xZMXE=
820+
github.com/onflow/flow-go v0.42.3-util-fix.0.20250905072050-dc2d576024e9/go.mod h1:9j2eaUpjVt9RAt0Th5ewyoWmNMBfVmaG2FGykUvW/sw=
821+
github.com/onflow/flow-go-sdk v1.7.0 h1:kSw94LZ+0ppt5ELqzixk7jjzkcrOR0Lh4mOgyu+KTOI=
822+
github.com/onflow/flow-go-sdk v1.7.0/go.mod h1:a5JyRWg1mT6MoixnjTl/E/6AO95u/r2BBy7U/CycvUM=
823+
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 h1:gWJgSSgIGo0qWOqr90+khQ69VoYF9vNlqzF+Yh6YYy4=
824+
github.com/onflow/flow-nft/lib/go/contracts v1.2.4/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
825+
github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE=
826+
github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI=
827+
github.com/onflow/flow/protobuf/go/flow v0.4.11 h1:EYjaATmor1ONczbvJ6VejQAJK4elFRk5h9AapxQ7j4c=
828+
github.com/onflow/flow/protobuf/go/flow v0.4.11/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
831829
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=
832830
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0/go.mod h1:kMeq9zUwCrgrSojEbTUTTJpZ4WwacVm2pA7LVFr+glk=
833831
github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k=

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)