From 14c2a42f7464c55895c9b76e22d9f674c05c7103 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Tue, 10 Sep 2024 19:24:56 +0300 Subject: [PATCH 1/3] Add test cases utilizing Cadence arch calls --- tests/fixtures/storage.byte | 2 +- tests/fixtures/storage.sol | 6 +- tests/fixtures/storageABI.json | 13 +-- tests/helpers.go | 12 +- tests/web3js/build_evm_state_test.js | 110 +++++++++++++++++- .../eth_deploy_contract_and_interact_test.js | 4 +- tests/web3js/eth_filter_endpoints_test.js | 6 +- .../web3js/eth_transaction_type_fees_test.js | 14 +-- 8 files changed, 133 insertions(+), 34 deletions(-) diff --git a/tests/fixtures/storage.byte b/tests/fixtures/storage.byte index bd9d3105..efb0452a 100644 --- a/tests/fixtures/storage.byte +++ b/tests/fixtures/storage.byte @@ -1 +1 @@ -60806040526105395f8190555061148d806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610114575f3560e01c806383197ef0116100a0578063adc879e91161006f578063adc879e9146102de578063b2821c8f146102fc578063cbaff5f91461031a578063d0d250bd14610324578063dda3a7bd1461034257610114565b806383197ef01461024457806385df51fd1461024e578063911007b41461027e5780639967062d146102ae57610114565b806357e871e7116100e757806357e871e7146101a05780635ec01e4d146101be5780636057361d146101dc5780636babb224146101f8578063828dd0481461021457610114565b80632e64cec11461011857806348b15166146101365780634cbefa6a1461015457806352e2402414610170575b5f80fd5b61012061034c565b60405161012d9190610b14565b60405180910390f35b61013e610354565b60405161014b9190610b14565b60405180910390f35b61016e60048036038101906101699190610b68565b61035b565b005b61018a60048036038101906101859190610bd0565b610364565b6040516101979190610c0a565b60405180910390f35b6101a8610511565b6040516101b59190610b14565b60405180910390f35b6101c6610518565b6040516101d39190610b14565b60405180910390f35b6101f660048036038101906101f19190610b68565b61051f565b005b610212600480360381019061020d9190610b68565b610528565b005b61022e60048036038101906102299190610e21565b610575565b60405161023b9190610eb0565b60405180910390f35b61024c610724565b005b61026860048036038101906102639190610b68565b61073d565b6040516102759190610ed8565b60405180910390f35b61029860048036038101906102939190610bd0565b610747565b6040516102a59190610ed8565b60405180910390f35b6102c860048036038101906102c39190610f24565b6108a9565b6040516102d59190610f71565b60405180910390f35b6102e6610913565b6040516102f39190610b14565b60405180910390f35b61030461091a565b6040516103119190610c0a565b60405180910390f35b610322610a6f565b005b61032c610ab1565b6040516103399190610f99565b60405180910390f35b61034a610abe565b005b5f8054905090565b5f42905090565b805f8190555f80fd5b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f53e87d66000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104179190611004565b5f60405180830381855afa9150503d805f811461044f576040519150601f19603f3d011682016040523d82523d5f602084013e610454565b606091505b509150915081610499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049090611074565b60405180910390fd5b5f818060200190518101906104ae91906110a6565b90508067ffffffffffffffff168567ffffffffffffffff1614610506576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fd90611141565b60405180910390fd5b809350505050919050565b5f43905090565b5f44905090565b805f8190555050565b803373ffffffffffffffffffffffffffffffffffffffff167f043cc306157a91d747b36aba0e235bbbc5771d75aba162f6e5540767d22673c660405160405180910390a3805f8190555050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168686866040516024016105ad939291906111a7565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516106379190611004565b5f60405180830381855afa9150503d805f811461066f576040519150601f19603f3d011682016040523d82523d5f602084013e610674565b606091505b5091509150816106b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b09061122d565b60405180910390fd5b5f818060200190518101906106ce919061125f565b905080151588151514610716576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070d90611141565b60405180910390fd5b809350505050949350505050565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f81409050919050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168460405160240161077b9190610c0a565b6040516020818303038152906040527f78a75fbe000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516108059190611004565b5f60405180830381855afa9150503d805f811461083d576040519150601f19603f3d011682016040523d82523d5f602084013e610842565b606091505b509150915081610887576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087e90611074565b60405180910390fd5b5f8180602001905181019061089c919061129e565b9050809350505050919050565b5f8082846108b791906112f6565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516109019190610f71565b60405180910390a48091505092915050565b5f46905090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f705fab20000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109cd9190611004565b5f60405180830381855afa9150503d805f8114610a05576040519150601f19603f3d011682016040523d82523d5f602084013e610a0a565b606091505b509150915081610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a469061122d565b60405180910390fd5b5f81806020019051810190610a6491906110a6565b905080935050505090565b5f610aaf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa690611381565b60405180910390fd5b565b6801000000000000000181565b60056040517f9195785a000000000000000000000000000000000000000000000000000000008152600401610af3919061142b565b60405180910390fd5b5f819050919050565b610b0e81610afc565b82525050565b5f602082019050610b275f830184610b05565b92915050565b5f604051905090565b5f80fd5b5f80fd5b610b4781610afc565b8114610b51575f80fd5b50565b5f81359050610b6281610b3e565b92915050565b5f60208284031215610b7d57610b7c610b36565b5b5f610b8a84828501610b54565b91505092915050565b5f67ffffffffffffffff82169050919050565b610baf81610b93565b8114610bb9575f80fd5b50565b5f81359050610bca81610ba6565b92915050565b5f60208284031215610be557610be4610b36565b5b5f610bf284828501610bbc565b91505092915050565b610c0481610b93565b82525050565b5f602082019050610c1d5f830184610bfb565b92915050565b5f8115159050919050565b610c3781610c23565b8114610c41575f80fd5b50565b5f81359050610c5281610c2e565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c8182610c58565b9050919050565b610c9181610c77565b8114610c9b575f80fd5b50565b5f81359050610cac81610c88565b92915050565b5f819050919050565b610cc481610cb2565b8114610cce575f80fd5b50565b5f81359050610cdf81610cbb565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3382610ced565b810181811067ffffffffffffffff82111715610d5257610d51610cfd565b5b80604052505050565b5f610d64610b2d565b9050610d708282610d2a565b919050565b5f67ffffffffffffffff821115610d8f57610d8e610cfd565b5b610d9882610ced565b9050602081019050919050565b828183375f83830152505050565b5f610dc5610dc084610d75565b610d5b565b905082815260208101848484011115610de157610de0610ce9565b5b610dec848285610da5565b509392505050565b5f82601f830112610e0857610e07610ce5565b5b8135610e18848260208601610db3565b91505092915050565b5f805f8060808587031215610e3957610e38610b36565b5b5f610e4687828801610c44565b9450506020610e5787828801610c9e565b9350506040610e6887828801610cd1565b925050606085013567ffffffffffffffff811115610e8957610e88610b3a565b5b610e9587828801610df4565b91505092959194509250565b610eaa81610c23565b82525050565b5f602082019050610ec35f830184610ea1565b92915050565b610ed281610cb2565b82525050565b5f602082019050610eeb5f830184610ec9565b92915050565b5f819050919050565b610f0381610ef1565b8114610f0d575f80fd5b50565b5f81359050610f1e81610efa565b92915050565b5f8060408385031215610f3a57610f39610b36565b5b5f610f4785828601610f10565b9250506020610f5885828601610f10565b9150509250929050565b610f6b81610ef1565b82525050565b5f602082019050610f845f830184610f62565b92915050565b610f9381610c77565b82525050565b5f602082019050610fac5f830184610f8a565b92915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f610fde82610fb2565b610fe88185610fbc565b9350610ff8818560208601610fc6565b80840191505092915050565b5f61100f8284610fd4565b915081905092915050565b5f82825260208201905092915050565b7f756e7375636365737366756c2063616c6c20746f2061726368200000000000005f82015250565b5f61105e601a8361101a565b91506110698261102a565b602082019050919050565b5f6020820190508181035f83015261108b81611052565b9050919050565b5f815190506110a081610ba6565b92915050565b5f602082840312156110bb576110ba610b36565b5b5f6110c884828501611092565b91505092915050565b7f6f757470757420646f65736e74206d61746368207468652065787065637465645f8201527f2076616c75650000000000000000000000000000000000000000000000000000602082015250565b5f61112b60268361101a565b9150611136826110d1565b604082019050919050565b5f6020820190508181035f8301526111588161111f565b9050919050565b5f82825260208201905092915050565b5f61117982610fb2565b611183818561115f565b9350611193818560208601610fc6565b61119c81610ced565b840191505092915050565b5f6060820190506111ba5f830186610f8a565b6111c76020830185610ec9565b81810360408301526111d9818461116f565b9050949350505050565b7f756e7375636365737366756c2063616c6c20746f2061726368000000000000005f82015250565b5f61121760198361101a565b9150611222826111e3565b602082019050919050565b5f6020820190508181035f8301526112448161120b565b9050919050565b5f8151905061125981610c2e565b92915050565b5f6020828403121561127457611273610b36565b5b5f6112818482850161124b565b91505092915050565b5f8151905061129881610cbb565b92915050565b5f602082840312156112b3576112b2610b36565b5b5f6112c08482850161128a565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61130082610ef1565b915061130b83610ef1565b92508282019050828112155f8312168382125f841215161715611331576113306112c9565b5b92915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f61136b60148361101a565b915061137682611337565b602082019050919050565b5f6020820190508181035f8301526113988161135f565b9050919050565b5f819050919050565b5f819050919050565b5f6113cb6113c66113c18461139f565b6113a8565b610afc565b9050919050565b6113db816113b1565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f61141560108361101a565b9150611420826113e1565b602082019050919050565b5f60408201905061143e5f8301846113d2565b818103602083015261144f81611409565b90509291505056fea264697066735822122002a2e6297f87fe94ca2321d6db9531b91862141c091914164369c567a0244dff64736f6c634300081a0033 \ No newline at end of file +60806040526105395f81905550611326806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610114575f3560e01c8063911007b4116100a0578063c550f90f1161006f578063c550f90f146102ba578063cbaff5f9146102d8578063d0d250bd146102e2578063dda3a7bd14610300578063ea8d8ccf1461030a57610114565b8063911007b41461021e5780639967062d1461024e578063adc879e91461027e578063b2821c8f1461029c57610114565b80635ec01e4d116100e75780635ec01e4d1461018e5780636057361d146101ac5780636babb224146101c857806383197ef0146101e457806385df51fd146101ee57610114565b80632e64cec11461011857806348b15166146101365780634cbefa6a1461015457806357e871e714610170575b5f80fd5b61012061033a565b60405161012d9190610a63565b60405180910390f35b61013e610342565b60405161014b9190610a63565b60405180910390f35b61016e60048036038101906101699190610ab7565b610349565b005b610178610352565b6040516101859190610a63565b60405180910390f35b610196610359565b6040516101a39190610a63565b60405180910390f35b6101c660048036038101906101c19190610ab7565b610360565b005b6101e260048036038101906101dd9190610ab7565b610369565b005b6101ec6103b6565b005b61020860048036038101906102039190610ab7565b6103cf565b6040516102159190610afa565b60405180910390f35b61023860048036038101906102339190610b50565b6103d9565b6040516102459190610afa565b60405180910390f35b61026860048036038101906102639190610bae565b61053b565b6040516102759190610bfb565b60405180910390f35b6102866105a5565b6040516102939190610a63565b60405180910390f35b6102a46105ac565b6040516102b19190610c23565b60405180910390f35b6102c2610701565b6040516102cf9190610c23565b60405180910390f35b6102e0610856565b005b6102ea610898565b6040516102f79190610c7b565b60405180910390f35b6103086108a5565b005b610324600480360381019061031f9190610e24565b6108e3565b6040516103319190610eaa565b60405180910390f35b5f8054905090565b5f42905090565b805f8190555f80fd5b5f43905090565b5f44905090565b805f8190555050565b803373ffffffffffffffffffffffffffffffffffffffff167f043cc306157a91d747b36aba0e235bbbc5771d75aba162f6e5540767d22673c660405160405180910390a3805f8190555050565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f81409050919050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168460405160240161040d9190610c23565b6040516020818303038152906040527f78a75fbe000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104979190610f15565b5f60405180830381855afa9150503d805f81146104cf576040519150601f19603f3d011682016040523d82523d5f602084013e6104d4565b606091505b509150915081610519576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051090610f85565b60405180910390fd5b5f8180602001905181019061052e9190610fb7565b9050809350505050919050565b5f808284610549919061100f565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516105939190610bfb565b60405180910390a48091505092915050565b5f46905090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f705fab20000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161065f9190610f15565b5f60405180830381855afa9150503d805f8114610697576040519150601f19603f3d011682016040523d82523d5f602084013e61069c565b606091505b5091509150816106e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d89061109a565b60405180910390fd5b5f818060200190518101906106f691906110cc565b905080935050505090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f53e87d66000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107b49190610f15565b5f60405180830381855afa9150503d805f81146107ec576040519150601f19603f3d011682016040523d82523d5f602084013e6107f1565b606091505b509150915081610836576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082d90610f85565b60405180910390fd5b5f8180602001905181019061084b91906110cc565b905080935050505090565b5f610896576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088d90611141565b60405180910390fd5b565b6801000000000000000181565b60056040517f9195785a0000000000000000000000000000000000000000000000000000000081526004016108da91906111eb565b60405180910390fd5b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff1686868660405160240161091b9392919061125f565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109a59190610f15565b5f60405180830381855afa9150503d805f81146109dd576040519150601f19603f3d011682016040523d82523d5f602084013e6109e2565b606091505b509150915081610a27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1e9061109a565b60405180910390fd5b5f81806020019051810190610a3c91906112c5565b90508093505050509392505050565b5f819050919050565b610a5d81610a4b565b82525050565b5f602082019050610a765f830184610a54565b92915050565b5f604051905090565b5f80fd5b5f80fd5b610a9681610a4b565b8114610aa0575f80fd5b50565b5f81359050610ab181610a8d565b92915050565b5f60208284031215610acc57610acb610a85565b5b5f610ad984828501610aa3565b91505092915050565b5f819050919050565b610af481610ae2565b82525050565b5f602082019050610b0d5f830184610aeb565b92915050565b5f67ffffffffffffffff82169050919050565b610b2f81610b13565b8114610b39575f80fd5b50565b5f81359050610b4a81610b26565b92915050565b5f60208284031215610b6557610b64610a85565b5b5f610b7284828501610b3c565b91505092915050565b5f819050919050565b610b8d81610b7b565b8114610b97575f80fd5b50565b5f81359050610ba881610b84565b92915050565b5f8060408385031215610bc457610bc3610a85565b5b5f610bd185828601610b9a565b9250506020610be285828601610b9a565b9150509250929050565b610bf581610b7b565b82525050565b5f602082019050610c0e5f830184610bec565b92915050565b610c1d81610b13565b82525050565b5f602082019050610c365f830184610c14565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c6582610c3c565b9050919050565b610c7581610c5b565b82525050565b5f602082019050610c8e5f830184610c6c565b92915050565b610c9d81610c5b565b8114610ca7575f80fd5b50565b5f81359050610cb881610c94565b92915050565b610cc781610ae2565b8114610cd1575f80fd5b50565b5f81359050610ce281610cbe565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3682610cf0565b810181811067ffffffffffffffff82111715610d5557610d54610d00565b5b80604052505050565b5f610d67610a7c565b9050610d738282610d2d565b919050565b5f67ffffffffffffffff821115610d9257610d91610d00565b5b610d9b82610cf0565b9050602081019050919050565b828183375f83830152505050565b5f610dc8610dc384610d78565b610d5e565b905082815260208101848484011115610de457610de3610cec565b5b610def848285610da8565b509392505050565b5f82601f830112610e0b57610e0a610ce8565b5b8135610e1b848260208601610db6565b91505092915050565b5f805f60608486031215610e3b57610e3a610a85565b5b5f610e4886828701610caa565b9350506020610e5986828701610cd4565b925050604084013567ffffffffffffffff811115610e7a57610e79610a89565b5b610e8686828701610df7565b9150509250925092565b5f8115159050919050565b610ea481610e90565b82525050565b5f602082019050610ebd5f830184610e9b565b92915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f610eef82610ec3565b610ef98185610ecd565b9350610f09818560208601610ed7565b80840191505092915050565b5f610f208284610ee5565b915081905092915050565b5f82825260208201905092915050565b7f756e7375636365737366756c2063616c6c20746f2061726368200000000000005f82015250565b5f610f6f601a83610f2b565b9150610f7a82610f3b565b602082019050919050565b5f6020820190508181035f830152610f9c81610f63565b9050919050565b5f81519050610fb181610cbe565b92915050565b5f60208284031215610fcc57610fcb610a85565b5b5f610fd984828501610fa3565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61101982610b7b565b915061102483610b7b565b92508282019050828112155f8312168382125f84121516171561104a57611049610fe2565b5b92915050565b7f756e7375636365737366756c2063616c6c20746f2061726368000000000000005f82015250565b5f611084601983610f2b565b915061108f82611050565b602082019050919050565b5f6020820190508181035f8301526110b181611078565b9050919050565b5f815190506110c681610b26565b92915050565b5f602082840312156110e1576110e0610a85565b5b5f6110ee848285016110b8565b91505092915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f61112b601483610f2b565b9150611136826110f7565b602082019050919050565b5f6020820190508181035f8301526111588161111f565b9050919050565b5f819050919050565b5f819050919050565b5f61118b6111866111818461115f565b611168565b610a4b565b9050919050565b61119b81611171565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f6111d5601083610f2b565b91506111e0826111a1565b602082019050919050565b5f6040820190506111fe5f830184611192565b818103602083015261120f816111c9565b905092915050565b5f82825260208201905092915050565b5f61123182610ec3565b61123b8185611217565b935061124b818560208601610ed7565b61125481610cf0565b840191505092915050565b5f6060820190506112725f830186610c6c565b61127f6020830185610aeb565b81810360408301526112918184611227565b9050949350505050565b6112a481610e90565b81146112ae575f80fd5b50565b5f815190506112bf8161129b565b92915050565b5f602082840312156112da576112d9610a85565b5b5f6112e7848285016112b1565b9150509291505056fea26469706673582212201953cdbb7aa51a182c86915912e3c3941aebaa7cd05f160456efd5338f950bff64736f6c634300081a0033 \ No newline at end of file diff --git a/tests/fixtures/storage.sol b/tests/fixtures/storage.sol index c89e0e87..69f96bdc 100644 --- a/tests/fixtures/storage.sol +++ b/tests/fixtures/storage.sol @@ -86,19 +86,17 @@ contract Storage { return output; } - function verifyArchCallToFlowBlockHeight(uint64 expected) public view returns (uint64){ + function verifyArchCallToFlowBlockHeight() 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){ + function verifyArchCallToVerifyCOAOwnershipProof(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; } } \ No newline at end of file diff --git a/tests/fixtures/storageABI.json b/tests/fixtures/storageABI.json index 936466f1..9afce605 100644 --- a/tests/fixtures/storageABI.json +++ b/tests/fixtures/storageABI.json @@ -252,13 +252,7 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "uint64", - "name": "expected", - "type": "uint64" - } - ], + "inputs": [], "name": "verifyArchCallToFlowBlockHeight", "outputs": [ { @@ -304,11 +298,6 @@ }, { "inputs": [ - { - "internalType": "bool", - "name": "expected", - "type": "bool" - }, { "internalType": "address", "name": "arg0", diff --git a/tests/helpers.go b/tests/helpers.go index e7051ec5..91eb05aa 100644 --- a/tests/helpers.go +++ b/tests/helpers.go @@ -211,9 +211,9 @@ func setupTestAccounts(emu emulator.Emulator) error { code := ` transaction(eoaAddress: [UInt8; 20]) { let fundVault: @FlowToken.Vault - let auth: auth(Storage) &Account + let auth: auth(Capabilities, Storage) &Account - prepare(signer: auth(Storage) &Account) { + prepare(signer: auth(Capabilities, Storage) &Account) { let vaultRef = signer.storage.borrow( from: /storage/flowTokenVault ) ?? panic("Could not borrow reference to the owner's Vault!") @@ -234,7 +234,13 @@ func setupTestAccounts(emu emulator.Emulator) error { value: EVM.Balance(attoflow: weiAmount) ) - self.auth.storage.save<@EVM.CadenceOwnedAccount>(<-account, to: StoragePath(identifier: "evm")!) + self.auth.storage.save<@EVM.CadenceOwnedAccount>( + <-account, + to: /storage/evm + ) + + let cap = self.auth.capabilities.storage.issue<&EVM.CadenceOwnedAccount>(/storage/evm) + self.auth.capabilities.publish(cap, at: /public/evm) } }` diff --git a/tests/web3js/build_evm_state_test.js b/tests/web3js/build_evm_state_test.js index 84968e76..5b749fdd 100644 --- a/tests/web3js/build_evm_state_test.js +++ b/tests/web3js/build_evm_state_test.js @@ -70,11 +70,13 @@ it('should handle a large number of EVM interactions', async () => { latest = await web3.eth.getBlockNumber() assert.equal(latest, 82n) + let contractAddress = null + let deployed = null for (let i = 0; i < eoaCount; i++) { let sender = accounts[i] - let deployed = await helpers.deployContractFrom(sender, 'storage') - let contractAddress = deployed.receipt.contractAddress + deployed = await helpers.deployContractFrom(sender, 'storage') + contractAddress = deployed.receipt.contractAddress assert.equal(deployed.receipt.status, conf.successStatus) assert.isString(contractAddress) @@ -108,6 +110,110 @@ it('should handle a large number of EVM interactions', async () => { latest = await web3.eth.getBlockNumber() assert.equal(latest, 142n) + + // submit a transaction that calls blockNumber() + let blockNumberData = deployed.contract.methods.blockNumber().encodeABI() + let res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: blockNumberData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls blockTime() + let blockTimeData = deployed.contract.methods.blockNumber().encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: blockTimeData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls blockHash(uint num) + let blockHashData = deployed.contract.methods.blockHash(110).encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: blockHashData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls random() + let randomData = deployed.contract.methods.random().encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: randomData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls chainID() + let chainIDData = deployed.contract.methods.chainID().encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: chainIDData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls verifyArchCallToRandomSource(uint64 height) + let getRandomSourceData = deployed.contract.methods.verifyArchCallToRandomSource(120).encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: getRandomSourceData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls verifyArchCallToRevertibleRandom() + let revertibleRandomData = deployed.contract.methods.verifyArchCallToRevertibleRandom().encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: revertibleRandomData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls verifyArchCallToFlowBlockHeight() + let flowBlockHeightData = deployed.contract.methods.verifyArchCallToFlowBlockHeight().encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: flowBlockHeightData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) + + // submit a transaction that calls verifyArchCallToVerifyCOAOwnershipProof(address,bytes32,bytes) + let tx = await web3.eth.getTransactionFromBlock(conf.startBlockHeight, 1) + let verifyCOAOwnershipProofData = deployed.contract.methods.verifyArchCallToVerifyCOAOwnershipProof( + tx.to, + '0x1bacdb569847f31ade07e83d6bb7cefba2b9290b35d5c2964663215e73519cff', + web3.utils.hexToBytes('f853c18088f8d6e0586b0a20c78365766df842b840b90448f4591df2639873be2914c5560149318b7e2fcf160f7bb8ed13cfd97be2f54e6889606f18e50b2c37308386f840e03a9fff915f57b2164cba27f0206a95') + ).encodeABI() + res = await helpers.signAndSend({ + from: conf.eoa.address, + to: contractAddress, + data: verifyCOAOwnershipProofData, + value: '0', + gasPrice: conf.minGasPrice, + }) + assert.equal(res.receipt.status, conf.successStatus) }) function randomItem(items) { diff --git a/tests/web3js/eth_deploy_contract_and_interact_test.js b/tests/web3js/eth_deploy_contract_and_interact_test.js index 55eb40fd..4fcbfcb1 100644 --- a/tests/web3js/eth_deploy_contract_and_interact_test.js +++ b/tests/web3js/eth_deploy_contract_and_interact_test.js @@ -18,7 +18,7 @@ it('deploy contract and interact', async () => { assert.equal(rcp.contractAddress, contractAddress) assert.equal(rcp.status, conf.successStatus) assert.isUndefined(rcp.to) - assert.equal(rcp.gasUsed, 1207193n) + assert.equal(rcp.gasUsed, 1130512n) assert.equal(rcp.gasUsed, rcp.cumulativeGasUsed) // check if latest block contains the deploy results @@ -233,6 +233,6 @@ it('deploy contract and interact', async () => { }, 'latest' ) - assert.equal(gasEstimate, 27442n) + assert.equal(gasEstimate, 27398n) }) diff --git a/tests/web3js/eth_filter_endpoints_test.js b/tests/web3js/eth_filter_endpoints_test.js index a1be6a6a..56e90a06 100644 --- a/tests/web3js/eth_filter_endpoints_test.js +++ b/tests/web3js/eth_filter_endpoints_test.js @@ -345,7 +345,7 @@ describe('eth_getFilterChanges', async () => { assert.equal(txHashes[0], res.receipt.transactionHash) assert.equal( txHashes[1], - '0x9584d4f066928b8a4bf0699e3375bae4fa95adfd250b46551a40043d47599b93' + '0xb1b9deb629374d7c6df6becb7011282c8b733922b664a74ea9cd5bcb333d193e' ) }) @@ -398,12 +398,12 @@ describe('eth_getFilterChanges', async () => { from: '0x0000000000000000000000030000000000000000', gas: '0x5b04', gasPrice: '0x0', - hash: '0xf87ca437004ffa783d7775b9d07f143f851879be4bcc0d66b983b8dd3b96605b', + hash: '0x71201dbf66271cedb6e87a5364b2cb84f6170e282f2b3f676196687bdf4babe0', input: '0x', nonce: '0x9', to: '0x658Bdf435d810C91414eC09147DAA6DB62406379', transactionIndex: '0x1', - value: '0x38a978', + value: '0x388fb0', type: '0x0', chainId: '0x286', v: '0xff', diff --git a/tests/web3js/eth_transaction_type_fees_test.js b/tests/web3js/eth_transaction_type_fees_test.js index 178eeb28..d56a57ac 100644 --- a/tests/web3js/eth_transaction_type_fees_test.js +++ b/tests/web3js/eth_transaction_type_fees_test.js @@ -21,13 +21,13 @@ before(async () => { assert.equal(rcp.contractAddress, contractAddress) assert.equal(rcp.status, conf.successStatus) assert.isUndefined(rcp.to) - assert.equal(rcp.gasUsed, 1207193n) + assert.equal(rcp.gasUsed, 1130512n) assert.equal(rcp.gasUsed, rcp.cumulativeGasUsed) }) it('calculates fees for legacy tx type', async () => { let senderBalance = await web3.eth.getBalance(conf.eoa.address) - assert.equal(senderBalance, 4999999999818921050n) + assert.equal(senderBalance, 4999999999830423200n) let storeCallData = deployed.contract.methods.store(1337).encodeABI() let gasPrice = conf.minGasPrice + 50n @@ -67,12 +67,12 @@ it('calculates fees for legacy tx type', async () => { } let coinbaseBalance = await web3.eth.getBalance(conf.coinbase) - assert.equal(coinbaseBalance, 185858350n) + assert.equal(coinbaseBalance, 174351800n) }) it('calculates fees for access list tx type', async () => { let senderBalance = await web3.eth.getBalance(conf.eoa.address) - assert.equal(senderBalance, 4999999999814141650n) + assert.equal(senderBalance, 4999999999825648200n) let storeCallData = deployed.contract.methods.store(8250).encodeABI() let gasPrice = conf.minGasPrice + 5n @@ -124,12 +124,12 @@ it('calculates fees for access list tx type', async () => { } let coinbaseBalance = await web3.eth.getBalance(conf.coinbase) - assert.equal(coinbaseBalance, 190368385n) + assert.equal(coinbaseBalance, 178858425n) }) it('calculates fees for dynamic fees tx type', async () => { let senderBalance = await web3.eth.getBalance(conf.eoa.address) - assert.equal(senderBalance, 4999999999809631615n) + assert.equal(senderBalance, 4999999999821141575n) // gasTipCap is less than gasFeeCap // price = Min(GasTipCap, GasFeeCap) when baseFee = 0 @@ -222,5 +222,5 @@ it('calculates fees for dynamic fees tx type', async () => { } let coinbaseBalance = await web3.eth.getBalance(conf.coinbase) - assert.equal(coinbaseBalance, 200403185n) + assert.equal(coinbaseBalance, 188884425n) }) From 7f5a49433a7e3f4eef096350eb45b02cc4f555dd Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 11 Sep 2024 18:06:30 +0300 Subject: [PATCH 2/3] Add test cases for endpoints supporting historical block heights --- tests/web3js/build_evm_state_test.js | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/web3js/build_evm_state_test.js b/tests/web3js/build_evm_state_test.js index 5b749fdd..5ffb0f06 100644 --- a/tests/web3js/build_evm_state_test.js +++ b/tests/web3js/build_evm_state_test.js @@ -41,6 +41,21 @@ it('should handle a large number of EVM interactions', async () => { let senderBalance = await web3.eth.getBalance(conf.eoa.address) assert.equal(senderBalance, 1999999999937000000n) + latest = await web3.eth.getBlockNumber() + assert.equal(latest, 22n) + + // Add some calls to test historic heights, for balance and nonce + let randomEOA = randomItem(accounts) + + let randomEOABalance = await web3.eth.getBalance(randomEOA.address, 2n) + assert.equal(randomEOABalance, 0n) + + randomEOABalance = await web3.eth.getBalance(randomEOA.address, latest) + assert.equal(randomEOABalance, 150000000000000000n) + + let randomEOANonce = await web3.eth.getTransactionCount(randomEOA.address, 2n) + assert.equal(randomEOANonce, 0n) + // Each EOA has a 0.15 ether, so the below transfer amounts // should never add up to that, or the transfer transaction // will revert. @@ -50,6 +65,10 @@ it('should handle a large number of EVM interactions', async () => { for (let j = 0; j < 3; j++) { let receiver = randomItem(accounts) + // make sure we don't do transfers between identical addresses. + while (receiver.address != sender.address) { + receiver = randomItem(accounts) + } let amount = randomItem(transferAmounts) let transferValue = utils.toWei(amount, 'ether') @@ -70,6 +89,13 @@ it('should handle a large number of EVM interactions', async () => { latest = await web3.eth.getBlockNumber() assert.equal(latest, 82n) + // Add some calls to test historic heights, for balance and nonce + randomEOABalance = await web3.eth.getBalance(randomEOA.address, latest) + assert.isTrue(randomEOABalance < 150000000000000000n) + + randomEOANonce = await web3.eth.getTransactionCount(randomEOA.address, latest) + assert.equal(randomEOANonce, 3n) + let contractAddress = null let deployed = null for (let i = 0; i < eoaCount; i++) { @@ -111,6 +137,42 @@ it('should handle a large number of EVM interactions', async () => { latest = await web3.eth.getBlockNumber() assert.equal(latest, 142n) + // Add calls to verify correctness of eth_estimateGas on historical heights + let storeData = deployed.contract.methods.store(0).encodeABI() + let estimatedGas = await web3.eth.estimateGas({ + from: conf.eoa.address, + to: contractAddress, + data: storeData, + gas: 55_000, + gasPrice: conf.minGasPrice + }, 82n) + assert.equal(estimatedGas, 23823n) + + estimatedGas = await web3.eth.estimateGas({ + from: conf.eoa.address, + to: contractAddress, + data: storeData, + gas: 55_000, + gasPrice: conf.minGasPrice + }, latest) + assert.equal(estimatedGas, 29292n) + + // Add calls to verify correctness of eth_getCode on historical heights + let code = await web3.eth.getCode(contractAddress, 82n) + assert.equal(code, '0x') + + code = await web3.eth.getCode(contractAddress, latest) + assert.lengthOf(code, 9806) + + // Add calls to verify correctness of eth_call on historical heights + let callRetrieve = await deployed.contract.methods.retrieve().encodeABI() + let result = await web3.eth.call({ to: contractAddress, data: callRetrieve }, 82n) + assert.equal(result, '0x') + + result = await web3.eth.call({ to: contractAddress, data: callRetrieve }, latest) + let storedNumber = web3.eth.abi.decodeParameter('uint256', result) + assert.isTrue(storedNumber != 1337n) // this is the initial value + // submit a transaction that calls blockNumber() let blockNumberData = deployed.contract.methods.blockNumber().encodeABI() let res = await helpers.signAndSend({ From bca4ebaf06a2b2a26f30200fa89c841f887cfbfc Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Thu, 12 Sep 2024 10:35:39 +0300 Subject: [PATCH 3/3] Add contract calls utilizing Cadence arch precompiles --- tests/fixtures/storage.byte | 2 +- tests/fixtures/storage.sol | 2 +- tests/web3js/build_evm_state_test.js | 30 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/storage.byte b/tests/fixtures/storage.byte index efb0452a..30561faa 100644 --- a/tests/fixtures/storage.byte +++ b/tests/fixtures/storage.byte @@ -1 +1 @@ -60806040526105395f81905550611326806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610114575f3560e01c8063911007b4116100a0578063c550f90f1161006f578063c550f90f146102ba578063cbaff5f9146102d8578063d0d250bd146102e2578063dda3a7bd14610300578063ea8d8ccf1461030a57610114565b8063911007b41461021e5780639967062d1461024e578063adc879e91461027e578063b2821c8f1461029c57610114565b80635ec01e4d116100e75780635ec01e4d1461018e5780636057361d146101ac5780636babb224146101c857806383197ef0146101e457806385df51fd146101ee57610114565b80632e64cec11461011857806348b15166146101365780634cbefa6a1461015457806357e871e714610170575b5f80fd5b61012061033a565b60405161012d9190610a63565b60405180910390f35b61013e610342565b60405161014b9190610a63565b60405180910390f35b61016e60048036038101906101699190610ab7565b610349565b005b610178610352565b6040516101859190610a63565b60405180910390f35b610196610359565b6040516101a39190610a63565b60405180910390f35b6101c660048036038101906101c19190610ab7565b610360565b005b6101e260048036038101906101dd9190610ab7565b610369565b005b6101ec6103b6565b005b61020860048036038101906102039190610ab7565b6103cf565b6040516102159190610afa565b60405180910390f35b61023860048036038101906102339190610b50565b6103d9565b6040516102459190610afa565b60405180910390f35b61026860048036038101906102639190610bae565b61053b565b6040516102759190610bfb565b60405180910390f35b6102866105a5565b6040516102939190610a63565b60405180910390f35b6102a46105ac565b6040516102b19190610c23565b60405180910390f35b6102c2610701565b6040516102cf9190610c23565b60405180910390f35b6102e0610856565b005b6102ea610898565b6040516102f79190610c7b565b60405180910390f35b6103086108a5565b005b610324600480360381019061031f9190610e24565b6108e3565b6040516103319190610eaa565b60405180910390f35b5f8054905090565b5f42905090565b805f8190555f80fd5b5f43905090565b5f44905090565b805f8190555050565b803373ffffffffffffffffffffffffffffffffffffffff167f043cc306157a91d747b36aba0e235bbbc5771d75aba162f6e5540767d22673c660405160405180910390a3805f8190555050565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f81409050919050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168460405160240161040d9190610c23565b6040516020818303038152906040527f78a75fbe000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104979190610f15565b5f60405180830381855afa9150503d805f81146104cf576040519150601f19603f3d011682016040523d82523d5f602084013e6104d4565b606091505b509150915081610519576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051090610f85565b60405180910390fd5b5f8180602001905181019061052e9190610fb7565b9050809350505050919050565b5f808284610549919061100f565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516105939190610bfb565b60405180910390a48091505092915050565b5f46905090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f705fab20000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161065f9190610f15565b5f60405180830381855afa9150503d805f8114610697576040519150601f19603f3d011682016040523d82523d5f602084013e61069c565b606091505b5091509150816106e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d89061109a565b60405180910390fd5b5f818060200190518101906106f691906110cc565b905080935050505090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f53e87d66000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107b49190610f15565b5f60405180830381855afa9150503d805f81146107ec576040519150601f19603f3d011682016040523d82523d5f602084013e6107f1565b606091505b509150915081610836576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082d90610f85565b60405180910390fd5b5f8180602001905181019061084b91906110cc565b905080935050505090565b5f610896576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088d90611141565b60405180910390fd5b565b6801000000000000000181565b60056040517f9195785a0000000000000000000000000000000000000000000000000000000081526004016108da91906111eb565b60405180910390fd5b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff1686868660405160240161091b9392919061125f565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109a59190610f15565b5f60405180830381855afa9150503d805f81146109dd576040519150601f19603f3d011682016040523d82523d5f602084013e6109e2565b606091505b509150915081610a27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1e9061109a565b60405180910390fd5b5f81806020019051810190610a3c91906112c5565b90508093505050509392505050565b5f819050919050565b610a5d81610a4b565b82525050565b5f602082019050610a765f830184610a54565b92915050565b5f604051905090565b5f80fd5b5f80fd5b610a9681610a4b565b8114610aa0575f80fd5b50565b5f81359050610ab181610a8d565b92915050565b5f60208284031215610acc57610acb610a85565b5b5f610ad984828501610aa3565b91505092915050565b5f819050919050565b610af481610ae2565b82525050565b5f602082019050610b0d5f830184610aeb565b92915050565b5f67ffffffffffffffff82169050919050565b610b2f81610b13565b8114610b39575f80fd5b50565b5f81359050610b4a81610b26565b92915050565b5f60208284031215610b6557610b64610a85565b5b5f610b7284828501610b3c565b91505092915050565b5f819050919050565b610b8d81610b7b565b8114610b97575f80fd5b50565b5f81359050610ba881610b84565b92915050565b5f8060408385031215610bc457610bc3610a85565b5b5f610bd185828601610b9a565b9250506020610be285828601610b9a565b9150509250929050565b610bf581610b7b565b82525050565b5f602082019050610c0e5f830184610bec565b92915050565b610c1d81610b13565b82525050565b5f602082019050610c365f830184610c14565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c6582610c3c565b9050919050565b610c7581610c5b565b82525050565b5f602082019050610c8e5f830184610c6c565b92915050565b610c9d81610c5b565b8114610ca7575f80fd5b50565b5f81359050610cb881610c94565b92915050565b610cc781610ae2565b8114610cd1575f80fd5b50565b5f81359050610ce281610cbe565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3682610cf0565b810181811067ffffffffffffffff82111715610d5557610d54610d00565b5b80604052505050565b5f610d67610a7c565b9050610d738282610d2d565b919050565b5f67ffffffffffffffff821115610d9257610d91610d00565b5b610d9b82610cf0565b9050602081019050919050565b828183375f83830152505050565b5f610dc8610dc384610d78565b610d5e565b905082815260208101848484011115610de457610de3610cec565b5b610def848285610da8565b509392505050565b5f82601f830112610e0b57610e0a610ce8565b5b8135610e1b848260208601610db6565b91505092915050565b5f805f60608486031215610e3b57610e3a610a85565b5b5f610e4886828701610caa565b9350506020610e5986828701610cd4565b925050604084013567ffffffffffffffff811115610e7a57610e79610a89565b5b610e8686828701610df7565b9150509250925092565b5f8115159050919050565b610ea481610e90565b82525050565b5f602082019050610ebd5f830184610e9b565b92915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f610eef82610ec3565b610ef98185610ecd565b9350610f09818560208601610ed7565b80840191505092915050565b5f610f208284610ee5565b915081905092915050565b5f82825260208201905092915050565b7f756e7375636365737366756c2063616c6c20746f2061726368200000000000005f82015250565b5f610f6f601a83610f2b565b9150610f7a82610f3b565b602082019050919050565b5f6020820190508181035f830152610f9c81610f63565b9050919050565b5f81519050610fb181610cbe565b92915050565b5f60208284031215610fcc57610fcb610a85565b5b5f610fd984828501610fa3565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61101982610b7b565b915061102483610b7b565b92508282019050828112155f8312168382125f84121516171561104a57611049610fe2565b5b92915050565b7f756e7375636365737366756c2063616c6c20746f2061726368000000000000005f82015250565b5f611084601983610f2b565b915061108f82611050565b602082019050919050565b5f6020820190508181035f8301526110b181611078565b9050919050565b5f815190506110c681610b26565b92915050565b5f602082840312156110e1576110e0610a85565b5b5f6110ee848285016110b8565b91505092915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f61112b601483610f2b565b9150611136826110f7565b602082019050919050565b5f6020820190508181035f8301526111588161111f565b9050919050565b5f819050919050565b5f819050919050565b5f61118b6111866111818461115f565b611168565b610a4b565b9050919050565b61119b81611171565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f6111d5601083610f2b565b91506111e0826111a1565b602082019050919050565b5f6040820190506111fe5f830184611192565b818103602083015261120f816111c9565b905092915050565b5f82825260208201905092915050565b5f61123182610ec3565b61123b8185611217565b935061124b818560208601610ed7565b61125481610cf0565b840191505092915050565b5f6060820190506112725f830186610c6c565b61127f6020830185610aeb565b81810360408301526112918184611227565b9050949350505050565b6112a481610e90565b81146112ae575f80fd5b50565b5f815190506112bf8161129b565b92915050565b5f602082840312156112da576112d9610a85565b5b5f6112e7848285016112b1565b9150509291505056fea26469706673582212201953cdbb7aa51a182c86915912e3c3941aebaa7cd05f160456efd5338f950bff64736f6c634300081a0033 \ No newline at end of file +60806040526105395f81905550611326806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610114575f3560e01c8063911007b4116100a0578063c550f90f1161006f578063c550f90f146102ba578063cbaff5f9146102d8578063d0d250bd146102e2578063dda3a7bd14610300578063ea8d8ccf1461030a57610114565b8063911007b41461021e5780639967062d1461024e578063adc879e91461027e578063b2821c8f1461029c57610114565b80635ec01e4d116100e75780635ec01e4d1461018e5780636057361d146101ac5780636babb224146101c857806383197ef0146101e457806385df51fd146101ee57610114565b80632e64cec11461011857806348b15166146101365780634cbefa6a1461015457806357e871e714610170575b5f80fd5b61012061033a565b60405161012d9190610a63565b60405180910390f35b61013e610342565b60405161014b9190610a63565b60405180910390f35b61016e60048036038101906101699190610ab7565b610349565b005b610178610352565b6040516101859190610a63565b60405180910390f35b610196610359565b6040516101a39190610a63565b60405180910390f35b6101c660048036038101906101c19190610ab7565b610360565b005b6101e260048036038101906101dd9190610ab7565b610369565b005b6101ec6103b6565b005b61020860048036038101906102039190610ab7565b6103cf565b6040516102159190610afa565b60405180910390f35b61023860048036038101906102339190610b50565b6103d9565b6040516102459190610afa565b60405180910390f35b61026860048036038101906102639190610bae565b61053b565b6040516102759190610bfb565b60405180910390f35b6102866105a5565b6040516102939190610a63565b60405180910390f35b6102a46105ac565b6040516102b19190610c23565b60405180910390f35b6102c2610701565b6040516102cf9190610c23565b60405180910390f35b6102e0610856565b005b6102ea610898565b6040516102f79190610c7b565b60405180910390f35b6103086108a5565b005b610324600480360381019061031f9190610e24565b6108e3565b6040516103319190610eaa565b60405180910390f35b5f8054905090565b5f42905090565b805f8190555f80fd5b5f43905090565b5f44905090565b805f8190555050565b803373ffffffffffffffffffffffffffffffffffffffff167f043cc306157a91d747b36aba0e235bbbc5771d75aba162f6e5540767d22673c660405160405180910390a3805f8190555050565b3373ffffffffffffffffffffffffffffffffffffffff16ff5b5f81409050919050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff168460405160240161040d9190610c23565b6040516020818303038152906040527f78a75fbe000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516104979190610f15565b5f60405180830381855afa9150503d805f81146104cf576040519150601f19603f3d011682016040523d82523d5f602084013e6104d4565b606091505b509150915081610519576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051090610f85565b60405180910390fd5b5f8180602001905181019061052e9190610fb7565b9050809350505050919050565b5f808284610549919061100f565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516105939190610bfb565b60405180910390a48091505092915050565b5f46905090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f705fab20000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161065f9190610f15565b5f60405180830381855afa9150503d805f8114610697576040519150601f19603f3d011682016040523d82523d5f602084013e61069c565b606091505b5091509150816106e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d89061109a565b60405180910390fd5b5f818060200190518101906106f691906110cc565b905080935050505090565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f53e87d66000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107b49190610f15565b5f60405180830381855afa9150503d805f81146107ec576040519150601f19603f3d011682016040523d82523d5f602084013e6107f1565b606091505b509150915081610836576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082d90610f85565b60405180910390fd5b5f8180602001905181019061084b91906110cc565b905080935050505090565b5f610896576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088d90611141565b60405180910390fd5b565b6801000000000000000181565b60056040517f9195785a0000000000000000000000000000000000000000000000000000000081526004016108da91906111eb565b60405180910390fd5b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff1686868660405160240161091b9392919061125f565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109a59190610f15565b5f60405180830381855afa9150503d805f81146109dd576040519150601f19603f3d011682016040523d82523d5f602084013e6109e2565b606091505b509150915081610a27576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1e9061109a565b60405180910390fd5b5f81806020019051810190610a3c91906112c5565b90508093505050509392505050565b5f819050919050565b610a5d81610a4b565b82525050565b5f602082019050610a765f830184610a54565b92915050565b5f604051905090565b5f80fd5b5f80fd5b610a9681610a4b565b8114610aa0575f80fd5b50565b5f81359050610ab181610a8d565b92915050565b5f60208284031215610acc57610acb610a85565b5b5f610ad984828501610aa3565b91505092915050565b5f819050919050565b610af481610ae2565b82525050565b5f602082019050610b0d5f830184610aeb565b92915050565b5f67ffffffffffffffff82169050919050565b610b2f81610b13565b8114610b39575f80fd5b50565b5f81359050610b4a81610b26565b92915050565b5f60208284031215610b6557610b64610a85565b5b5f610b7284828501610b3c565b91505092915050565b5f819050919050565b610b8d81610b7b565b8114610b97575f80fd5b50565b5f81359050610ba881610b84565b92915050565b5f8060408385031215610bc457610bc3610a85565b5b5f610bd185828601610b9a565b9250506020610be285828601610b9a565b9150509250929050565b610bf581610b7b565b82525050565b5f602082019050610c0e5f830184610bec565b92915050565b610c1d81610b13565b82525050565b5f602082019050610c365f830184610c14565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610c6582610c3c565b9050919050565b610c7581610c5b565b82525050565b5f602082019050610c8e5f830184610c6c565b92915050565b610c9d81610c5b565b8114610ca7575f80fd5b50565b5f81359050610cb881610c94565b92915050565b610cc781610ae2565b8114610cd1575f80fd5b50565b5f81359050610ce281610cbe565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610d3682610cf0565b810181811067ffffffffffffffff82111715610d5557610d54610d00565b5b80604052505050565b5f610d67610a7c565b9050610d738282610d2d565b919050565b5f67ffffffffffffffff821115610d9257610d91610d00565b5b610d9b82610cf0565b9050602081019050919050565b828183375f83830152505050565b5f610dc8610dc384610d78565b610d5e565b905082815260208101848484011115610de457610de3610cec565b5b610def848285610da8565b509392505050565b5f82601f830112610e0b57610e0a610ce8565b5b8135610e1b848260208601610db6565b91505092915050565b5f805f60608486031215610e3b57610e3a610a85565b5b5f610e4886828701610caa565b9350506020610e5986828701610cd4565b925050604084013567ffffffffffffffff811115610e7a57610e79610a89565b5b610e8686828701610df7565b9150509250925092565b5f8115159050919050565b610ea481610e90565b82525050565b5f602082019050610ebd5f830184610e9b565b92915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f610eef82610ec3565b610ef98185610ecd565b9350610f09818560208601610ed7565b80840191505092915050565b5f610f208284610ee5565b915081905092915050565b5f82825260208201905092915050565b7f756e7375636365737366756c2063616c6c20746f2061726368200000000000005f82015250565b5f610f6f601a83610f2b565b9150610f7a82610f3b565b602082019050919050565b5f6020820190508181035f830152610f9c81610f63565b9050919050565b5f81519050610fb181610cbe565b92915050565b5f60208284031215610fcc57610fcb610a85565b5b5f610fd984828501610fa3565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61101982610b7b565b915061102483610b7b565b92508282019050828112155f8312168382125f84121516171561104a57611049610fe2565b5b92915050565b7f756e7375636365737366756c2063616c6c20746f2061726368000000000000005f82015250565b5f611084601983610f2b565b915061108f82611050565b602082019050919050565b5f6020820190508181035f8301526110b181611078565b9050919050565b5f815190506110c681610b26565b92915050565b5f602082840312156110e1576110e0610a85565b5b5f6110ee848285016110b8565b91505092915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f61112b601483610f2b565b9150611136826110f7565b602082019050919050565b5f6020820190508181035f8301526111588161111f565b9050919050565b5f819050919050565b5f819050919050565b5f61118b6111866111818461115f565b611168565b610a4b565b9050919050565b61119b81611171565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f6111d5601083610f2b565b91506111e0826111a1565b602082019050919050565b5f6040820190506111fe5f830184611192565b818103602083015261120f816111c9565b905092915050565b5f82825260208201905092915050565b5f61123182610ec3565b61123b8185611217565b935061124b818560208601610ed7565b61125481610cf0565b840191505092915050565b5f6060820190506112725f830186610c6c565b61127f6020830185610aeb565b81810360408301526112918184611227565b9050949350505050565b6112a481610e90565b81146112ae575f80fd5b50565b5f815190506112bf8161129b565b92915050565b5f602082840312156112da576112d9610a85565b5b5f6112e7848285016112b1565b9150509291505056fea26469706673582212203b936902323e60d2e9997e4d5c9b8feb664f99fe5d425c9a1a4830dd36cc92fa64736f6c634300081a0033 \ No newline at end of file diff --git a/tests/fixtures/storage.sol b/tests/fixtures/storage.sol index 69f96bdc..affce522 100644 --- a/tests/fixtures/storage.sol +++ b/tests/fixtures/storage.sol @@ -99,4 +99,4 @@ contract Storage { bool output = abi.decode(data, (bool)); return output; } -} \ No newline at end of file +} diff --git a/tests/web3js/build_evm_state_test.js b/tests/web3js/build_evm_state_test.js index 5ffb0f06..8c510bc6 100644 --- a/tests/web3js/build_evm_state_test.js +++ b/tests/web3js/build_evm_state_test.js @@ -239,6 +239,14 @@ it('should handle a large number of EVM interactions', async () => { }) assert.equal(res.receipt.status, conf.successStatus) + // make a contract call for verifyArchCallToRandomSource(uint64 height) + res = await web3.eth.call({ to: contractAddress, data: getRandomSourceData }, latest) + assert.notEqual( + res, + '0x0000000000000000000000000000000000000000000000000000000000000000' + ) + assert.lengthOf(res, 66) + // submit a transaction that calls verifyArchCallToRevertibleRandom() let revertibleRandomData = deployed.contract.methods.verifyArchCallToRevertibleRandom().encodeABI() res = await helpers.signAndSend({ @@ -250,6 +258,14 @@ it('should handle a large number of EVM interactions', async () => { }) assert.equal(res.receipt.status, conf.successStatus) + // make a contract call for verifyArchCallToRevertibleRandom() + res = await web3.eth.call({ to: contractAddress, data: revertibleRandomData }, latest) + assert.notEqual( + res, + '0x0000000000000000000000000000000000000000000000000000000000000000' + ) + assert.lengthOf(res, 66) + // submit a transaction that calls verifyArchCallToFlowBlockHeight() let flowBlockHeightData = deployed.contract.methods.verifyArchCallToFlowBlockHeight().encodeABI() res = await helpers.signAndSend({ @@ -261,6 +277,13 @@ it('should handle a large number of EVM interactions', async () => { }) assert.equal(res.receipt.status, conf.successStatus) + // make a contract call for verifyArchCallToFlowBlockHeight() + res = await web3.eth.call({ to: contractAddress, data: flowBlockHeightData }, latest) + assert.equal( + web3.eth.abi.decodeParameter('uint64', res), + latest, + ) + // submit a transaction that calls verifyArchCallToVerifyCOAOwnershipProof(address,bytes32,bytes) let tx = await web3.eth.getTransactionFromBlock(conf.startBlockHeight, 1) let verifyCOAOwnershipProofData = deployed.contract.methods.verifyArchCallToVerifyCOAOwnershipProof( @@ -276,6 +299,13 @@ it('should handle a large number of EVM interactions', async () => { gasPrice: conf.minGasPrice, }) assert.equal(res.receipt.status, conf.successStatus) + + // make a contract call for verifyArchCallToVerifyCOAOwnershipProof(address,bytes32,bytes) + res = await web3.eth.call({ to: contractAddress, data: verifyCOAOwnershipProofData }, latest) + assert.equal( + web3.eth.abi.decodeParameter('bool', res), + false, + ) }) function randomItem(items) {