Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the storage solidity contract used in testing #536

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/e2e_web3js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestWeb3_E2E(t *testing.T) {
require.NoError(t, err)

// contract deployment transaction
deployPayload, _, err := evmSign(big.NewInt(0), 350_000, accountKey, nonce, nil, contractCode)
deployPayload, _, err := evmSign(big.NewInt(0), 1_250_000, accountKey, nonce, nil, contractCode)
require.NoError(t, err)
nonce += 1

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/storage.byte
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60806040526105395f819055506104c9806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c80632e64cec1146100595780636057361d146100775780639967062d14610093578063cbaff5f9146100c3578063dda3a7bd146100cd575b5f80fd5b6100616100d7565b60405161006e91906101ea565b60405180910390f35b610091600480360381019061008c9190610231565b6100df565b005b6100ad60048036038101906100a8919061028f565b6100e8565b6040516100ba91906102dc565b60405180910390f35b6100cb610152565b005b6100d5610194565b005b5f8054905090565b805f8190555050565b5f8082846100f69190610322565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b8460405161014091906102dc565b60405180910390a48091505092915050565b5f610192576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610189906103bd565b60405180910390fd5b565b60056040517f9195785a0000000000000000000000000000000000000000000000000000000081526004016101c99190610467565b60405180910390fd5b5f819050919050565b6101e4816101d2565b82525050565b5f6020820190506101fd5f8301846101db565b92915050565b5f80fd5b610210816101d2565b811461021a575f80fd5b50565b5f8135905061022b81610207565b92915050565b5f6020828403121561024657610245610203565b5b5f6102538482850161021d565b91505092915050565b5f819050919050565b61026e8161025c565b8114610278575f80fd5b50565b5f8135905061028981610265565b92915050565b5f80604083850312156102a5576102a4610203565b5b5f6102b28582860161027b565b92505060206102c38582860161027b565b9150509250929050565b6102d68161025c565b82525050565b5f6020820190506102ef5f8301846102cd565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61032c8261025c565b91506103378361025c565b92508282019050828112155f8312168382125f84121516171561035d5761035c6102f5565b5b92915050565b5f82825260208201905092915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f6103a7601483610363565b91506103b282610373565b602082019050919050565b5f6020820190508181035f8301526103d48161039b565b9050919050565b5f819050919050565b5f819050919050565b5f6104076104026103fd846103db565b6103e4565b6101d2565b9050919050565b610417816103ed565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f610451601083610363565b915061045c8261041d565b602082019050919050565b5f60408201905061047a5f83018461040e565b818103602083015261048b81610445565b90509291505056fea26469706673582212206c2b15d7949b146ae0403a2d44e0ed089f2af31511d01e1126d557a83708e1c464736f6c634300081a0033
60806040526105395f8190555061148d806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610114575f3560e01c806383197ef0116100a0578063adc879e91161006f578063adc879e9146102de578063b2821c8f146102fc578063cbaff5f91461031a578063d0d250bd14610324578063dda3a7bd1461034257610114565b806383197ef01461024457806385df51fd1461024e578063911007b41461027e5780639967062d146102ae57610114565b806357e871e7116100e757806357e871e7146101a05780635ec01e4d146101be5780636057361d146101dc5780636babb224146101f8578063828dd0481461021457610114565b80632e64cec11461011857806348b15166146101365780634cbefa6a1461015457806352e2402414610170575b5f80fd5b61012061034c565b60405161012d9190610b14565b60405180910390f35b61013e610354565b60405161014b9190610b14565b60405180910390f35b61016e60048036038101906101699190610b68565b61035b565b005b61018a60048036038101906101859190610bd0565b610364565b6040516101979190610c0a565b60405180910390f35b6101a8610511565b6040516101b59190610b14565b60405180910390f35b6101c6610518565b6040516101d39190610b14565b60405180910390f35b6101f660048036038101906101f19190610b68565b61051f565b005b610212600480360381019061020d9190610b68565b610528565b005b61022e60048036038101906102299190610e21565b610575565b60405161023b9190610eb0565b60405180910390f35b61024c610724565b005b61026860048036038101906102639190610b68565b61073d565b6040516102759190610ed8565b60405180910390f35b61029860048036038101906102939190610bd0565b610747565b6040516102a59190610ed8565b60405180910390f35b6102c860048036038101906102c39190610f24565b6108a9565b6040516102d59190610f71565b60405180910390f35b6102e6610913565b6040516102f39190610b14565b60405180910390f35b61030461091a565b6040516103119190610c0a565b60405180910390f35b610322610a6f565b005b61032c610ab1565b6040516103399190610f99565b60405180910390f35b61034a610abe565b005b5f8054905090565b5f42905090565b805f8190555f80fd5b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f53e87d66000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104179190611004565b5f60405180830381855afa9150503d805f811461044f576040519150601f19603f3d011682016040523d82523d5f602084013e610454565b606091505b509150915081610499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049090611074565b60405180910390fd5b5f818060200190518101906104ae91906110a6565b90508067ffffffffffffffff168567ffffffffffffffff1614610506576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fd90611141565b60405180910390fd5b809350505050919050565b5f43905090565b5f44905090565b805f8190555050565b803373ffffffffffffffffffffffffffffffffffffffff167f043cc306157a91d747b36aba0e235bbbc5771d75aba162f6e5540767d22673c660405160405180910390a3805f8190555050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168686866040516024016105ad939291906111a7565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516106379190611004565b5f60405180830381855afa9150503d805f811461066f576040519150601f19603f3d011682016040523d82523d5f602084013e610674565b606091505b5091509150816106b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b09061122d565b60405180910390fd5b5f818060200190518101906106ce919061125f565b905080151588151514610716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070d90611141565b60405180910390fd5b809350505050949350505050565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f81409050919050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168460405160240161077b9190610c0a565b6040516020818303038152906040527f78a75fbe000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516108059190611004565b5f60405180830381855afa9150503d805f811461083d576040519150601f19603f3d011682016040523d82523d5f602084013e610842565b606091505b509150915081610887576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087e90611074565b60405180910390fd5b5f8180602001905181019061089c919061129e565b9050809350505050919050565b5f8082846108b791906112f6565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516109019190610f71565b60405180910390a48091505092915050565b5f46905090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f705fab20000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109cd9190611004565b5f60405180830381855afa9150503d805f8114610a05576040519150601f19603f3d011682016040523d82523d5f602084013e610a0a565b606091505b509150915081610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a469061122d565b60405180910390fd5b5f81806020019051810190610a6491906110a6565b905080935050505090565b5f610aaf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa690611381565b60405180910390fd5b565b6801000000000000000181565b60056040517f9195785a000000000000000000000000000000000000000000000000000000008152600401610af3919061142b565b60405180910390fd5b5f819050919050565b610b0e81610afc565b82525050565b5f602082019050610b275f830184610b05565b92915050565b5f604051905090565b5f80fd5b5f80fd5b610b4781610afc565b8114610b51575f80fd5b50565b5f81359050610b6281610b3e565b92915050565b5f60208284031215610b7d57610b7c610b36565b5b5f610b8a84828501610b54565b91505092915050565b5f67ffffffffffffffff82169050919050565b610baf81610b93565b8114610bb9575f80fd5b50565b5f81359050610bca81610ba6565b92915050565b5f60208284031215610be557610be4610b36565b5b5f610bf284828501610bbc565b91505092915050565b610c0481610b93565b82525050565b5f602082019050610c1d5f830184610bfb565b92915050565b5f8115159050919050565b610c3781610c23565b8114610c41575f80fd5b50565b5f81359050610c5281610c2e565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c8182610c58565b9050919050565b610c9181610c77565b8114610c9b575f80fd5b50565b5f81359050610cac81610c88565b92915050565b5f819050919050565b610cc481610cb2565b8114610cce575f80fd5b50565b5f81359050610cdf81610cbb565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3382610ced565b810181811067ffffffffffffffff82111715610d5257610d51610cfd565b5b80604052505050565b5f610d64610b2d565b9050610d708282610d2a565b919050565b5f67ffffffffffffffff821115610d8f57610d8e610cfd565b5b610d9882610ced565b9050602081019050919050565b828183375f83830152505050565b5f610dc5610dc084610d75565b610d5b565b905082815260208101848484011115610de157610de0610ce9565b5b610dec848285610da5565b509392505050565b5f82601f830112610e0857610e07610ce5565b5b8135610e18848260208601610db3565b91505092915050565b5f805f8060808587031215610e3957610e38610b36565b5b5f610e4687828801610c44565b9450506020610e5787828801610c9e565b9350506040610e6887828801610cd1565b925050606085013567ffffffffffffffff811115610e8957610e88610b3a565b5b610e9587828801610df4565b91505092959194509250565b610eaa81610c23565b82525050565b5f602082019050610ec35f830184610ea1565b92915050565b610ed281610cb2565b82525050565b5f602082019050610eeb5f830184610ec9565b92915050565b5f819050919050565b610f0381610ef1565b8114610f0d575f80fd5b50565b5f81359050610f1e81610efa565b92915050565b5f8060408385031215610f3a57610f39610b36565b5b5f610f4785828601610f10565b9250506020610f5885828601610f10565b9150509250929050565b610f6b81610ef1565b82525050565b5f602082019050610f845f830184610f62565b92915050565b610f9381610c77565b82525050565b5f602082019050610fac5f830184610f8a565b92915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f610fde82610fb2565b610fe88185610fbc565b9350610ff8818560208601610fc6565b80840191505092915050565b5f61100f8284610fd4565b915081905092915050565b5f82825260208201905092915050565b7f756e7375636365737366756c2063616c6c20746f2061726368200000000000005f82015250565b5f61105e601a8361101a565b91506110698261102a565b602082019050919050565b5f6020820190508181035f83015261108b81611052565b9050919050565b5f815190506110a081610ba6565b92915050565b5f602082840312156110bb576110ba610b36565b5b5f6110c884828501611092565b91505092915050565b7f6f757470757420646f65736e74206d61746368207468652065787065637465645f8201527f2076616c75650000000000000000000000000000000000000000000000000000602082015250565b5f61112b60268361101a565b9150611136826110d1565b604082019050919050565b5f6020820190508181035f8301526111588161111f565b9050919050565b5f82825260208201905092915050565b5f61117982610fb2565b611183818561115f565b9350611193818560208601610fc6565b61119c81610ced565b840191505092915050565b5f6060820190506111ba5f830186610f8a565b6111c76020830185610ec9565b81810360408301526111d9818461116f565b9050949350505050565b7f756e7375636365737366756c2063616c6c20746f2061726368000000000000005f82015250565b5f61121760198361101a565b9150611222826111e3565b602082019050919050565b5f6020820190508181035f8301526112448161120b565b9050919050565b5f8151905061125981610c2e565b92915050565b5f6020828403121561127457611273610b36565b5b5f6112818482850161124b565b91505092915050565b5f8151905061129881610cbb565b92915050565b5f602082840312156112b3576112b2610b36565b5b5f6112c08482850161128a565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61130082610ef1565b915061130b83610ef1565b92508282019050828112155f8312168382125f841215161715611331576113306112c9565b5b92915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f61136b60148361101a565b915061137682611337565b602082019050919050565b5f6020820190508181035f8301526113988161135f565b9050919050565b5f819050919050565b5f819050919050565b5f6113cb6113c66113c18461139f565b6113a8565b610afc565b9050919050565b6113db816113b1565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f61141560108361101a565b9150611420826113e1565b602082019050919050565b5f60408201905061143e5f8301846113d2565b818103602083015261144f81611409565b90509291505056fea264697066735822122002a2e6297f87fe94ca2321d6db9531b91862141c091914164369c567a0244dff64736f6c634300081a0033
75 changes: 72 additions & 3 deletions tests/fixtures/storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
pragma solidity >=0.8.2 <0.9.0;

contract Storage {
error MyCustomError(uint value, string message);

address constant public cadenceArch = 0x0000000000000000000000010000000000000001;
event NewStore(address indexed caller, uint256 indexed value);
event Calculated(address indexed caller, int indexed numA, int indexed numB, int sum);

error MyCustomError(uint value, string message);

uint256 number;

constructor() payable {
Expand All @@ -15,6 +20,16 @@ contract Storage {
number = num;
}

function storeWithLog(uint256 num) public {
emit NewStore(msg.sender, num);
number = num;
}

function storeButRevert(uint256 num) public {
number = num;
revert();
}

function retrieve() public view returns (uint256){
return number;
}
Expand All @@ -25,11 +40,65 @@ contract Storage {
return s;
}

function assertError() public pure {
function blockNumber() public view returns (uint256) {
return block.number;
}

function blockTime() public view returns (uint) {
return block.timestamp;
}

function blockHash(uint num) public view returns (bytes32) {
return blockhash(num);
}

function random() public view returns (uint256) {
return block.prevrandao;
}

function chainID() public view returns (uint256) {
return block.chainid;
}

function destroy() public {
selfdestruct(payable(msg.sender));
}

function assertError() public pure{
require(false, "Assert Error Message");
}

function customError() public pure {
function customError() public pure{
revert MyCustomError(5, "Value is too low");
}

function verifyArchCallToRandomSource(uint64 height) public view returns (bytes32) {
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("getRandomSource(uint64)", height));
require(ok, "unsuccessful call to arch ");
bytes32 output = abi.decode(data, (bytes32));
return output;
}

function verifyArchCallToRevertibleRandom() public view returns (uint64) {
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("revertibleRandom()"));
require(ok, "unsuccessful call to arch");
uint64 output = abi.decode(data, (uint64));
return output;
}

function verifyArchCallToFlowBlockHeight(uint64 expected) public view returns (uint64){
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("flowBlockHeight()"));
require(ok, "unsuccessful call to arch ");
uint64 output = abi.decode(data, (uint64));
require(expected == output, "output doesnt match the expected value");
return output;
}

function verifyArchCallToVerifyCOAOwnershipProof(bool expected, address arg0 , bytes32 arg1 , bytes memory arg2 ) public view returns (bool){
(bool ok, bytes memory data) = cadenceArch.staticcall(abi.encodeWithSignature("verifyCOAOwnershipProof(address,bytes32,bytes)", arg0, arg1, arg2));
require(ok, "unsuccessful call to arch");
bool output = abi.decode(data, (bool));
require(expected == output, "output doesnt match the expected value");
return output;
}
}
Loading
Loading