-
Notifications
You must be signed in to change notification settings - Fork 7
Add cheatcode tests #435
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
base: master
Are you sure you want to change the base?
Add cheatcode tests #435
Changes from all commits
cf06481
fb00c57
634117e
faddcb7
0576916
6d0f526
94efd48
2080137
61f8697
581b65d
d72b2e4
55299cd
883f3ba
cc75e46
90eddfe
75e334f
4b08f04
51d8e6c
f14b9d5
336fc6a
11d0eae
6ec22cc
531e2de
46a34ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,177 @@ | ||||
| //! Individual cheatcode tests for pallet-revive | ||||
| //! Each test runs a specific cheatcode file for easier debugging | ||||
|
|
||||
| use crate::{config::*, test_helpers::TEST_DATA_REVIVE}; | ||||
| use foundry_test_utils::Filter; | ||||
| use revive_strategy::ReviveRuntimeMode; | ||||
| use revm::primitives::hardfork::SpecId; | ||||
| use rstest::rstest; | ||||
|
|
||||
| // Internal macro that accepts directory parameter | ||||
| macro_rules! revive_cheat_test_with_dir { | ||||
| ($test_name:ident, $file_pattern:expr, $dir:expr) => { | ||||
| #[rstest] | ||||
| #[case::evm(ReviveRuntimeMode::Evm)] | ||||
| #[tokio::test(flavor = "multi_thread")] | ||||
| async fn $test_name(#[case] runtime_mode: ReviveRuntimeMode) { | ||||
| let filter = Filter::new(".*", ".*", &format!(".*/{}/{}.*", $dir, $file_pattern)); | ||||
|
|
||||
| let runner = TEST_DATA_REVIVE.runner_revive_with(runtime_mode, |config| { | ||||
| use foundry_config::{FsPermissions, fs_permissions::PathPermission}; | ||||
| config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]); | ||||
| }); | ||||
|
|
||||
| TestConfig::with_filter(runner, filter).spec_id(SpecId::PRAGUE).run().await; | ||||
| } | ||||
| }; | ||||
| } | ||||
|
|
||||
| // Public macro for revive-specific tests (default) | ||||
| macro_rules! revive_cheat_test { | ||||
| ($test_name:ident, $file_pattern:expr) => { | ||||
| revive_cheat_test_with_dir!($test_name, $file_pattern, "revive"); | ||||
| }; | ||||
| } | ||||
|
|
||||
| // Public macro for original cheatcode tests | ||||
| macro_rules! revive_cheat_test_original { | ||||
| ($test_name:ident, $file_pattern:expr) => { | ||||
| revive_cheat_test_with_dir!($test_name, $file_pattern, "cheats"); | ||||
| }; | ||||
| } | ||||
|
|
||||
| revive_cheat_test_original!(test_nonce, "Nonce"); | ||||
| revive_cheat_test!(test_coinbase, "CoinBase"); | ||||
| revive_cheat_test!(test_warp, "Warp"); | ||||
| // TOFIX Fails blockhash | ||||
| revive_cheat_test!(test_roll, "Roll"); | ||||
| revive_cheat_test!(test_chainid, "ChainId"); | ||||
| revive_cheat_test!(test_deal, "Deal"); | ||||
| revive_cheat_test!(test_get_block_timestamp, "GetBlockTimestamp"); | ||||
| revive_cheat_test!(test_get_block_number, "getBlockNumber"); | ||||
| revive_cheat_test_original!(test_expect_emit, "ExpectEmit"); | ||||
| // TOFIX | ||||
| revive_cheat_test_original!(test_expect_revert, "ExpectRevert"); | ||||
| // TOFIX | ||||
| revive_cheat_test_original!(test_expect_call, "ExpectCall"); | ||||
| // vm.fee() doesn't work correctly in revive mode | ||||
| // revive_cheat_test!(test_fee, "Fee"); | ||||
| // vm.prevrandao() doesn't work correctly in revive mode | ||||
| // revive_cheat_test!(test_prevrandao, "Prevrandao"); | ||||
| revive_cheat_test_original!(test_load, "Load"); | ||||
| // Not implemented | ||||
| // revive_cheat_test_original!(test_access_list, "AccessList"); | ||||
| revive_cheat_test_original!(test_addr, "Addr"); | ||||
| // Not implemented vm.setArbitraryStorage | ||||
| // revive_cheat_test_original!(test_arbitrary_storage, "ArbitraryStorage"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_assert, "Assert"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test!(test_assume, "Assume"); | ||||
| revive_cheat_test_original!(test_assume_no_revert, "AssumeNoRevert"); | ||||
| // vm.attachBlob vm.broadcast does not work | ||||
| revive_cheat_test_original!(test_attach_blob, "AttachBlob"); | ||||
| // vm.attachDelegation vm.broadcast does not work | ||||
| // revive_cheat_test_original!(test_attach_delegation, "AttachDelegation"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_base64, "Base64"); | ||||
| // Compilation error | ||||
| // revive_cheat_test!(test_blob_base_fee, "BlobBaseFee"); | ||||
| revive_cheat_test_original!(test_blobhashes, "Blobhashes"); | ||||
| // vm.broadcast does not work | ||||
| // revive_cheat_test_original!(test_broadcast, "Broadcast"); | ||||
| // vm.broadcastRawTransaction does not work | ||||
| // revive_cheat_test_original!(test_broadcast_raw_transaction, "BroadcastRawTransaction"); | ||||
| // vm.cloneAccount maybly ised for forks - skip it | ||||
| //revive_cheat_test_original!(test_clone_account, "CloneAccount"); | ||||
| // not supported in polkadot | ||||
| // revive_cheat_test_original!(test_cool, "Cool"); | ||||
| // vm.copyStorage vm.setArbitraryStorage not implemented | ||||
| //revive_cheat_test_original!(test_copy_storage, "CopyStorage"); | ||||
| // vm.deployCode not implemented | ||||
| revive_cheat_test_original!(test_deploy_code, "DeployCode"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_derive, "Derive"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_ens_namehash, "EnsNamehash"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_env, "Env"); | ||||
| // EXTCODECOPY compilation issue | ||||
| revive_cheat_test_original!(test_etch, "Etch"); | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smiasojed etch, prank, mock tests were already ported by me and passing here:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes I saw it, I will clean this up. But anyway original etch is failing - probably issue with EXTCODECOPY - but it should not affect our EVM path. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah EXTCODECOPY compilation was the reason I modified. the test slightly.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should not error out in this case, because it means that we do not have pvm code which is fine for evm path. @pkhry WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error out
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It means that if any project uses opcodes not supported in PVM, the EVM tests will fail. I’m not sure if this is the right approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
then just disable pvm for now i guess
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or if compilation for pvm fails just skip this bytecode in dualcompiledcontract - the user will not be able to switch to pvm in test |
||||
| revive_cheat_test_original!(test_expect_create, "ExpectCreate"); | ||||
| // revive_cheat_test_original!(test_ffi, "Ffi"); | ||||
| // fork cheatcodes not supported | ||||
| // revive_cheat_test_original!(test_fork, "Fork"); | ||||
| // fork cheatcodes not supported | ||||
| // revive_cheat_test_original!(test_fork2, "Fork2"); | ||||
| // revive_cheat_test_original!(test_fs, "Fs"); | ||||
| revive_cheat_test!(test_get_artifact_path, "GetArtifactPath"); | ||||
| revive_cheat_test_original!(test_get_chain, "GetChain"); | ||||
| revive_cheat_test_original!(test_get_code, "GetCode"); | ||||
| revive_cheat_test!(test_get_deployed_code, "GetDeployedCode"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_get_foundry_version, "GetFoundryVersion"); | ||||
| revive_cheat_test_original!(test_get_label, "GetLabel"); | ||||
| revive_cheat_test_original!(test_get_nonce, "GetNonce"); | ||||
| // Implement test to work without fork | ||||
| revive_cheat_test!(test_get_raw_block_header, "GetRawBlockHeader"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_json, "Json"); | ||||
| // revive_cheat_test_original!(test_label, "Label"); | ||||
| // TODO: check if it is needed | ||||
| // revive_cheat_test_original!(test_mapping, "Mapping"); | ||||
| // TODO: check if it is needed | ||||
| // revive_cheat_test_original!(test_mem_safety, "MemSafety"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_parse, "Parse"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_project_root, "ProjectRoot"); | ||||
| // TODO: check if it is needed | ||||
| // revive_cheat_test_original!(test_prompt, "Prompt"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_random_address, "RandomAddress"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_random_bytes, "RandomBytes"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_random_cheatcodes, "RandomCheatcodes"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_random_uint, "RandomUint"); | ||||
| // TODO: check if it is needed | ||||
| revive_cheat_test_original!(test_read_callers, "ReadCallers"); | ||||
| revive_cheat_test_original!(test_record, "Record"); | ||||
| revive_cheat_test_original!(test_record_account_accesses, "RecordAccountAccesses"); | ||||
| revive_cheat_test_original!(test_record_debug_trace, "RecordDebugTrace"); | ||||
| revive_cheat_test_original!(test_record_logs, "RecordLogs"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_remember, "Remember"); | ||||
| revive_cheat_test_original!(test_reset_nonce, "ResetNonce"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_rpc_urls, "RpcUrls"); | ||||
| revive_cheat_test_original!(test_seed, "Seed"); | ||||
| revive_cheat_test!(test_set_blockhash, "SetBlockhash"); | ||||
| revive_cheat_test_original!(test_set_blockhash2, "SetBlockhash"); | ||||
| revive_cheat_test_original!(test_set_nonce, "SetNonce"); | ||||
| revive_cheat_test_original!(test_set_nonce_unsafe, "SetNonceUnsafe"); | ||||
| revive_cheat_test_original!(test_setup, "Setup"); | ||||
| // revive_cheat_test_original!(test_shuffle, "Shuffle"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_sign, "Sign"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_sign_p256, "SignP256"); | ||||
| revive_cheat_test_original!(test_skip, "Skip"); | ||||
| // revive_cheat_test_original!(test_sleep, "Sleep"); | ||||
| // revive_cheat_test_original!(test_sort, "Sort"); | ||||
| revive_cheat_test_original!(test_state_snapshots, "StateSnapshots"); | ||||
| // Will not work at itt check Gas nd vm.cool | ||||
| revive_cheat_test_original!(test_storage_slot_state, "StorageSlotState"); | ||||
| // SKIP it should not affect pallet-revive execution | ||||
| // revive_cheat_test_original!(test_string_utils, "StringUtils"); | ||||
| // revive_cheat_test_original!(test_to_string, "ToString"); | ||||
| // revive_cheat_test_original!(test_toml, "Toml"); | ||||
| revive_cheat_test!(test_chainid2, "Travel"); | ||||
| // revive_cheat_test_original!(test_try_ffi, "TryFfi"); | ||||
| // revive_cheat_test_original!(test_unix_time, "UnixTime"); | ||||
| // revive_cheat_test_original!(test_wallet, "Wallet"); | ||||
| revive_cheat_test_original!(test_dump_state, "dumpState"); | ||||
| // revive_cheat_test_original!(test_load_allocs, "loadAllocs"); | ||||
| revive_cheat_test_original!(test_gas_metering, "GasMetering"); | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be
*/{}/{}.t.*to correctly grab tests by their filename?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes there is a bug