├── .cargo └── config.toml ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── 1-bug_report.yml │ ├── 2-feature_request.yml │ ├── 3-work_item.yml │ ├── 4-child_work_item.yml │ └── config.yml ├── dependabot.yml ├── images │ ├── demo.gif │ └── plot.png ├── pull_request_template.md └── workflows │ ├── _build-binaries.yml │ ├── _build-plugin-binaries.yml │ ├── _publish-plugin.yml │ ├── _test-binaries.yml │ ├── automate-stale.yml │ ├── ci.yml │ ├── docs.yml │ ├── label-issues.yml │ ├── nightly.yml │ ├── publish-plugin.yml │ ├── publish-std.yml │ ├── release.yml │ └── scheduled.yml ├── .gitignore ├── .tool-versions ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── RELEASING.md ├── _typos.toml ├── crates ├── cheatnet │ ├── Cargo.toml │ ├── src │ │ ├── constants.rs │ │ ├── data │ │ │ ├── eth_erc20_casm.json │ │ │ └── strk_erc20_casm.json │ │ ├── forking │ │ │ ├── cache.rs │ │ │ ├── mod.rs │ │ │ └── state.rs │ │ ├── lib.rs │ │ ├── predeployment │ │ │ ├── erc20 │ │ │ │ ├── constructor_data.rs │ │ │ │ ├── eth.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── predeployed_contract.rs │ │ │ │ └── strk.rs │ │ │ ├── mod.rs │ │ │ └── predeployed_contract.rs │ │ ├── runtime_extensions │ │ │ ├── call_to_blockifier_runtime_extension │ │ │ │ ├── execution │ │ │ │ │ ├── cairo1_execution.rs │ │ │ │ │ ├── calls.rs │ │ │ │ │ ├── cheated_syscalls.rs │ │ │ │ │ ├── deprecated │ │ │ │ │ │ ├── cairo0_execution.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ │ ├── entry_point.rs │ │ │ │ │ ├── execution_info.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── syscall_hooks.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── panic_data.rs │ │ │ │ └── rpc.rs │ │ │ ├── cheatable_starknet_runtime_extension.rs │ │ │ ├── common.rs │ │ │ ├── deprecated_cheatable_starknet_extension │ │ │ │ ├── mod.rs │ │ │ │ └── runtime.rs │ │ │ ├── forge_config_extension.rs │ │ │ ├── forge_config_extension │ │ │ │ └── config.rs │ │ │ ├── forge_runtime_extension │ │ │ │ ├── cheatcodes │ │ │ │ │ ├── cheat_block_hash.rs │ │ │ │ │ ├── cheat_block_number.rs │ │ │ │ │ ├── cheat_block_timestamp.rs │ │ │ │ │ ├── cheat_caller_address.rs │ │ │ │ │ ├── cheat_execution_info.rs │ │ │ │ │ ├── cheat_sequencer_address.rs │ │ │ │ │ ├── declare.rs │ │ │ │ │ ├── deploy.rs │ │ │ │ │ ├── generate_random_felt.rs │ │ │ │ │ ├── get_class_hash.rs │ │ │ │ │ ├── l1_handler_execute.rs │ │ │ │ │ ├── mock_call.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── precalculate_address.rs │ │ │ │ │ ├── replace_bytecode.rs │ │ │ │ │ ├── spy_events.rs │ │ │ │ │ ├── spy_messages_to_l1.rs │ │ │ │ │ └── storage.rs │ │ │ │ ├── contracts_data.rs │ │ │ │ ├── file_operations.rs │ │ │ │ ├── fuzzer.rs │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── state.rs │ │ └── sync_client.rs │ └── tests │ │ ├── builtins │ │ ├── mod.rs │ │ ├── panic_call.rs │ │ └── segment_arena.rs │ │ ├── cheatcodes │ │ ├── cheat_block_hash.rs │ │ ├── cheat_block_number.rs │ │ ├── cheat_block_timestamp.rs │ │ ├── cheat_caller_address.rs │ │ ├── cheat_execution_info.rs │ │ ├── cheat_sequencer_address.rs │ │ ├── declare.rs │ │ ├── deploy.rs │ │ ├── generate_random_felt.rs │ │ ├── get_class_hash.rs │ │ ├── load.rs │ │ ├── mock_call.rs │ │ ├── mod.rs │ │ ├── multiple_writes_same_storage.rs │ │ ├── precalculate_address.rs │ │ ├── replace_bytecode.rs │ │ ├── spy_events.rs │ │ ├── store.rs │ │ └── test_environment.rs │ │ ├── common │ │ ├── assertions.rs │ │ ├── cache.rs │ │ ├── mod.rs │ │ └── state.rs │ │ ├── contracts │ │ ├── Scarb.toml │ │ └── src │ │ │ ├── bytearray_string_panic_call.cairo │ │ │ ├── cheat_block_hash.cairo │ │ │ ├── cheat_block_hash │ │ │ ├── checker.cairo │ │ │ ├── checker_library_call.cairo │ │ │ ├── checker_proxy.cairo │ │ │ └── constructor_checker.cairo │ │ │ ├── cheat_block_number.cairo │ │ │ ├── cheat_block_number │ │ │ ├── checker.cairo │ │ │ ├── checker_library_call.cairo │ │ │ ├── checker_proxy.cairo │ │ │ └── constructor_checker.cairo │ │ │ ├── cheat_block_timestamp.cairo │ │ │ ├── cheat_block_timestamp │ │ │ ├── checker.cairo │ │ │ ├── checker_library_call.cairo │ │ │ ├── checker_proxy.cairo │ │ │ └── constructor_checker.cairo │ │ │ ├── cheat_caller_address.cairo │ │ │ ├── cheat_caller_address │ │ │ ├── checker.cairo │ │ │ ├── checker_cairo0.cairo │ │ │ ├── checker_library_call.cairo │ │ │ ├── checker_proxy.cairo │ │ │ └── constructor_checker.cairo │ │ │ ├── cheat_sequencer_address.cairo │ │ │ ├── cheat_sequencer_address │ │ │ ├── checker.cairo │ │ │ ├── checker_library_call.cairo │ │ │ ├── checker_proxy.cairo │ │ │ └── constructor_checker.cairo │ │ │ ├── cheat_tx_info.cairo │ │ │ ├── cheat_tx_info │ │ │ ├── constructor_tx_hash_checker.cairo │ │ │ ├── tx_hash_checker_proxy.cairo │ │ │ ├── tx_info_checker.cairo │ │ │ └── tx_info_checker_library_call.cairo │ │ │ ├── common.cairo │ │ │ ├── common │ │ │ ├── constructor_simple.cairo │ │ │ ├── constructor_simple2.cairo │ │ │ └── hello_starknet.cairo │ │ │ ├── events.cairo │ │ │ ├── events │ │ │ ├── constructor_spy_events_checker.cairo │ │ │ ├── spy_events_cairo0.cairo │ │ │ ├── spy_events_checker.cairo │ │ │ ├── spy_events_checker_proxy.cairo │ │ │ ├── spy_events_lib_call.cairo │ │ │ └── spy_events_order_checker.cairo │ │ │ ├── get_class_hash.cairo │ │ │ ├── get_class_hash │ │ │ └── get_class_hash_checker.cairo │ │ │ ├── lib.cairo │ │ │ ├── mock.cairo │ │ │ ├── mock │ │ │ ├── constructor_mock_checker.cairo │ │ │ ├── mock_checker.cairo │ │ │ ├── mock_checker_library_call.cairo │ │ │ └── mock_checker_proxy.cairo │ │ │ ├── panic_call.cairo │ │ │ ├── replace_bytecode.cairo │ │ │ ├── replace_bytecode │ │ │ ├── replace_bytecode_a.cairo │ │ │ ├── replace_bytecode_b.cairo │ │ │ └── replace_fork.cairo │ │ │ ├── revert.cairo │ │ │ ├── segment_arena_user.cairo │ │ │ ├── starknet.cairo │ │ │ ├── starknet │ │ │ ├── block_info_checker_library_call.cairo │ │ │ ├── block_info_checker_proxy.cairo │ │ │ ├── blocker.cairo │ │ │ ├── forking_checker.cairo │ │ │ ├── noncer.cairo │ │ │ └── timestamper.cairo │ │ │ ├── store_load.cairo │ │ │ ├── store_load │ │ │ └── map_simple_value_simple_key.cairo │ │ │ └── tracked_resources.cairo │ │ ├── main.rs │ │ └── starknet │ │ ├── block.rs │ │ ├── cheat_fork.rs │ │ ├── execution.rs │ │ ├── forking.rs │ │ ├── mod.rs │ │ ├── nonce.rs │ │ └── timestamp.rs ├── configuration │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── data │ │ └── stubtool_snfoundry.toml ├── conversions │ ├── Cargo.toml │ ├── cairo-serde-macros │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── cairo_deserialize.rs │ │ │ ├── cairo_serialize.rs │ │ │ └── lib.rs │ ├── src │ │ ├── byte_array.rs │ │ ├── class_hash.rs │ │ ├── contract_address.rs │ │ ├── entrypoint_selector.rs │ │ ├── eth_address.rs │ │ ├── felt.rs │ │ ├── lib.rs │ │ ├── non_zero_felt.rs │ │ ├── non_zero_u128.rs │ │ ├── non_zero_u64.rs │ │ ├── nonce.rs │ │ ├── padded_felt.rs │ │ ├── primitive.rs │ │ ├── serde.rs │ │ ├── serde │ │ │ ├── deserialize.rs │ │ │ ├── deserialize │ │ │ │ └── deserialize_impl.rs │ │ │ ├── lib.rs │ │ │ ├── serialize.rs │ │ │ └── serialize │ │ │ │ ├── raw.rs │ │ │ │ └── serialize_impl.rs │ │ └── string.rs │ └── tests │ │ ├── derive_cairo_deserialize.rs │ │ ├── derive_cairo_serialize.rs │ │ ├── e2e │ │ ├── class_hash.rs │ │ ├── contract_address.rs │ │ ├── entrypoint_selector.rs │ │ ├── felt.rs │ │ ├── field_elements.rs │ │ ├── mod.rs │ │ ├── non_zero_felt.rs │ │ ├── non_zero_u128.rs │ │ ├── non_zero_u64.rs │ │ ├── nonce.rs │ │ ├── padded_felt.rs │ │ └── string.rs │ │ └── main.rs ├── data-transformer │ ├── ARCHITECTURE.md │ ├── Cargo.toml │ ├── src │ │ ├── cairo_types │ │ │ ├── bytes31.rs │ │ │ ├── helpers.rs │ │ │ ├── mod.rs │ │ │ ├── u256.rs │ │ │ ├── u384.rs │ │ │ ├── u512.rs │ │ │ └── u96.rs │ │ ├── lib.rs │ │ ├── reverse_transformer │ │ │ ├── mod.rs │ │ │ ├── transform.rs │ │ │ └── types.rs │ │ ├── shared │ │ │ ├── extraction.rs │ │ │ ├── mod.rs │ │ │ ├── parsing.rs │ │ │ └── path.rs │ │ └── transformer │ │ │ ├── mod.rs │ │ │ └── sierra_abi │ │ │ ├── binary.rs │ │ │ ├── complex_types.rs │ │ │ ├── data_representation.rs │ │ │ ├── literals.rs │ │ │ ├── macros.rs │ │ │ ├── mod.rs │ │ │ └── parsing.rs │ └── tests │ │ ├── data │ │ └── data_transformer │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ └── lib.cairo │ │ ├── integration │ │ ├── identity.rs │ │ ├── mod.rs │ │ ├── reverse_transformer.rs │ │ └── transformer.rs │ │ ├── lib.rs │ │ └── unit │ │ ├── bytes31.rs │ │ ├── mod.rs │ │ ├── u384.rs │ │ └── u96.rs ├── debugging │ ├── Cargo.toml │ └── src │ │ ├── contracts_data_store.rs │ │ ├── lib.rs │ │ ├── trace │ │ ├── collect.rs │ │ ├── mod.rs │ │ └── types.rs │ │ ├── tree │ │ ├── building │ │ │ ├── builder.rs │ │ │ ├── mod.rs │ │ │ └── node.rs │ │ ├── mod.rs │ │ └── ui │ │ │ ├── as_tree_node.rs │ │ │ ├── display.rs │ │ │ └── mod.rs │ │ └── verbosity.rs ├── docs │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── snippet.rs │ │ ├── utils.rs │ │ └── validation.rs ├── forge-runner │ ├── Cargo.toml │ └── src │ │ ├── backtrace │ │ ├── data.rs │ │ ├── display.rs │ │ └── mod.rs │ │ ├── build_trace_data.rs │ │ ├── coverage_api.rs │ │ ├── debugging.rs │ │ ├── expected_result.rs │ │ ├── forge_config.rs │ │ ├── gas.rs │ │ ├── lib.rs │ │ ├── messages.rs │ │ ├── package_tests.rs │ │ ├── package_tests │ │ ├── raw.rs │ │ ├── with_config.rs │ │ └── with_config_resolved.rs │ │ ├── printing.rs │ │ ├── profiler_api.rs │ │ ├── running.rs │ │ ├── running │ │ ├── config_run.rs │ │ ├── copied_code.rs │ │ ├── execution.rs │ │ ├── hints.rs │ │ ├── setup.rs │ │ ├── syscall_handler.rs │ │ └── with_config.rs │ │ ├── test_case_summary.rs │ │ └── test_target_summary.rs ├── forge │ ├── Cargo.toml │ ├── src │ │ ├── block_number_map.rs │ │ ├── clean.rs │ │ ├── combine_configs.rs │ │ ├── compatibility_check.rs │ │ ├── init.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── new.rs │ │ ├── run_tests.rs │ │ ├── run_tests │ │ │ ├── maat.rs │ │ │ ├── package.rs │ │ │ ├── resolve_config.rs │ │ │ ├── structs.rs │ │ │ ├── test_target.rs │ │ │ └── workspace.rs │ │ ├── scarb.rs │ │ ├── scarb │ │ │ └── config.rs │ │ ├── shared_cache.rs │ │ ├── test_filter.rs │ │ └── warn.rs │ ├── test_utils │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── runner.rs │ │ │ └── running_tests.rs │ └── tests │ │ ├── code_quality.rs │ │ ├── data │ │ ├── backtrace_panic │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── backtrace_vm_error │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── collection_with_lib │ │ │ ├── Scarb.toml │ │ │ ├── fob.cairo │ │ │ ├── src │ │ │ │ ├── fab.cairo │ │ │ │ ├── fab │ │ │ │ │ ├── fab_impl.cairo │ │ │ │ │ └── fibfabfob.cairo │ │ │ │ ├── fib.cairo │ │ │ │ ├── fob.cairo │ │ │ │ ├── fob │ │ │ │ │ ├── fibfabfob.cairo │ │ │ │ │ └── fob_impl.cairo │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ ├── fab.cairo │ │ │ │ ├── fab │ │ │ │ └── fab_mod.cairo │ │ │ │ ├── fibfabfob.cairo │ │ │ │ ├── lib.cairo │ │ │ │ ├── not_found.cairo │ │ │ │ └── not_found │ │ │ │ └── not_found.cairo │ │ ├── collection_without_lib │ │ │ ├── Scarb.toml │ │ │ ├── fob.cairo │ │ │ ├── src │ │ │ │ ├── fab.cairo │ │ │ │ ├── fab │ │ │ │ │ ├── fab_impl.cairo │ │ │ │ │ └── fibfabfob.cairo │ │ │ │ ├── fib.cairo │ │ │ │ ├── fob.cairo │ │ │ │ ├── fob │ │ │ │ │ ├── fibfabfob.cairo │ │ │ │ │ └── fob_impl.cairo │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ ├── fab.cairo │ │ │ │ ├── fab │ │ │ │ └── fab_mod.cairo │ │ │ │ ├── fibfabfob.cairo │ │ │ │ └── not_found │ │ │ │ └── not_found.cairo │ │ ├── component_macros │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ ├── example.cairo │ │ │ │ ├── lib.cairo │ │ │ │ └── oz_ac_component.cairo │ │ │ └── tests │ │ │ │ └── test_contract.cairo │ │ ├── contracts │ │ │ ├── benchmarks │ │ │ │ ├── declare_deploy_interact.cairo │ │ │ │ └── test_declare_deploy_interact.cairo │ │ │ ├── block_hash_checker.cairo │ │ │ ├── block_info_checker.cairo │ │ │ ├── catching_error.cairo │ │ │ ├── cheat_block_hash_checker.cairo │ │ │ ├── cheat_block_number_checker.cairo │ │ │ ├── cheat_block_timestamp_checker.cairo │ │ │ ├── cheat_caller_address_checker.cairo │ │ │ ├── cheat_sequencer_address_checker.cairo │ │ │ ├── cheat_tx_info_checker.cairo │ │ │ ├── deploy_checker.cairo │ │ │ ├── dict_using_contract.cairo │ │ │ ├── erc20.cairo │ │ │ ├── gas_checker.cairo │ │ │ ├── gas_checker_proxy.cairo │ │ │ ├── gas_constructor_checker.cairo │ │ │ ├── hello_starknet.cairo │ │ │ ├── keccak_usage.cairo │ │ │ ├── l1_handler_execute_checker.cairo │ │ │ ├── message_to_l1_checker.cairo │ │ │ ├── mock_checker.cairo │ │ │ ├── panicking_constructor.cairo │ │ │ ├── response_with_2_felts.cairo │ │ │ ├── serding.cairo │ │ │ ├── spy_events_checker.cairo │ │ │ ├── storage_tester.cairo │ │ │ ├── too_many_events.cairo │ │ │ ├── trace_dummy.cairo │ │ │ ├── trace_info_checker.cairo │ │ │ ├── trace_info_proxy.cairo │ │ │ └── two_implementations.cairo │ │ ├── coverage_project │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── lib.cairo │ │ ├── debugging │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_trace.cairo │ │ ├── debugging_fork │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_trace.cairo │ │ ├── deterministic_output │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── dispatchers │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ ├── error_handler.cairo │ │ │ │ ├── failable.cairo │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test.cairo │ │ ├── duplicated_test_names │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ ├── tests_a.cairo │ │ │ │ └── tests_b.cairo │ │ ├── empty │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── env │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── erc20_package │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ ├── erc20.cairo │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_complex.cairo │ │ ├── exit_first │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── ext_function_test.cairo │ │ ├── features │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test.cairo │ │ ├── file_reading │ │ │ ├── Scarb.toml │ │ │ ├── data │ │ │ │ ├── json │ │ │ │ │ ├── invalid.json │ │ │ │ │ ├── nested_valid.json │ │ │ │ │ ├── valid.json │ │ │ │ │ └── with_array.json │ │ │ │ ├── negative_number.txt │ │ │ │ ├── non_ascii.txt │ │ │ │ └── valid.txt │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ ├── tests │ │ │ │ └── test.cairo │ │ │ └── valid_file.txt │ │ ├── forking │ │ │ ├── .gitignore │ │ │ ├── .snfoundry_cache │ │ │ │ ├── README.md │ │ │ │ └── http___188_34_188_184_7070_rpc_v0_8_54060_v0_44_0.json │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── fuzzing │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ ├── exit_first_fuzz.cairo │ │ │ │ ├── exit_first_single_fail.cairo │ │ │ │ ├── generate_arg.cairo │ │ │ │ ├── incorrect_args.cairo │ │ │ │ └── multiple_attributes.cairo │ │ ├── hello_workspaces │ │ │ ├── Scarb.toml │ │ │ ├── crates │ │ │ │ ├── addition │ │ │ │ │ ├── Scarb.toml │ │ │ │ │ ├── src │ │ │ │ │ │ └── lib.cairo │ │ │ │ │ └── tests │ │ │ │ │ │ ├── nested.cairo │ │ │ │ │ │ └── nested │ │ │ │ │ │ └── test_nested.cairo │ │ │ │ └── fibonacci │ │ │ │ │ ├── Scarb.toml │ │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ │ └── tests │ │ │ │ │ ├── abc.cairo │ │ │ │ │ ├── abc │ │ │ │ │ └── efg.cairo │ │ │ │ │ ├── lib.cairo │ │ │ │ │ └── not_collected.cairo │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_failing.cairo │ │ ├── nonexistent_selector │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_contract.cairo │ │ ├── panic_decoding │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_panic_decoding.cairo │ │ ├── should_panic_test │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── should_panic_test.cairo │ │ ├── simple_package │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ ├── hello_starknet.cairo │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ ├── contract.cairo │ │ │ │ ├── ext_function_test.cairo │ │ │ │ ├── test_simple.cairo │ │ │ │ └── without_prefix.cairo │ │ ├── steps │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── targets │ │ │ ├── custom_target │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ └── tests.cairo │ │ │ ├── custom_target_custom_names │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ └── tests.cairo │ │ │ ├── custom_target_only_integration │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ └── tests.cairo │ │ │ ├── only_integration │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ └── tests.cairo │ │ │ ├── only_lib_integration │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ ├── lib.cairo │ │ │ │ │ └── tests.cairo │ │ │ ├── only_unit │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── unit_and_integration │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ └── tests.cairo │ │ │ ├── unit_and_lib_integration │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ ├── lib.cairo │ │ │ │ │ └── tests.cairo │ │ │ └── with_features │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ └── tests.cairo │ │ ├── trace │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ └── tests │ │ │ │ └── test_trace.cairo │ │ ├── trace_resources │ │ │ ├── Scarb.toml │ │ │ ├── src │ │ │ │ ├── empty.cairo │ │ │ │ ├── lib.cairo │ │ │ │ ├── trace_dummy.cairo │ │ │ │ ├── trace_info_checker.cairo │ │ │ │ └── trace_info_proxy.cairo │ │ │ └── tests │ │ │ │ ├── lib.cairo │ │ │ │ ├── test_call.cairo │ │ │ │ ├── test_deploy.cairo │ │ │ │ ├── test_failed_call.cairo │ │ │ │ ├── test_failed_lib_call.cairo │ │ │ │ ├── test_l1_handler.cairo │ │ │ │ └── test_lib_call.cairo │ │ └── virtual_workspace │ │ │ ├── Scarb.toml │ │ │ ├── dummy_name │ │ │ ├── fibonacci2 │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ ├── abc.cairo │ │ │ │ │ ├── abc │ │ │ │ │ └── efg.cairo │ │ │ │ │ ├── lib.cairo │ │ │ │ │ └── not_collected.cairo │ │ │ └── subtraction │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ ├── nested.cairo │ │ │ │ └── nested │ │ │ │ └── test_nested.cairo │ │ │ └── not_collected.cairo │ │ ├── e2e │ │ ├── backtrace.rs │ │ ├── build_profile.rs │ │ ├── build_trace_data.rs │ │ ├── clean.rs │ │ ├── collection.rs │ │ ├── color.rs │ │ ├── common │ │ │ ├── mod.rs │ │ │ └── runner.rs │ │ ├── completions.rs │ │ ├── components.rs │ │ ├── contract_artifacts.rs │ │ ├── coverage.rs │ │ ├── debugging.rs │ │ ├── docs_snippets_validation.rs │ │ ├── env.rs │ │ ├── features.rs │ │ ├── fork_warning.rs │ │ ├── forking.rs │ │ ├── fuzzing.rs │ │ ├── io_operations.rs │ │ ├── mod.rs │ │ ├── new.rs │ │ ├── requirements.rs │ │ ├── running.rs │ │ ├── steps.rs │ │ ├── templates.rs │ │ ├── trace_print.rs │ │ ├── trace_resources.rs │ │ └── workspaces.rs │ │ ├── integration │ │ ├── available_gas.rs │ │ ├── builtins.rs │ │ ├── cheat_block_hash.rs │ │ ├── cheat_block_number.rs │ │ ├── cheat_block_timestamp.rs │ │ ├── cheat_caller_address.rs │ │ ├── cheat_execution_info.rs │ │ ├── cheat_fork.rs │ │ ├── cheat_sequencer_address.rs │ │ ├── declare.rs │ │ ├── deploy.rs │ │ ├── deploy_at.rs │ │ ├── dict.rs │ │ ├── dispatchers.rs │ │ ├── env.rs │ │ ├── fuzzing.rs │ │ ├── gas.rs │ │ ├── generate_random_felt.rs │ │ ├── get_class_hash.rs │ │ ├── l1_handler_executor.rs │ │ ├── message_to_l1.rs │ │ ├── mock_call.rs │ │ ├── mod.rs │ │ ├── precalculate_address.rs │ │ ├── pure_cairo.rs │ │ ├── replace_bytecode.rs │ │ ├── resources.rs │ │ ├── runtime.rs │ │ ├── set_balance.rs │ │ ├── setup_fork.rs │ │ ├── should_panic.rs │ │ ├── signing.rs │ │ ├── spy_events.rs │ │ ├── store_load.rs │ │ ├── syscalls.rs │ │ ├── test_state.rs │ │ ├── too_many_events.rs │ │ └── trace.rs │ │ └── main.rs ├── foundry-ui │ ├── Cargo.toml │ └── src │ │ ├── components │ │ ├── error.rs │ │ ├── labeled.rs │ │ ├── mod.rs │ │ ├── tagged.rs │ │ └── warning.rs │ │ ├── lib.rs │ │ ├── message.rs │ │ └── output.rs ├── runtime │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── starknet │ │ ├── constants.rs │ │ ├── context.rs │ │ ├── mod.rs │ │ └── state.rs │ │ └── vm.rs ├── scarb-api │ ├── Cargo.toml │ ├── src │ │ ├── artifacts.rs │ │ ├── artifacts │ │ │ ├── deserialized.rs │ │ │ └── representation.rs │ │ ├── command.rs │ │ ├── lib.rs │ │ ├── metadata.rs │ │ └── version.rs │ └── tests │ │ └── data │ │ ├── basic_package │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ │ └── empty_lib │ │ ├── Scarb.toml │ │ └── src │ │ └── lib.cairo ├── shared │ ├── Cargo.toml │ └── src │ │ ├── auto_completions.rs │ │ ├── command.rs │ │ ├── consts.rs │ │ ├── lib.rs │ │ ├── rpc.rs │ │ ├── spinner.rs │ │ ├── test_utils │ │ ├── mod.rs │ │ ├── node_url.rs │ │ └── output_assert.rs │ │ ├── utils.rs │ │ └── vm.rs ├── sncast │ ├── .cargo │ │ └── config.toml │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── helpers │ │ │ ├── account.rs │ │ │ ├── block_explorer.rs │ │ │ ├── braavos.rs │ │ │ ├── config.rs │ │ │ ├── configuration.rs │ │ │ ├── constants.rs │ │ │ ├── fee.rs │ │ │ ├── interactive.rs │ │ │ ├── mod.rs │ │ │ ├── output_format.rs │ │ │ ├── rpc.rs │ │ │ └── scarb_utils.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── response │ │ │ ├── account │ │ │ │ ├── create.rs │ │ │ │ ├── delete.rs │ │ │ │ ├── deploy.rs │ │ │ │ ├── import.rs │ │ │ │ └── mod.rs │ │ │ ├── call.rs │ │ │ ├── cast_message.rs │ │ │ ├── command.rs │ │ │ ├── declare.rs │ │ │ ├── deploy.rs │ │ │ ├── errors.rs │ │ │ ├── explorer_link.rs │ │ │ ├── invoke.rs │ │ │ ├── mod.rs │ │ │ ├── multicall │ │ │ │ ├── mod.rs │ │ │ │ ├── new.rs │ │ │ │ └── run.rs │ │ │ ├── print.rs │ │ │ ├── script │ │ │ │ ├── init.rs │ │ │ │ ├── mod.rs │ │ │ │ └── run.rs │ │ │ ├── show_config.rs │ │ │ ├── transformed_call.rs │ │ │ ├── tx_status.rs │ │ │ └── verify.rs │ │ ├── starknet_commands │ │ │ ├── account │ │ │ │ ├── create.rs │ │ │ │ ├── delete.rs │ │ │ │ ├── deploy.rs │ │ │ │ ├── import.rs │ │ │ │ ├── list.rs │ │ │ │ └── mod.rs │ │ │ ├── call.rs │ │ │ ├── declare.rs │ │ │ ├── deploy.rs │ │ │ ├── invoke.rs │ │ │ ├── mod.rs │ │ │ ├── multicall │ │ │ │ ├── mod.rs │ │ │ │ ├── new.rs │ │ │ │ └── run.rs │ │ │ ├── script │ │ │ │ ├── init.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── run.rs │ │ │ │ └── run │ │ │ │ │ └── script_runtime.rs │ │ │ ├── show_config.rs │ │ │ ├── tx_status.rs │ │ │ └── verify │ │ │ │ ├── explorer.rs │ │ │ │ ├── mod.rs │ │ │ │ └── walnut.rs │ │ └── state │ │ │ ├── hashing.rs │ │ │ ├── mod.rs │ │ │ └── state_file.rs │ └── tests │ │ ├── code_quality.rs │ │ ├── data │ │ ├── accounts │ │ │ ├── accounts.json │ │ │ ├── faulty_accounts.json │ │ │ ├── faulty_accounts_invalid_felt.json │ │ │ └── invalid_format.json │ │ ├── contracts │ │ │ ├── build_fails │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── constructor_with_params │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── map │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── multiple_packages │ │ │ │ ├── Scarb.toml │ │ │ │ ├── crates │ │ │ │ │ ├── package1 │ │ │ │ │ │ ├── Scarb.toml │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── lib.cairo │ │ │ │ │ └── package2 │ │ │ │ │ │ ├── Scarb.toml │ │ │ │ │ │ └── src │ │ │ │ │ │ └── lib.cairo │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── no_casm │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ ├── no_sierra │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ └── virtual_workspace │ │ │ │ ├── Scarb.toml │ │ │ │ └── crates │ │ │ │ ├── cast_addition │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── cast_fibonacci │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ └── lib.cairo │ │ ├── files │ │ │ ├── correct_snfoundry.toml │ │ │ ├── pre_0.34.0_state_with_tx.json │ │ │ ├── state_corrupt_missing_field.json │ │ │ ├── state_no_txs.json │ │ │ ├── state_with_tx.json │ │ │ ├── state_with_txs.json │ │ │ └── state_wrong_version.json │ │ ├── keystore │ │ │ ├── my_account.json │ │ │ ├── my_account_argent_undeployed_happy_case.json │ │ │ ├── my_account_braavos_invalid_multisig.json │ │ │ ├── my_account_braavos_multiple_signers.json │ │ │ ├── my_account_braavos_undeployed_happy_case.json │ │ │ ├── my_account_invalid.json │ │ │ ├── my_account_oz_undeployed_happy_case.json │ │ │ ├── my_account_undeployed.json │ │ │ ├── my_account_undeployed_happy_case_other_args.json │ │ │ ├── my_key.json │ │ │ ├── my_key_invalid.json │ │ │ ├── predeployed_account.json │ │ │ └── predeployed_key.json │ │ ├── multicall_configs │ │ │ ├── deploy_invalid.toml │ │ │ ├── deploy_invoke.toml │ │ │ ├── deploy_invoke_calldata_ids.toml │ │ │ ├── deploy_invoke_numeric_inputs.toml │ │ │ ├── deploy_invoke_numeric_overflow.toml │ │ │ ├── deploy_succ_invoke_fail.toml │ │ │ └── invoke_invalid.toml │ │ └── scripts │ │ │ ├── call │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── invalid_address.cairo │ │ │ │ ├── invalid_calldata.cairo │ │ │ │ ├── invalid_entry_point.cairo │ │ │ │ └── lib.cairo │ │ │ ├── declare │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── fee_settings.cairo │ │ │ │ ├── insufficient_account_balance.cairo │ │ │ │ ├── lib.cairo │ │ │ │ ├── no_contract.cairo │ │ │ │ ├── same_contract_twice.cairo │ │ │ │ ├── time_out.cairo │ │ │ │ ├── with_invalid_max_fee.cairo │ │ │ │ └── with_invalid_nonce.cairo │ │ │ ├── deploy │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── fee_settings.cairo │ │ │ │ ├── invalid_calldata.cairo │ │ │ │ ├── invalid_class_hash.cairo │ │ │ │ ├── invalid_nonce.cairo │ │ │ │ ├── lib.cairo │ │ │ │ ├── same_class_hash_and_salt.cairo │ │ │ │ └── with_calldata.cairo │ │ │ ├── invoke │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── contract_does_not_exist.cairo │ │ │ │ ├── lib.cairo │ │ │ │ ├── max_fee_too_low.cairo │ │ │ │ ├── wrong_calldata.cairo │ │ │ │ └── wrong_function_name.cairo │ │ │ ├── map_script │ │ │ ├── contracts │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ └── scripts │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ ├── display_debug_traits_for_subcommand_responses.cairo │ │ │ │ ├── lib.cairo │ │ │ │ └── map_script.cairo │ │ │ ├── misc │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── call_fail.cairo │ │ │ │ ├── call_happy.cairo │ │ │ │ ├── lib.cairo │ │ │ │ └── using_starknet_syscall.cairo │ │ │ ├── missing_field │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ │ ├── lib.cairo │ │ │ │ └── missing_field.cairo │ │ │ ├── old_sncast_std │ │ │ └── scripts │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ ├── lib.cairo │ │ │ │ └── map_script.cairo │ │ │ ├── packages │ │ │ ├── Scarb.toml │ │ │ └── crates │ │ │ │ └── scripts │ │ │ │ ├── script1 │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── script2 │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ └── lib.cairo │ │ │ ├── state_file │ │ │ ├── Scarb.toml │ │ │ ├── rerun_failed_tx_alpha-sepolia_state.json │ │ │ └── src │ │ │ │ ├── all_tx_fail.cairo │ │ │ │ ├── lib.cairo │ │ │ │ └── rerun_failed_tx.cairo │ │ │ ├── state_script │ │ │ ├── contracts │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ │ └── lib.cairo │ │ │ └── scripts │ │ │ │ ├── Scarb.toml │ │ │ │ └── src │ │ │ │ ├── lib.cairo │ │ │ │ └── state_script.cairo │ │ │ └── tx_status │ │ │ ├── Scarb.toml │ │ │ └── src │ │ │ ├── incorrect_transaction_hash.cairo │ │ │ ├── lib.cairo │ │ │ ├── status_reverted.cairo │ │ │ └── status_succeeded.cairo │ │ ├── docs_snippets │ │ ├── mod.rs │ │ └── validation.rs │ │ ├── e2e │ │ ├── account │ │ │ ├── create.rs │ │ │ ├── delete.rs │ │ │ ├── deploy.rs │ │ │ ├── helpers.rs │ │ │ ├── import.rs │ │ │ ├── list.rs │ │ │ └── mod.rs │ │ ├── call.rs │ │ ├── completions.rs │ │ ├── declare.rs │ │ ├── deploy.rs │ │ ├── fee.rs │ │ ├── invoke.rs │ │ ├── main_tests.rs │ │ ├── mod.rs │ │ ├── multicall │ │ │ ├── mod.rs │ │ │ ├── new.rs │ │ │ └── run.rs │ │ ├── script │ │ │ ├── call.rs │ │ │ ├── declare.rs │ │ │ ├── deploy.rs │ │ │ ├── general.rs │ │ │ ├── init.rs │ │ │ ├── invoke.rs │ │ │ ├── mod.rs │ │ │ └── tx_status.rs │ │ ├── show_config.rs │ │ ├── tx_status.rs │ │ └── verify │ │ │ ├── mod.rs │ │ │ └── walnut.rs │ │ ├── helpers │ │ ├── constants.rs │ │ ├── devnet.rs │ │ ├── env.rs │ │ ├── fee.rs │ │ ├── fixtures.rs │ │ ├── mod.rs │ │ ├── runner.rs │ │ └── shell.rs │ │ ├── integration │ │ ├── fee.rs │ │ ├── lib_tests.rs │ │ ├── mod.rs │ │ └── wait_for_tx.rs │ │ ├── main.rs │ │ └── shell │ │ ├── call.ps1 │ │ ├── call.sh │ │ ├── call_unsigned.sh │ │ ├── deploy.ps1 │ │ ├── deploy.sh │ │ ├── invoke.ps1 │ │ └── invoke.sh ├── snforge-scarb-plugin │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Scarb.toml │ ├── src │ │ ├── args.rs │ │ ├── args │ │ │ ├── named.rs │ │ │ └── unnamed.rs │ │ ├── asserts.rs │ │ ├── attributes.rs │ │ ├── attributes │ │ │ ├── available_gas.rs │ │ │ ├── disable_predeployed_contracts.rs │ │ │ ├── fork.rs │ │ │ ├── fork │ │ │ │ └── block_id.rs │ │ │ ├── fuzzer.rs │ │ │ ├── fuzzer │ │ │ │ └── wrapper.rs │ │ │ ├── ignore.rs │ │ │ ├── internal_config_statement.rs │ │ │ ├── should_panic.rs │ │ │ ├── should_panic │ │ │ │ └── expected.rs │ │ │ └── test.rs │ │ ├── cairo_expression.rs │ │ ├── common.rs │ │ ├── config_statement.rs │ │ ├── lib.rs │ │ ├── parse.rs │ │ ├── types.rs │ │ └── utils.rs │ └── tests │ │ └── integration │ │ ├── main.rs │ │ ├── multiple_attributes.rs │ │ ├── single_attributes.rs │ │ ├── single_attributes │ │ ├── available_gas.rs │ │ ├── disable_predeployed_contracts.rs │ │ ├── fork.rs │ │ ├── fuzzer.rs │ │ ├── ignore.rs │ │ ├── internal_config_statement.rs │ │ ├── should_panic.rs │ │ └── test.rs │ │ └── utils.rs ├── testing │ └── packages_validation │ │ ├── Cargo.toml │ │ └── src │ │ └── lib.rs └── universal-sierra-compiler-api │ ├── Cargo.toml │ └── src │ ├── command.rs │ └── lib.rs ├── design_documents ├── accessing_emitted_events.md ├── cairo_deployment_scripts.md ├── contract_verification.md ├── loading_data_from_files.md ├── parametrizing_tests_with_fixed_values.md ├── prepare_cheatcode.md ├── sncast_interface_overhaul.md ├── stark_curve_signatures.md ├── state_forking │ ├── multi-forking.md │ ├── new_CheatnetState_interface.png │ ├── read_state_flow_diag.jpg │ ├── state_forking.md │ └── state_forking_arch_diag.jpg ├── store_load_cheatcodes.md ├── template.md ├── test_design.md └── transactional_testing │ ├── transactional_testing.md │ └── txn_based_testing_arch.png ├── docs ├── .gitignore ├── README.md ├── book.toml ├── codeSnippets.js ├── count.js ├── example_workflows │ └── basic_workflow.yml ├── listings │ ├── basic_example │ │ ├── Scarb.toml │ │ └── src │ │ │ ├── basic_example.cairo │ │ │ └── lib.cairo │ ├── call │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── conditional_compilation │ │ ├── Scarb.toml │ │ ├── src │ │ │ ├── contract.cairo │ │ │ ├── function.cairo │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── test.cairo │ ├── declare │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── deploy │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── detailed_resources_example │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── test_contract.cairo │ ├── direct_storage_access │ │ ├── Scarb.toml │ │ ├── src │ │ │ ├── complex_structures.cairo │ │ │ ├── felts_only.cairo │ │ │ ├── lib.cairo │ │ │ └── using_enums.cairo │ │ └── tests │ │ │ ├── complex_structures.cairo │ │ │ ├── felts_only.cairo │ │ │ ├── felts_only │ │ │ ├── field.cairo │ │ │ └── map_entry.cairo │ │ │ ├── lib.cairo │ │ │ ├── storage_address.cairo │ │ │ ├── using_enums.cairo │ │ │ └── using_storage_address_from_base.cairo │ ├── error_handling │ │ ├── Scarb.toml │ │ └── src │ │ │ ├── error_handling.cairo │ │ │ └── lib.cairo │ ├── failing_example │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── lib.cairo │ ├── first_test │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── fork_testing │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ ├── explicit.cairo │ │ │ ├── explicit │ │ │ ├── block_hash.cairo │ │ │ ├── block_number.cairo │ │ │ └── block_tag.cairo │ │ │ ├── lib.cairo │ │ │ ├── name.cairo │ │ │ └── overridden_name.cairo │ ├── full_example │ │ ├── Scarb.toml │ │ └── src │ │ │ ├── full_example.cairo │ │ │ └── lib.cairo │ ├── fuzz_testing │ │ ├── Scarb.toml │ │ └── src │ │ │ ├── basic_example.cairo │ │ │ ├── lib.cairo │ │ │ └── with_parameters.cairo │ ├── get_nonce │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── hello_sncast │ │ ├── Scarb.toml │ │ ├── accounts.json │ │ ├── snfoundry.toml │ │ └── src │ │ │ ├── constructor_contract.cairo │ │ │ ├── data_transformer_contract.cairo │ │ │ ├── hello_sncast.cairo │ │ │ └── lib.cairo │ ├── hello_snforge │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── test_contract.cairo │ ├── hello_starknet │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── test_contract.cairo │ ├── hello_workspaces │ │ ├── Scarb.toml │ │ ├── crates │ │ │ ├── addition │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ │ ├── nested.cairo │ │ │ │ │ └── nested │ │ │ │ │ └── test_nested.cairo │ │ │ └── fibonacci │ │ │ │ ├── Scarb.toml │ │ │ │ ├── src │ │ │ │ └── lib.cairo │ │ │ │ └── tests │ │ │ │ ├── abc.cairo │ │ │ │ ├── abc │ │ │ │ └── efg.cairo │ │ │ │ ├── lib.cairo │ │ │ │ └── not_collected.cairo │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── test_failing.cairo │ ├── ignoring_example │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── invoke │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── map3 │ │ ├── Scarb.toml │ │ ├── snfoundry.toml │ │ └── src │ │ │ └── lib.cairo │ ├── panicking_test │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── should_panic_example │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── testing_contract_internals │ │ ├── Scarb.toml │ │ ├── src │ │ │ ├── basic_example.cairo │ │ │ ├── lib.cairo │ │ │ ├── spying_for_events.cairo │ │ │ └── using_library_calls.cairo │ │ └── tests │ │ │ ├── lib.cairo │ │ │ ├── mocking_the_context_info.cairo │ │ │ ├── spying_for_events.cairo │ │ │ ├── spying_for_events │ │ │ ├── syscall_tests.cairo │ │ │ └── tests.cairo │ │ │ └── using_library_calls.cairo │ ├── testing_events │ │ ├── Scarb.toml │ │ ├── src │ │ │ ├── contract.cairo │ │ │ ├── lib.cairo │ │ │ ├── syscall.cairo │ │ │ └── syscall_dummy.cairo │ │ └── tests │ │ │ ├── assert_emitted.cairo │ │ │ ├── assert_manually.cairo │ │ │ ├── filter.cairo │ │ │ └── syscall.cairo │ ├── testing_messages_to_l1 │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ ├── detailed.cairo │ │ │ ├── lib.cairo │ │ │ └── simple.cairo │ ├── testing_smart_contracts_handling_errors │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ ├── handle_panic.cairo │ │ │ └── panic.cairo │ ├── testing_smart_contracts_safe_dispatcher │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── safe_dispatcher.cairo │ ├── testing_smart_contracts_writing_tests │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── simple_contract.cairo │ ├── tx_status │ │ ├── Scarb.toml │ │ └── src │ │ │ └── lib.cairo │ ├── using_cheatcodes │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── lib.cairo │ ├── using_cheatcodes_cancelling_cheat │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── lib.cairo │ ├── using_cheatcodes_cheat_address │ │ ├── Scarb.toml │ │ ├── src │ │ │ └── lib.cairo │ │ └── tests │ │ │ └── lib.cairo │ └── using_cheatcodes_others │ │ ├── Scarb.toml │ │ ├── src │ │ └── lib.cairo │ │ └── tests │ │ ├── caller_address.cairo │ │ ├── caller_address │ │ ├── proper_use_global.cairo │ │ └── span.cairo │ │ ├── cheat_constructor.cairo │ │ ├── lib.cairo │ │ ├── set_balance_custom_token.cairo │ │ └── set_balance_strk.cairo ├── src │ ├── README.md │ ├── SUMMARY.md │ ├── appendix │ │ ├── cheatcodes.md │ │ ├── cheatcodes │ │ │ ├── account_contract_address.md │ │ │ ├── account_deployment_data.md │ │ │ ├── block_hash.md │ │ │ ├── block_number.md │ │ │ ├── block_timestamp.md │ │ │ ├── caller_address.md │ │ │ ├── chain_id.md │ │ │ ├── cheat_span.md │ │ │ ├── fee_data_availability_mode.md │ │ │ ├── generate_arg.md │ │ │ ├── generate_random_felt.md │ │ │ ├── get_class_hash.md │ │ │ ├── global.md │ │ │ ├── l1_handler.md │ │ │ ├── load.md │ │ │ ├── max_fee.md │ │ │ ├── mock_call.md │ │ │ ├── nonce.md │ │ │ ├── nonce_data_availability_mode.md │ │ │ ├── paymaster_data.md │ │ │ ├── replace_bytecode.md │ │ │ ├── resource_bounds.md │ │ │ ├── sequencer_address.md │ │ │ ├── set_balance.md │ │ │ ├── signature.md │ │ │ ├── spy_events.md │ │ │ ├── spy_messages_to_l1.md │ │ │ ├── store.md │ │ │ ├── tip.md │ │ │ ├── token.md │ │ │ ├── transaction_hash.md │ │ │ └── transaction_version.md │ │ ├── scarb-toml.md │ │ ├── sncast-library.md │ │ ├── sncast-library │ │ │ ├── call.md │ │ │ ├── declare.md │ │ │ ├── deploy.md │ │ │ ├── errors.md │ │ │ ├── fee_settings_trait.md │ │ │ ├── get_nonce.md │ │ │ ├── invoke.md │ │ │ └── tx_status.md │ │ ├── sncast.md │ │ ├── sncast │ │ │ ├── account │ │ │ │ ├── account.md │ │ │ │ ├── create.md │ │ │ │ ├── delete.md │ │ │ │ ├── deploy.md │ │ │ │ ├── import.md │ │ │ │ └── list.md │ │ │ ├── call.md │ │ │ ├── common.md │ │ │ ├── completion.md │ │ │ ├── declare.md │ │ │ ├── deploy.md │ │ │ ├── invoke.md │ │ │ ├── multicall │ │ │ │ ├── multicall.md │ │ │ │ ├── new.md │ │ │ │ └── run.md │ │ │ ├── script │ │ │ │ ├── init.md │ │ │ │ ├── run.md │ │ │ │ └── script.md │ │ │ ├── show_config.md │ │ │ ├── tx-status.md │ │ │ └── verify.md │ │ ├── snforge-library.md │ │ ├── snforge-library │ │ │ ├── byte_array.md │ │ │ ├── contract_class.md │ │ │ ├── declare.md │ │ │ ├── env.md │ │ │ ├── fs.md │ │ │ ├── fuzzable.md │ │ │ ├── get_call_trace.md │ │ │ └── signature.md │ │ ├── snforge.md │ │ ├── snforge │ │ │ ├── check-requirements.md │ │ │ ├── clean-cache.md │ │ │ ├── clean.md │ │ │ ├── completion.md │ │ │ ├── init.md │ │ │ ├── new.md │ │ │ └── test.md │ │ ├── snfoundry-toml.md │ │ └── starknet-foundry-github-action.md │ ├── development │ │ ├── environment-setup.md │ │ └── shell-snippets.md │ ├── getting-started │ │ ├── first-steps.md │ │ ├── installation.md │ │ └── scarb.md │ ├── images │ │ ├── foundry.png │ │ └── logo.png │ ├── projects │ │ └── configuration.md │ ├── snforge-advanced-features │ │ ├── conditional-compilation.md │ │ ├── debugging.md │ │ ├── fork-testing.md │ │ ├── fuzz-testing.md │ │ ├── profiling.md │ │ └── storage-cheatcodes.md │ ├── starknet │ │ ├── 101.md │ │ ├── account-import.md │ │ ├── account.md │ │ ├── call.md │ │ ├── calldata-transformation.md │ │ ├── declare.md │ │ ├── deploy.md │ │ ├── images │ │ │ └── starknet-faucet-sepolia.png │ │ ├── img │ │ │ ├── argent_export_1.png │ │ │ ├── argent_export_2.png │ │ │ ├── argent_export_3.png │ │ │ ├── argent_export_4.png │ │ │ ├── argent_export_5.png │ │ │ ├── braavos_export_1.png │ │ │ ├── braavos_export_2.png │ │ │ ├── braavos_export_3.png │ │ │ ├── braavos_export_4.png │ │ │ └── braavos_export_5.png │ │ ├── invoke.md │ │ ├── multicall.md │ │ ├── script.md │ │ ├── show_config.md │ │ ├── sncast-overview.md │ │ ├── tx-status.md │ │ └── verify.md │ └── testing │ │ ├── contract-collection │ │ ├── new-mechanism.md │ │ └── old-mechanism.md │ │ ├── contracts-collection.md │ │ ├── contracts.md │ │ ├── coverage.md │ │ ├── gas-and-resource-estimation.md │ │ ├── running-tests.md │ │ ├── test-attributes.md │ │ ├── test-collection.md │ │ ├── testing-contract-internals.md │ │ ├── testing-events.md │ │ ├── testing-messages-to-l1.md │ │ ├── testing-workspaces.md │ │ ├── testing.md │ │ └── using-cheatcodes.md └── theme │ ├── favicon.png │ ├── favicon.svg │ └── head.hbs ├── rust-toolchain.toml ├── scripts ├── build_docs.sh ├── compareVersions.js ├── get_scarb_versions.sh ├── handle_version.sh ├── install.sh ├── install_devnet.ps1 ├── install_devnet.sh ├── package-lock.json ├── package.json ├── package.sh ├── release.sh ├── scarbfmt.sh ├── smoke_test.sh ├── snfoundryup └── verify_cairo_listings.sh ├── sncast_std ├── README.md ├── Scarb.lock ├── Scarb.toml └── src │ └── lib.cairo ├── snforge_std ├── README.md ├── Scarb.lock ├── Scarb.toml └── src │ ├── byte_array.cairo │ ├── cheatcode.cairo │ ├── cheatcodes.cairo │ ├── cheatcodes │ ├── block_hash.cairo │ ├── contract_class.cairo │ ├── erc20.cairo │ ├── events.cairo │ ├── execution_info.cairo │ ├── execution_info │ │ ├── account_contract_address.cairo │ │ ├── account_deployment_data.cairo │ │ ├── block_number.cairo │ │ ├── block_timestamp.cairo │ │ ├── caller_address.cairo │ │ ├── chain_id.cairo │ │ ├── fee_data_availability_mode.cairo │ │ ├── max_fee.cairo │ │ ├── nonce.cairo │ │ ├── nonce_data_availability_mode.cairo │ │ ├── paymaster_data.cairo │ │ ├── resource_bounds.cairo │ │ ├── sequencer_address.cairo │ │ ├── signature.cairo │ │ ├── tip.cairo │ │ ├── transaction_hash.cairo │ │ └── version.cairo │ ├── generate_arg.cairo │ ├── generate_random_felt.cairo │ ├── l1_handler.cairo │ ├── message_to_l1.cairo │ └── storage.cairo │ ├── config_types.cairo │ ├── env.cairo │ ├── env │ └── env_vars.cairo │ ├── fs.cairo │ ├── fs │ └── file_operations.cairo │ ├── fuzzable.cairo │ ├── lib.cairo │ ├── signature.cairo │ ├── signature │ ├── secp256k1_curve.cairo │ ├── secp256r1_curve.cairo │ └── stark_curve.cairo │ └── trace.cairo └── snforge_templates ├── balance_contract ├── src │ └── lib.cairo └── tests │ └── test_contract.cairo ├── cairo_program └── src │ └── lib.cairo └── erc20_contract ├── src ├── lib.cairo ├── mock_erc20.cairo └── token_sender.cairo └── tests ├── test_erc20.cairo └── test_token_sender.cairo /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | lint = "clippy --all-targets --all-features -- --no-deps -W clippy::pedantic -W clippy::undocumented_unsafe_blocks -A clippy::module_name_repetitions -A clippy::missing_errors_doc -A clippy::missing_panics_doc" 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.* text eol=lf 2 | *.png -text 3 | *.jpg -text 4 | *.gif -text 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @foundry-rs/starknet-foundry 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Telegram Support Channel 4 | url: https://t.me/starknet_foundry_support 5 | about: This issue tracker is only for bugs and feature requests. Support is available through Telegram channel. 6 | -------------------------------------------------------------------------------- /.github/images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/.github/images/demo.gif -------------------------------------------------------------------------------- /.github/images/plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/.github/images/plot.png -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Closes # 4 | 5 | ## Introduced changes 6 | 7 | 8 | 9 | - 10 | 11 | ## Checklist 12 | 13 | 14 | 15 | - [ ] Linked relevant issue 16 | - [ ] Updated relevant documentation 17 | - [ ] Added relevant tests 18 | - [ ] Performed self-review of the code 19 | - [ ] Added changes to `CHANGELOG.md` 20 | -------------------------------------------------------------------------------- /.github/workflows/label-issues.yml: -------------------------------------------------------------------------------- 1 | name: Label issues 2 | on: 3 | issues: 4 | types: 5 | - opened 6 | jobs: 7 | label_issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | steps: 12 | - uses: actions/github-script@v7 13 | with: 14 | script: | 15 | github.rest.issues.addLabels({ 16 | issue_number: context.issue.number, 17 | owner: context.repo.owner, 18 | repo: context.repo.repo, 19 | labels: ["new"] 20 | }) 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | pyproject.toml 3 | .DS_Store 4 | */.tool-versions 5 | target 6 | .vscode/ 7 | .env 8 | Scarb.lock 9 | !snforge_std/Scarb.lock 10 | !sncast_std/Scarb.lock 11 | */node_modules 12 | .spr.yml 13 | .snfoundry_cache/ 14 | .snfoundry_versioned_programs/ 15 | snfoundry_trace/ 16 | coverage/ 17 | **/.forge_e2e_cache/ 18 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | scarb 2.9.4 2 | -------------------------------------------------------------------------------- /_typos.toml: -------------------------------------------------------------------------------- 1 | [default.extend-words] 2 | ba = "ba" 3 | 4 | [files] 5 | extend-exclude = ["docs/theme/head.hbs"] 6 | -------------------------------------------------------------------------------- /crates/cheatnet/src/forking/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cache; 2 | pub mod state; 3 | -------------------------------------------------------------------------------- /crates/cheatnet/src/lib.rs: -------------------------------------------------------------------------------- 1 | use state::CheatnetState; 2 | 3 | pub mod constants; 4 | pub mod forking; 5 | pub mod predeployment; 6 | pub mod runtime_extensions; 7 | pub mod state; 8 | pub mod sync_client; 9 | -------------------------------------------------------------------------------- /crates/cheatnet/src/predeployment/erc20/constructor_data.rs: -------------------------------------------------------------------------------- 1 | use starknet_api::core::ContractAddress; 2 | 3 | pub struct ERC20ConstructorData { 4 | pub name: String, 5 | pub symbol: String, 6 | pub decimals: u8, 7 | pub total_supply: (u128, u128), // (low, high) 8 | pub permitted_minter: ContractAddress, 9 | pub upgrade_delay: u64, 10 | } 11 | -------------------------------------------------------------------------------- /crates/cheatnet/src/predeployment/erc20/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod constructor_data; 2 | pub mod eth; 3 | pub mod predeployed_contract; 4 | pub mod strk; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/src/predeployment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod erc20; 2 | pub mod predeployed_contract; 3 | -------------------------------------------------------------------------------- /crates/cheatnet/src/runtime_extensions/call_to_blockifier_runtime_extension/execution/deprecated/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cairo0_execution; 2 | -------------------------------------------------------------------------------- /crates/cheatnet/src/runtime_extensions/call_to_blockifier_runtime_extension/execution/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cairo1_execution; 2 | pub mod calls; 3 | pub mod cheated_syscalls; 4 | pub mod deprecated; 5 | pub mod entry_point; 6 | pub mod execution_info; 7 | pub mod syscall_hooks; 8 | -------------------------------------------------------------------------------- /crates/cheatnet/src/runtime_extensions/forge_runtime_extension/cheatcodes/generate_random_felt.rs: -------------------------------------------------------------------------------- 1 | use num_bigint::{BigUint, RandBigInt}; 2 | use starknet_types_core::felt::Felt; 3 | 4 | #[must_use] 5 | pub fn generate_random_felt() -> Felt { 6 | let mut rng = rand::thread_rng(); 7 | 8 | let random_number: BigUint = rng.gen_biguint(251); 9 | Felt::from(random_number) 10 | } 11 | -------------------------------------------------------------------------------- /crates/cheatnet/src/runtime_extensions/forge_runtime_extension/cheatcodes/replace_bytecode.rs: -------------------------------------------------------------------------------- 1 | use crate::CheatnetState; 2 | use conversions::serde::serialize::CairoSerialize; 3 | use starknet_api::core::{ClassHash, ContractAddress}; 4 | 5 | impl CheatnetState { 6 | pub fn replace_class_for_contract( 7 | &mut self, 8 | contract_address: ContractAddress, 9 | class_hash: ClassHash, 10 | ) { 11 | self.replaced_bytecode_contracts 12 | .insert(contract_address, class_hash); 13 | } 14 | } 15 | 16 | #[derive(CairoSerialize)] 17 | pub enum ReplaceBytecodeError { 18 | ContractNotDeployed, 19 | UndeclaredClassHash, 20 | } 21 | -------------------------------------------------------------------------------- /crates/cheatnet/src/runtime_extensions/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod call_to_blockifier_runtime_extension; 2 | pub mod cheatable_starknet_runtime_extension; 3 | pub mod common; 4 | pub mod deprecated_cheatable_starknet_extension; 5 | pub mod forge_config_extension; 6 | pub mod forge_runtime_extension; 7 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/builtins/mod.rs: -------------------------------------------------------------------------------- 1 | mod panic_call; 2 | mod segment_arena; 3 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/cheatcodes/mod.rs: -------------------------------------------------------------------------------- 1 | mod test_environment; 2 | 3 | mod cheat_block_hash; 4 | mod cheat_block_number; 5 | mod cheat_block_timestamp; 6 | mod cheat_caller_address; 7 | mod cheat_execution_info; 8 | mod cheat_sequencer_address; 9 | mod declare; 10 | mod deploy; 11 | mod generate_random_felt; 12 | mod get_class_hash; 13 | mod load; 14 | mod mock_call; 15 | mod multiple_writes_same_storage; 16 | mod precalculate_address; 17 | mod replace_bytecode; 18 | mod spy_events; 19 | mod store; 20 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cheatnet_testing_contracts" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest 7 | [[target.starknet-contract]] 8 | 9 | [dependencies] 10 | starknet = "2.4.0" 11 | 12 | [tool.snforge] 13 | # exit_first = true 14 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_block_hash.cairo: -------------------------------------------------------------------------------- 1 | mod checker; 2 | mod constructor_checker; 3 | mod checker_proxy; 4 | mod checker_library_call; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_block_number.cairo: -------------------------------------------------------------------------------- 1 | mod checker; 2 | mod constructor_checker; 3 | mod checker_library_call; 4 | mod checker_proxy; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_block_timestamp.cairo: -------------------------------------------------------------------------------- 1 | mod checker; 2 | mod constructor_checker; 3 | mod checker_library_call; 4 | mod checker_proxy; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_caller_address.cairo: -------------------------------------------------------------------------------- 1 | mod checker; 2 | mod constructor_checker; 3 | mod checker_library_call; 4 | mod checker_proxy; 5 | mod checker_cairo0; 6 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_sequencer_address.cairo: -------------------------------------------------------------------------------- 1 | mod checker; 2 | mod constructor_checker; 3 | mod checker_library_call; 4 | mod checker_proxy; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/cheat_tx_info.cairo: -------------------------------------------------------------------------------- 1 | mod tx_info_checker; 2 | mod constructor_tx_hash_checker; 3 | mod tx_info_checker_library_call; 4 | mod tx_hash_checker_proxy; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/common.cairo: -------------------------------------------------------------------------------- 1 | mod hello_starknet; 2 | mod constructor_simple; 3 | mod constructor_simple2; 4 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/events.cairo: -------------------------------------------------------------------------------- 1 | mod spy_events_checker; 2 | mod spy_events_order_checker; 3 | mod spy_events_lib_call; 4 | mod constructor_spy_events_checker; 5 | mod spy_events_checker_proxy; 6 | mod spy_events_cairo0; 7 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/events/constructor_spy_events_checker.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod ConstructorSpyEventsChecker { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[event] 7 | #[derive(Drop, starknet::Event)] 8 | enum Event { 9 | FirstEvent: FirstEvent, 10 | } 11 | 12 | #[derive(Drop, starknet::Event)] 13 | struct FirstEvent { 14 | some_data: felt252, 15 | } 16 | 17 | #[constructor] 18 | fn constructor(ref self: ContractState, data: felt252) { 19 | self.emit(Event::FirstEvent(FirstEvent { some_data: data })); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/get_class_hash.cairo: -------------------------------------------------------------------------------- 1 | mod get_class_hash_checker; 2 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod common; 2 | mod events; 3 | mod get_class_hash; 4 | mod mock; 5 | mod cheat_caller_address; 6 | mod replace_bytecode; 7 | mod cheat_block_number; 8 | mod cheat_tx_info; 9 | mod cheat_sequencer_address; 10 | mod starknet; 11 | mod cheat_block_timestamp; 12 | mod segment_arena_user; 13 | mod panic_call; 14 | mod store_load; 15 | mod bytearray_string_panic_call; 16 | mod cheat_block_hash; 17 | mod revert; 18 | mod tracked_resources; 19 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/mock.cairo: -------------------------------------------------------------------------------- 1 | mod mock_checker; 2 | mod constructor_mock_checker; 3 | mod mock_checker_library_call; 4 | mod mock_checker_proxy; 5 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/panic_call.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod PanicCall { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[external(v0)] 7 | fn panic_call(ref self: ContractState) { 8 | panic( 9 | array![ 10 | 'shortstring', 11 | 0, 12 | 0x800000000000011000000000000000000000000000000000000000000000000, 13 | 'shortstring2', 14 | ], 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/replace_bytecode.cairo: -------------------------------------------------------------------------------- 1 | mod replace_bytecode_a; 2 | mod replace_bytecode_b; 3 | mod replace_fork; 4 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/replace_bytecode/replace_fork.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | trait IReplaceInFork { 3 | fn get_owner(self: @TContractState) -> felt252; 4 | } 5 | 6 | #[starknet::contract] 7 | mod ReplaceInFork { 8 | #[storage] 9 | struct Storage {} 10 | 11 | #[abi(embed_v0)] 12 | impl IReplaceInFork of super::IReplaceInFork { 13 | fn get_owner(self: @ContractState) -> felt252 { 14 | 0 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/segment_arena_user.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod SegmentArenaUser { 3 | use core::dict::Felt252Dict; 4 | 5 | #[storage] 6 | struct Storage {} 7 | 8 | #[external(v0)] 9 | fn interface_function(ref self: ContractState) { 10 | let _felt_dict: Felt252Dict = Default::default(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/starknet.cairo: -------------------------------------------------------------------------------- 1 | mod timestamper; 2 | mod blocker; 3 | mod block_info_checker_proxy; 4 | mod block_info_checker_library_call; 5 | mod noncer; 6 | mod forking_checker; 7 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/store_load.cairo: -------------------------------------------------------------------------------- 1 | mod map_simple_value_simple_key; 2 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/contracts/src/store_load/map_simple_value_simple_key.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod MapSimpleValueSimpleKey { 3 | use starknet::{ 4 | storage::{StoragePointerWriteAccess, StorageMapReadAccess, StoragePathEntry, Map}, 5 | }; 6 | #[storage] 7 | struct Storage { 8 | values: Map, 9 | } 10 | 11 | #[external(v0)] 12 | fn insert(ref self: ContractState, key: felt252, value: felt252) { 13 | self.values.entry(key).write(value); 14 | } 15 | 16 | #[external(v0)] 17 | fn read(self: @ContractState, key: felt252) -> felt252 { 18 | self.values.read(key) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/cheatnet/tests/starknet/mod.rs: -------------------------------------------------------------------------------- 1 | // Testing whether Cheatnet's behavior is consistent with Starknet's 2 | mod block; 3 | mod cheat_fork; 4 | mod execution; 5 | mod forking; 6 | mod nonce; 7 | mod timestamp; 8 | -------------------------------------------------------------------------------- /crates/configuration/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "configuration" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [features] 7 | testing = [] 8 | 9 | [dependencies] 10 | anyhow.workspace = true 11 | serde_json.workspace = true 12 | serde.workspace = true 13 | camino.workspace = true 14 | toml.workspace = true 15 | tempfile.workspace = true 16 | scarb-metadata.workspace = true 17 | 18 | -------------------------------------------------------------------------------- /crates/conversions/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "conversions" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [features] 7 | testing = [] 8 | 9 | [dependencies] 10 | anyhow.workspace = true 11 | blockifier.workspace = true 12 | starknet_api.workspace = true 13 | starknet-types-core.workspace = true 14 | cairo-lang-utils.workspace = true 15 | cairo-vm.workspace = true 16 | starknet.workspace = true 17 | thiserror.workspace = true 18 | serde_json.workspace = true 19 | serde.workspace = true 20 | num-traits.workspace = true 21 | itertools.workspace = true 22 | cairo-serde-macros = { path = "cairo-serde-macros" } 23 | 24 | -------------------------------------------------------------------------------- /crates/conversions/cairo-serde-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cairo-serde-macros" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [lib] 7 | proc-macro = true 8 | 9 | [dependencies] 10 | syn = "2.0.100" 11 | quote = "1.0.40" 12 | proc-macro2 = "1.0.94" 13 | -------------------------------------------------------------------------------- /crates/conversions/cairo-serde-macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod cairo_deserialize; 2 | mod cairo_serialize; 3 | 4 | #[proc_macro_derive(CairoDeserialize)] 5 | pub fn derive_deserialize(item: proc_macro::TokenStream) -> proc_macro::TokenStream { 6 | cairo_deserialize::derive_deserialize(item) 7 | } 8 | 9 | #[proc_macro_derive(CairoSerialize)] 10 | pub fn derive_serialize(item: proc_macro::TokenStream) -> proc_macro::TokenStream { 11 | cairo_serialize::derive_serialize(item) 12 | } 13 | -------------------------------------------------------------------------------- /crates/conversions/src/class_hash.rs: -------------------------------------------------------------------------------- 1 | use crate::{FromConv, IntoConv, from_thru_felt}; 2 | use conversions::padded_felt::PaddedFelt; 3 | use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; 4 | use starknet_types_core::felt::Felt; 5 | 6 | impl FromConv for ClassHash { 7 | fn from_(value: Felt) -> ClassHash { 8 | ClassHash(value.into_()) 9 | } 10 | } 11 | 12 | from_thru_felt!(ContractAddress, ClassHash); 13 | from_thru_felt!(Nonce, ClassHash); 14 | from_thru_felt!(EntryPointSelector, ClassHash); 15 | from_thru_felt!(PaddedFelt, ClassHash); 16 | -------------------------------------------------------------------------------- /crates/conversions/src/entrypoint_selector.rs: -------------------------------------------------------------------------------- 1 | use crate::{FromConv, IntoConv, from_thru_felt}; 2 | use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; 3 | use starknet_types_core::felt::Felt; 4 | 5 | impl FromConv for EntryPointSelector { 6 | fn from_(value: Felt) -> EntryPointSelector { 7 | EntryPointSelector(value.into_()) 8 | } 9 | } 10 | 11 | from_thru_felt!(ContractAddress, EntryPointSelector); 12 | from_thru_felt!(Nonce, EntryPointSelector); 13 | from_thru_felt!(ClassHash, EntryPointSelector); 14 | -------------------------------------------------------------------------------- /crates/conversions/src/eth_address.rs: -------------------------------------------------------------------------------- 1 | use crate::FromConv; 2 | use starknet_api::core::EthAddress; 3 | use starknet_types_core::felt::Felt; 4 | 5 | impl FromConv for EthAddress { 6 | fn from_(value: Felt) -> EthAddress { 7 | EthAddress::try_from(value).expect("Conversion of felt to EthAddress failed") 8 | } 9 | } 10 | 11 | impl FromConv for Felt { 12 | fn from_(value: EthAddress) -> Felt { 13 | value.into() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /crates/conversions/src/non_zero_u128.rs: -------------------------------------------------------------------------------- 1 | use crate::TryFromConv; 2 | use starknet_types_core::felt::{Felt, NonZeroFelt}; 3 | use std::num::{NonZero, NonZeroU128}; 4 | 5 | impl TryFromConv for NonZeroU128 { 6 | type Error = String; 7 | fn try_from_(value: NonZeroFelt) -> Result { 8 | let value: u128 = Felt::from(value) 9 | .try_into() 10 | .map_err(|_| "felt was too large to fit in u128")?; 11 | Ok(NonZero::new(value) 12 | .unwrap_or_else(|| unreachable!("non zero felt is always greater than 0"))) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/conversions/src/non_zero_u64.rs: -------------------------------------------------------------------------------- 1 | use crate::TryFromConv; 2 | use starknet_types_core::felt::{Felt, NonZeroFelt}; 3 | use std::num::{NonZero, NonZeroU64}; 4 | 5 | impl TryFromConv for NonZeroU64 { 6 | type Error = String; 7 | fn try_from_(value: NonZeroFelt) -> Result { 8 | let value: u64 = Felt::from(value) 9 | .try_into() 10 | .map_err(|_| "felt was too large to fit in u64")?; 11 | Ok(NonZero::new(value) 12 | .unwrap_or_else(|| unreachable!("non zero felt is always greater than 0"))) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/conversions/src/nonce.rs: -------------------------------------------------------------------------------- 1 | use crate::{FromConv, IntoConv, from_thru_felt}; 2 | use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; 3 | use starknet_types_core::felt::Felt; 4 | 5 | impl FromConv for Nonce { 6 | fn from_(value: Felt) -> Nonce { 7 | Nonce(value.into_()) 8 | } 9 | } 10 | 11 | from_thru_felt!(ClassHash, Nonce); 12 | from_thru_felt!(ContractAddress, Nonce); 13 | from_thru_felt!(EntryPointSelector, Nonce); 14 | -------------------------------------------------------------------------------- /crates/conversions/src/serde.rs: -------------------------------------------------------------------------------- 1 | pub mod deserialize; 2 | pub mod serialize; 3 | -------------------------------------------------------------------------------- /crates/conversions/src/serde/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod deserialize; 2 | pub mod serialize; 3 | -------------------------------------------------------------------------------- /crates/conversions/tests/e2e/mod.rs: -------------------------------------------------------------------------------- 1 | mod class_hash; 2 | mod contract_address; 3 | mod entrypoint_selector; 4 | mod felt; 5 | mod field_elements; 6 | mod non_zero_felt; 7 | mod non_zero_u128; 8 | mod non_zero_u64; 9 | mod nonce; 10 | mod padded_felt; 11 | mod string; 12 | -------------------------------------------------------------------------------- /crates/conversions/tests/e2e/non_zero_felt.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests_non_zero_felt { 3 | use std::num::{NonZeroU64, NonZeroU128}; 4 | 5 | use conversions::FromConv; 6 | use starknet_types_core::felt::{Felt, NonZeroFelt}; 7 | 8 | #[test] 9 | fn test_happy_case() { 10 | let non_zero_felt = NonZeroFelt::try_from(Felt::from(1_u8)).unwrap(); 11 | 12 | assert_eq!( 13 | non_zero_felt, 14 | NonZeroFelt::from_(NonZeroU64::new(1).unwrap()) 15 | ); 16 | assert_eq!( 17 | non_zero_felt, 18 | NonZeroFelt::from_(NonZeroU128::new(1).unwrap()) 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/conversions/tests/main.rs: -------------------------------------------------------------------------------- 1 | mod e2e; 2 | -------------------------------------------------------------------------------- /crates/data-transformer/src/cairo_types/mod.rs: -------------------------------------------------------------------------------- 1 | mod bytes31; 2 | mod helpers; 3 | mod u256; 4 | mod u384; 5 | mod u512; 6 | mod u96; 7 | 8 | pub use bytes31::{CairoBytes31, ParseBytes31Error}; 9 | pub use u96::{CairoU96, ParseCairoU96Error}; 10 | pub use u256::{CairoU256, ParseCairoU256Error}; 11 | pub use u384::{CairoU384, ParseCairoU384Error}; 12 | pub use u512::{CairoU512, ParseCairoU512Error}; 13 | -------------------------------------------------------------------------------- /crates/data-transformer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod cairo_types; 2 | mod reverse_transformer; 3 | mod shared; 4 | mod transformer; 5 | 6 | pub use reverse_transformer::{ 7 | ReverseTransformError, reverse_transform_input, reverse_transform_output, 8 | }; 9 | pub use transformer::transform; 10 | -------------------------------------------------------------------------------- /crates/data-transformer/src/shared/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod extraction; 2 | pub mod parsing; 3 | pub mod path; 4 | -------------------------------------------------------------------------------- /crates/data-transformer/tests/data/data_transformer/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "data_transformer_contract" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.9.4" 10 | alexandria_data_structures = "0.4.0" 11 | 12 | [dev-dependencies] 13 | snforge_std = "0.39.0" 14 | assert_macros = "2.9.4" 15 | 16 | [[target.starknet-contract]] 17 | sierra = true 18 | 19 | [scripts] 20 | test = "snforge test" 21 | 22 | [tool.scarb] 23 | allow-prebuilt-plugins = ["snforge_std"] 24 | -------------------------------------------------------------------------------- /crates/data-transformer/tests/lib.rs: -------------------------------------------------------------------------------- 1 | mod integration; 2 | mod unit; 3 | -------------------------------------------------------------------------------- /crates/data-transformer/tests/unit/mod.rs: -------------------------------------------------------------------------------- 1 | mod bytes31; 2 | mod u384; 3 | mod u96; 4 | -------------------------------------------------------------------------------- /crates/debugging/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "debugging" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | starknet_api.workspace = true 8 | blockifier.workspace = true 9 | ptree.workspace = true 10 | console.workspace = true 11 | starknet-types-core.workspace = true 12 | starknet.workspace = true 13 | cheatnet = { path = "../cheatnet" } 14 | data-transformer = { path = "../data-transformer" } 15 | thiserror.workspace = true 16 | serde_json.workspace = true 17 | rayon.workspace = true 18 | -------------------------------------------------------------------------------- /crates/debugging/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Crate with debugging utilities in forge. 2 | //! 3 | //! Currently, the main purpose of this crate is displaying pretty traces. 4 | //! The entry point for that is the [`Trace`] struct that implements the [`Display`](std::fmt::Display) 5 | //! which allows for pretty printing of traces. 6 | mod contracts_data_store; 7 | mod trace; 8 | mod tree; 9 | mod verbosity; 10 | 11 | pub use contracts_data_store::ContractsDataStore; 12 | pub use trace::collect::CollectorError; 13 | pub use trace::types::Trace; 14 | pub use verbosity::Verbosity; 15 | -------------------------------------------------------------------------------- /crates/debugging/src/trace/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod collect; 2 | pub mod types; 3 | -------------------------------------------------------------------------------- /crates/debugging/src/tree/building/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod builder; 2 | pub mod node; 3 | -------------------------------------------------------------------------------- /crates/debugging/src/tree/ui/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod as_tree_node; 2 | pub mod display; 3 | -------------------------------------------------------------------------------- /crates/docs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "docs" 3 | version.workspace = true 4 | edition.workspace = true 5 | repository.workspace = true 6 | license.workspace = true 7 | 8 | [dependencies] 9 | regex.workspace = true 10 | shell-words.workspace = true 11 | walkdir.workspace = true 12 | serde.workspace = true 13 | serde_json.workspace = true 14 | toml_edit.workspace = true 15 | camino.workspace = true 16 | tempfile.workspace = true 17 | anyhow.workspace = true 18 | 19 | [features] 20 | testing = [] 21 | -------------------------------------------------------------------------------- /crates/docs/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "testing")] 2 | pub mod snippet; 3 | #[cfg(feature = "testing")] 4 | pub mod validation; 5 | 6 | #[cfg(feature = "testing")] 7 | pub mod utils; 8 | -------------------------------------------------------------------------------- /crates/forge-runner/src/package_tests/raw.rs: -------------------------------------------------------------------------------- 1 | use super::TestTargetLocation; 2 | use cairo_lang_sierra::program::ProgramArtifact; 3 | use camino::Utf8PathBuf; 4 | 5 | /// these structs are representation of scarb output for `scarb build --test` 6 | /// produced by scarb 7 | pub struct TestTargetRaw { 8 | pub sierra_program: ProgramArtifact, 9 | pub sierra_program_path: Utf8PathBuf, 10 | pub tests_location: TestTargetLocation, 11 | } 12 | -------------------------------------------------------------------------------- /crates/forge-runner/src/printing.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/crates/forge-runner/src/printing.rs -------------------------------------------------------------------------------- /crates/forge/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use forge::{ExitStatus, main_execution}; 4 | use foundry_ui::{UI, components::error::ErrorMessage}; 5 | 6 | fn main() { 7 | let ui = Arc::new(UI::default()); 8 | match main_execution(ui.clone()) { 9 | Ok(ExitStatus::Success) => std::process::exit(0), 10 | Ok(ExitStatus::Failure) => std::process::exit(1), 11 | Err(error) => { 12 | ui.println(&ErrorMessage::from(error)); 13 | std::process::exit(2); 14 | } 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /crates/forge/src/run_tests.rs: -------------------------------------------------------------------------------- 1 | pub mod maat; 2 | pub mod package; 3 | pub mod resolve_config; 4 | pub mod structs; 5 | pub mod test_target; 6 | pub mod workspace; 7 | -------------------------------------------------------------------------------- /crates/forge/src/run_tests/maat.rs: -------------------------------------------------------------------------------- 1 | #[must_use] 2 | pub fn env_ignore_fork_tests() -> bool { 3 | std::env::var("SNFORGE_IGNORE_FORK_TESTS").is_ok_and(|v| v == "1") 4 | } 5 | -------------------------------------------------------------------------------- /crates/forge/tests/code_quality.rs: -------------------------------------------------------------------------------- 1 | use camino::Utf8PathBuf; 2 | use packages_validation::check_and_lint; 3 | 4 | #[test] 5 | fn validate_snforge_std() { 6 | let package_path = Utf8PathBuf::from("../../snforge_std") 7 | .canonicalize() 8 | .unwrap() 9 | .try_into() 10 | .unwrap(); 11 | check_and_lint(&package_path); 12 | } 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/backtrace_panic/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "backtrace_panic" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | 20 | [profile.dev.cairo] 21 | unstable-add-statements-functions-debug-info = true 22 | unstable-add-statements-code-locations-debug-info = true 23 | panic-backtrace = true 24 | -------------------------------------------------------------------------------- /crates/forge/tests/data/backtrace_vm_error/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "backtrace_vm_error" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | 20 | [profile.dev.cairo] 21 | unstable-add-statements-functions-debug-info = true 22 | unstable-add-statements-code-locations-debug-info = true 23 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "collection_with_lib" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | # foo = { path = "vendor/foo" } 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/fob.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use collection_with_lib::fob::fob_impl::fob_fn; 4 | 5 | #[test] 6 | fn test_fob() { 7 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/src/fab.cairo: -------------------------------------------------------------------------------- 1 | pub mod fab_impl; 2 | 3 | pub fn fn_from_above() -> felt252 { 4 | 1 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | #[test] 10 | fn test_simple() { 11 | assert(1 == 1, 1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/src/fab/fibfabfob.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use collection_with_lib::fob::fob_impl::fob_fn; 4 | use collection_with_lib::fab::fab_impl::fab_fn; 5 | use collection_with_lib::fib::fib_fn; 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::{fib_fn, fob_fb, fab_fn}; 10 | 11 | #[test] 12 | fn test_fib() { 13 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 14 | } 15 | 16 | #[test] 17 | fn test_fob() { 18 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 19 | } 20 | 21 | #[test] 22 | fn test_fab() { 23 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/src/fob.cairo: -------------------------------------------------------------------------------- 1 | pub mod fob_impl; 2 | 3 | #[cfg(test)] 4 | mod tests { 5 | #[test] 6 | fn test_simple() { 7 | assert(1 == 1, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/src/fob/fob_impl.cairo: -------------------------------------------------------------------------------- 1 | pub fn fob_fn(a: felt252, b: felt252, n: felt252) -> felt252 { 2 | match n { 3 | 0 => a, 4 | _ => fob_fn(b, a + b, n - 1), 5 | } 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::fob_fn; 11 | 12 | #[test] 13 | fn test_fob() { 14 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod fib; 2 | pub mod fob; 3 | pub mod fab; 4 | 5 | use fob::fob_impl::fob_fn; 6 | use fib::fib_fn; 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::{fob_fn, fib_fn}; 11 | #[test] 12 | fn test_simple() { 13 | assert(1 == 1, 1); 14 | } 15 | 16 | #[test] 17 | fn test_fob_in_lib() { 18 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 19 | } 20 | 21 | #[test] 22 | fn test_fib_in_lib() { 23 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/fab.cairo: -------------------------------------------------------------------------------- 1 | use collection_with_lib::fab::fab_impl::fab_fn; 2 | 3 | mod fab_mod; 4 | 5 | #[test] 6 | fn test_fab() { 7 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/fab/fab_mod.cairo: -------------------------------------------------------------------------------- 1 | use super::fab_fn; 2 | 3 | #[test] 4 | fn test_fab() { 5 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/fibfabfob.cairo: -------------------------------------------------------------------------------- 1 | use collection_with_lib::fob::fob_impl::fob_fn; 2 | use collection_with_lib::fab::fab_impl::fab_fn; 3 | use collection_with_lib::fib::fib_fn; 4 | 5 | #[test] 6 | fn test_fib() { 7 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 8 | } 9 | 10 | #[test] 11 | fn test_fob() { 12 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 13 | } 14 | 15 | #[test] 16 | fn test_fab() { 17 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 18 | } 19 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod fibfabfob; 2 | pub mod fab; 3 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/not_found.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use super::fibfabfob::fab_fn; 4 | 5 | mod fab_mod; 6 | 7 | #[test] 8 | fn test_fab() { 9 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_with_lib/tests/not_found/not_found.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use collection_with_lib::fib::fib_fn; 4 | 5 | #[test] 6 | fn test_fib() { 7 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "collection_without_lib" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | # foo = { path = "vendor/foo" } 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/fob.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use collection_without_lib::fob::fob_impl::fob_fn; 4 | 5 | #[test] 6 | fn test_fob() { 7 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/src/fab.cairo: -------------------------------------------------------------------------------- 1 | pub mod fab_impl; 2 | 3 | fn fn_from_above() -> felt252 { 4 | 1 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | #[test] 10 | fn test_simple() { 11 | assert(1 == 1, 1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/src/fob.cairo: -------------------------------------------------------------------------------- 1 | pub mod fob_impl; 2 | 3 | #[cfg(test)] 4 | mod tests { 5 | #[test] 6 | fn test_simple() { 7 | assert(1 == 1, 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/src/fob/fob_impl.cairo: -------------------------------------------------------------------------------- 1 | pub fn fob_fn(a: felt252, b: felt252, n: felt252) -> felt252 { 2 | match n { 3 | 0 => a, 4 | _ => fob_fn(b, a + b, n - 1), 5 | } 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::fob_fn; 11 | 12 | #[test] 13 | fn test_fob() { 14 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod fib; 2 | pub mod fob; 3 | pub mod fab; 4 | 5 | use fob::fob_impl::fob_fn; 6 | use fib::fib_fn; 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::{fob_fn, fib_fn}; 11 | #[test] 12 | fn test_simple() { 13 | assert(1 == 1, 1); 14 | } 15 | 16 | #[test] 17 | fn test_fob_in_lib() { 18 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 19 | } 20 | 21 | #[test] 22 | fn test_fib_in_lib() { 23 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/tests/fab.cairo: -------------------------------------------------------------------------------- 1 | use collection_without_lib::fab::fab_impl::fab_fn; 2 | 3 | mod fab_mod; 4 | 5 | #[test] 6 | fn test_fab() { 7 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/tests/fab/fab_mod.cairo: -------------------------------------------------------------------------------- 1 | use super::fab_fn; 2 | 3 | #[test] 4 | fn test_fab() { 5 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/tests/fibfabfob.cairo: -------------------------------------------------------------------------------- 1 | use collection_without_lib::fob::fob_impl::fob_fn; 2 | use collection_without_lib::fab::fab_impl::fab_fn; 3 | use collection_without_lib::fib::fib_fn; 4 | 5 | #[test] 6 | fn test_fib() { 7 | assert(fib_fn(0, 1, 10) == 55, fib_fn(0, 1, 10)); 8 | } 9 | 10 | #[test] 11 | fn test_fob() { 12 | assert(fob_fn(0, 1, 10) == 55, fob_fn(0, 1, 10)); 13 | } 14 | 15 | #[test] 16 | fn test_fab() { 17 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 18 | } 19 | -------------------------------------------------------------------------------- /crates/forge/tests/data/collection_without_lib/tests/not_found/not_found.cairo: -------------------------------------------------------------------------------- 1 | // Won't be found by the collector 2 | 3 | use super::fab_fn; 4 | 5 | #[test] 6 | fn test_fab() { 7 | assert(fab_fn(0, 1, 10) == 55, fab_fn(0, 1, 10)); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/component_macros/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "component_macros" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/component_macros/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod example; 2 | pub mod oz_ac_component; 3 | -------------------------------------------------------------------------------- /crates/forge/tests/data/contracts/gas_constructor_checker.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod GasConstructorChecker { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[constructor] 7 | fn constructor(ref self: ContractState, _dummy_calldata: felt252) { 8 | keccak::keccak_u256s_le_inputs(array![1].span()); 9 | keccak::keccak_u256s_le_inputs(array![1].span()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /crates/forge/tests/data/contracts/panicking_constructor.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod PanickingConstructor { 3 | use array::ArrayTrait; 4 | 5 | #[storage] 6 | struct Storage {} 7 | 8 | #[constructor] 9 | fn constructor(ref self: ContractState) { 10 | let mut panic_data = ArrayTrait::new(); 11 | panic_data.append('PANIK'); 12 | panic_data.append('DEJTA'); 13 | panic(panic_data); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/contracts/trace_dummy.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | trait ITraceDummy { 3 | fn from_proxy_dummy(ref self: T); 4 | } 5 | 6 | #[starknet::contract] 7 | mod TraceDummy { 8 | #[storage] 9 | struct Storage { 10 | balance: u8 11 | } 12 | 13 | #[abi(embed_v0)] 14 | impl ITraceDummyImpl of super::ITraceDummy { 15 | fn from_proxy_dummy(ref self: ContractState) { 16 | self.balance.write(7); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/forge/tests/data/coverage_project/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "coverage_project" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [profile.dev.cairo] 18 | unstable-add-statements-functions-debug-info = true # Comment 19 | unstable-add-statements-code-locations-debug-info = true 20 | inlining-strategy= "avoid" # Comment 21 | -------------------------------------------------------------------------------- /crates/forge/tests/data/coverage_project/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub fn increase_by_two(arg: u8) -> u8 { 2 | assert(2 == 2, ''); 3 | increase_by_one(arg + 1) 4 | } 5 | 6 | pub fn increase_by_one(arg: u8) -> u8 { 7 | assert(1 == 1, ''); 8 | arg + 1 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/coverage_project/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | use coverage_project::{increase_by_one, increase_by_two}; 2 | 3 | 4 | #[test] 5 | fn my_test() { 6 | assert(increase_by_two(1) == 3, ''); // inlines 7 | assert(increase_by_one(1) == 2, ''); // inlines 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/data/debugging/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trace_info" 3 | version = "0.1.0" 4 | edition = "2023_01" 5 | 6 | [dependencies] 7 | starknet = ">=2.8.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/debugging_fork/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trace_info" 3 | version = "0.1.0" 4 | edition = "2023_01" 5 | 6 | [dependencies] 7 | starknet = ">=2.8.0" 8 | 9 | [[target.starknet-contract]] 10 | sierra = true 11 | 12 | [dev-dependencies] 13 | snforge_std = { path = "../../../../../snforge_std" } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/debugging_fork/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use starknet::ContractAddress; 2 | 3 | #[derive(Drop, Serde, Clone)] 4 | struct RecursiveCall { 5 | contract_address: ContractAddress, 6 | payload: Array, 7 | } 8 | 9 | // `RecursiveCaller` is implemented in the `debugging` package 10 | #[starknet::interface] 11 | trait RecursiveCaller { 12 | fn execute_calls(self: @T, calls: Array) -> Array; 13 | } 14 | 15 | // `Failing` is implemented in the `debugging` package 16 | #[starknet::interface] 17 | trait Failing { 18 | fn fail(self: @TContractState, data: Array); 19 | } 20 | -------------------------------------------------------------------------------- /crates/forge/tests/data/deterministic_output/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deterministic_output" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | 8 | [dev-dependencies] 9 | snforge_std = { path = "../../../../../snforge_std" } 10 | 11 | [[target.starknet-contract]] 12 | sierra = true 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/dispatchers/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dispatchers" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.9.4" 10 | assert_macros = "2.9.4" 11 | 12 | [dev-dependencies] 13 | snforge_std = { path = "../../../../../snforge_std" } 14 | 15 | [[target.starknet-contract]] 16 | sierra = true 17 | 18 | [scripts] 19 | test = "snforge test" 20 | 21 | [profile.dev.cairo] 22 | unstable-add-statements-functions-debug-info = true 23 | unstable-add-statements-code-locations-debug-info = true 24 | panic-backtrace = true 25 | -------------------------------------------------------------------------------- /crates/forge/tests/data/dispatchers/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod error_handler; 2 | 3 | pub mod failable; 4 | -------------------------------------------------------------------------------- /crates/forge/tests/data/duplicated_test_names/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "duplicated_test_names" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dev-dependencies] 7 | snforge_std = { path = "../../../../../snforge_std" } 8 | 9 | [scripts] 10 | test = "snforge test" 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/duplicated_test_names/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/duplicated_test_names/tests/tests_a.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_simple() { 3 | assert(1 == 1, 'simple check'); 4 | } 5 | -------------------------------------------------------------------------------- /crates/forge/tests/data/duplicated_test_names/tests/tests_b.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_simple() { 3 | assert(1 == 1, 'simple check'); 4 | } 5 | -------------------------------------------------------------------------------- /crates/forge/tests/data/empty/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "empty" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/empty/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/env/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "env" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | 8 | [dev-dependencies] 9 | snforge_std = { path = "../../../../../snforge_std" } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/erc20_package/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "erc20_package" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [tool.snforge] 16 | exit_first = false 17 | -------------------------------------------------------------------------------- /crates/forge/tests/data/erc20_package/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc20; 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/exit_first/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "exit_first" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/exit_first/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub fn fib(a: felt252, b: felt252, n: felt252) -> felt252 { 2 | match n { 3 | 0 => a, 4 | _ => fib(b, a + b, n - 1), 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/exit_first/tests/ext_function_test.cairo: -------------------------------------------------------------------------------- 1 | use exit_first::fib; 2 | 3 | #[test] 4 | fn hard_test() { 5 | fib(0, 1, 99999999999999999999999); 6 | assert(2 == 2, 'simple check'); 7 | } 8 | 9 | #[test] 10 | fn simple_test() { 11 | fib(0, 1, 3); 12 | assert(1 == 2, 'simple check'); 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/features/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "features" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [features] 15 | snforge_test_only = [] 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/features/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | pub trait IContract { 3 | fn response(ref self: TContractState) -> felt252; 4 | } 5 | 6 | #[cfg(feature: 'snforge_test_only')] 7 | #[starknet::contract] 8 | pub mod MockContract { 9 | #[storage] 10 | struct Storage {} 11 | 12 | #[abi(embed_v0)] 13 | impl IContractImpl of super::IContract { 14 | fn response(ref self: ContractState) -> felt252 { 15 | super::some_func() 16 | } 17 | } 18 | } 19 | 20 | fn some_func() -> felt252 { 21 | 1234 22 | } 23 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "file_reading" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [[target.starknet-contract]] 7 | sierra = true 8 | 9 | [dependencies] 10 | starknet = "2.4.0" 11 | 12 | [dev-dependencies] 13 | snforge_std = { path = "../../../../../snforge_std" } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/json/invalid.json: -------------------------------------------------------------------------------- 1 | 231232 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/json/nested_valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "b": { 3 | "d": 1, 4 | "c": "test", 5 | "e": { 6 | "a": 2 7 | } 8 | }, 9 | "a": 23 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/json/valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "b": "hello", 3 | "a": 1, 4 | "c": 3, 5 | "d": 1656, 6 | "e": " ", 7 | "f": "hello\nworld", 8 | "g": "world", 9 | "h": 0, 10 | "i": 3618502788666131213697322783095070105623107215331596699973092056135872020480 11 | } 12 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/json/with_array.json: -------------------------------------------------------------------------------- 1 | { 2 | "aa": 2, 3 | "array": [1, 23, 4, 5], 4 | "string_array": ["test", "test2"] 5 | } 6 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/negative_number.txt: -------------------------------------------------------------------------------- 1 | -1241241 -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/non_ascii.txt: -------------------------------------------------------------------------------- 1 | a 2 | £ 3 | § -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/data/valid.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 'hello' 3 | 3 4 | 5 | 0x678 6 | 7 | ' ' 8 | 9 | 10 | 'hello\nworld' 11 | 'world' 12 | 13 | 14 | 0 15 | 3618502788666131213697322783095070105623107215331596699973092056135872020480 16 | 17 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/file_reading/valid_file.txt: -------------------------------------------------------------------------------- 1 | 123 2 | '12dsfwe' 3 | 00124 4 | -------------------------------------------------------------------------------- /crates/forge/tests/data/forking/.gitignore: -------------------------------------------------------------------------------- 1 | !.snfoundry_cache/ 2 | !.snfoundry_cache/* 3 | -------------------------------------------------------------------------------- /crates/forge/tests/data/forking/.snfoundry_cache/README.md: -------------------------------------------------------------------------------- 1 | This is a fabricated cache file with value for storage changed from real `2` to fake `333`. 2 | 3 | It is used to verify if the cache is actually used. -------------------------------------------------------------------------------- /crates/forge/tests/data/forking/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forking" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/fuzzing/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fuzzing" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [features] 15 | unimplemented = [] 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/fuzzing/tests/exit_first_fuzz.cairo: -------------------------------------------------------------------------------- 1 | use fuzzing::adder; 2 | use fuzzing::fib; 3 | 4 | 5 | #[test] 6 | #[fuzzer] 7 | fn exit_first_fails_test(b: felt252) { 8 | adder(0, 1); 9 | assert(1 == 2, '2 + b == 2 + b'); 10 | } 11 | 12 | #[test] 13 | #[fuzzer] 14 | fn exit_first_hard_test(b: felt252) { 15 | fib(0, 1, 30344); 16 | assert(2 == 2, 'simple check'); 17 | } 18 | -------------------------------------------------------------------------------- /crates/forge/tests/data/fuzzing/tests/exit_first_single_fail.cairo: -------------------------------------------------------------------------------- 1 | use fuzzing::adder; 2 | use fuzzing::fib; 3 | 4 | 5 | #[test] 6 | fn exit_first_fails_test() { 7 | adder(0, 1); 8 | assert(1 == 2, '2 + b == 2 + b'); 9 | } 10 | 11 | #[test] 12 | #[fuzzer] 13 | fn exit_first_hard_test(b: felt252) { 14 | fib(0, 1, 30344); 15 | assert(2 == 2, 'simple check'); 16 | } 17 | -------------------------------------------------------------------------------- /crates/forge/tests/data/fuzzing/tests/generate_arg.cairo: -------------------------------------------------------------------------------- 1 | use snforge_std::fuzzable::generate_arg; 2 | 3 | #[test] 4 | fn use_generate_arg_outside_fuzzer() { 5 | let random: usize = generate_arg(100, 999); 6 | assert(99 < random && random < 1000, 'value outside correct range'); 7 | } 8 | 9 | 10 | #[test] 11 | fn generate_arg_incorrect_range() { 12 | generate_arg(101, 100); 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/fuzzing/tests/incorrect_args.cairo: -------------------------------------------------------------------------------- 1 | use fuzzing::adder; 2 | 3 | #[derive(Debug, Drop)] 4 | struct MyStruct { 5 | a: felt252, 6 | } 7 | 8 | #[test] 9 | #[fuzzer] 10 | fn correct_args(b: felt252) { 11 | let result = adder(2, b); 12 | assert(result == 2 + b, '2 + b == 2 + b'); 13 | } 14 | 15 | #[cfg(feature: 'unimplemented')] 16 | #[test] 17 | #[fuzzer] 18 | fn incorrect_args(b: felt252, a: MyStruct) { 19 | let result = adder(2, b); 20 | assert(result == 2 + b, '2 + b == 2 + b'); 21 | } 22 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/addition/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "addition" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet.workspace = true 8 | 9 | [dev-dependencies] 10 | snforge_std.workspace = true 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [lib] 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/addition/tests/nested.cairo: -------------------------------------------------------------------------------- 1 | use snforge_std::declare; 2 | 3 | mod test_nested; 4 | 5 | fn foo() -> u8 { 6 | 2 7 | } 8 | 9 | #[test] 10 | fn simple_case() { 11 | assert(1 == 1, 'simple check'); 12 | } 13 | 14 | #[test] 15 | fn contract_test() { 16 | declare("AdditionContract").unwrap(); 17 | } 18 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/addition/tests/nested/test_nested.cairo: -------------------------------------------------------------------------------- 1 | use super::foo; 2 | 3 | #[test] 4 | fn test_two() { 5 | assert(foo() == 2, 'foo() == 2'); 6 | } 7 | 8 | #[test] 9 | fn test_two_and_two() { 10 | assert(2 == 2, '2 == 2'); 11 | assert(2 == 2, '2 == 2'); 12 | } 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/fibonacci/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fibonacci" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [scripts] 7 | test.workspace = true 8 | 9 | [tool] 10 | snforge.workspace = true 11 | 12 | [dependencies] 13 | addition = { path = "../addition" } 14 | starknet.workspace = true 15 | 16 | [dev-dependencies] 17 | snforge_std.workspace = true 18 | 19 | [[target.starknet-contract]] 20 | sierra = true 21 | build-external-contracts = ["addition::AdditionContract"] 22 | 23 | [lib] 24 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/fibonacci/tests/abc.cairo: -------------------------------------------------------------------------------- 1 | mod efg; 2 | 3 | #[test] 4 | fn abc_test() { 5 | assert(foo() == 1, ''); 6 | } 7 | 8 | pub fn foo() -> u8 { 9 | 1 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/fibonacci/tests/abc/efg.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn efg_test() { 3 | assert(super::foo() == 1, ''); 4 | } 5 | 6 | #[test] 7 | fn failing_test() { 8 | assert(1 == 2, ''); 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/fibonacci/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod abc; 2 | 3 | #[test] 4 | fn lib_test() { 5 | assert(abc::foo() == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/crates/fibonacci/tests/not_collected.cairo: -------------------------------------------------------------------------------- 1 | // should not be collected 2 | 3 | #[test] 4 | fn not_collected() { 5 | assert(1 == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/hello_workspaces/tests/test_failing.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_failing() { 3 | assert(1 == 2, 'failing check'); 4 | } 5 | 6 | #[test] 7 | fn test_another_failing() { 8 | assert(2 == 3, 'failing check'); 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/nonexistent_selector/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nonexistent_selector" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /crates/forge/tests/data/panic_decoding/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "panic_decoding" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | assert_macros = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/panic_decoding/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/should_panic_test/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "should_panic_test" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dev-dependencies] 7 | snforge_std = { path = "../../../../../snforge_std" } 8 | -------------------------------------------------------------------------------- /crates/forge/tests/data/should_panic_test/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/simple_package/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "simple_package" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/simple_package/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod hello_starknet; 2 | 3 | pub fn fib(a: felt252, b: felt252, n: felt252) -> felt252 { 4 | match n { 5 | 0 => a, 6 | _ => fib(b, a + b, n - 1), 7 | } 8 | } 9 | 10 | #[cfg(test)] 11 | mod tests { 12 | use super::fib; 13 | 14 | #[test] 15 | fn test_fib() { 16 | assert(fib(0, 1, 10) == 55, fib(0, 1, 10)); 17 | } 18 | 19 | #[test] 20 | #[ignore] 21 | fn ignored_test() { 22 | assert(1 == 1, 'passing'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/forge/tests/data/simple_package/tests/ext_function_test.cairo: -------------------------------------------------------------------------------- 1 | use simple_package::fib; 2 | 3 | #[test] 4 | fn test_my_test() { 5 | assert(fib(0, 1, 10) == 55, fib(0, 1, 10)); 6 | assert(2 == 2, 'simple check'); 7 | } 8 | 9 | #[test] 10 | #[ignore] 11 | fn ignored_test() { 12 | assert(1 == 2, 'not passing'); 13 | } 14 | 15 | #[test] 16 | fn test_simple() { 17 | assert(1 == 1, 'simple check'); 18 | } 19 | -------------------------------------------------------------------------------- /crates/forge/tests/data/simple_package/tests/test_simple.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_simple() { 3 | assert(1 == 1, 'simple check'); 4 | } 5 | 6 | #[test] 7 | fn test_simple2() { 8 | assert(3 == 3, 'simple check'); 9 | } 10 | 11 | #[test] 12 | fn test_two() { 13 | assert(2 == 2, '2 == 2'); 14 | } 15 | 16 | #[test] 17 | fn test_two_and_two() { 18 | assert(2 == 2, '2 == 2'); 19 | assert(2 == 2, '2 == 2'); 20 | } 21 | 22 | #[test] 23 | fn test_failing() { 24 | assert(1 == 2, 'failing check'); 25 | } 26 | 27 | #[test] 28 | fn test_another_failing() { 29 | assert(2 == 3, 'failing check'); 30 | } 31 | -------------------------------------------------------------------------------- /crates/forge/tests/data/simple_package/tests/without_prefix.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn five() { 3 | assert(5 == 5, '5 == 5'); 4 | } 5 | -------------------------------------------------------------------------------- /crates/forge/tests/data/steps/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "steps" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.4.0" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/steps/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn steps_less_than_10000000() { 5 | let mut i = 0; 6 | 7 | while i != 550_000 { 8 | i = i + 1; 9 | assert(1 + 1 == 2, 'who knows?'); 10 | } 11 | } 12 | 13 | 14 | #[test] 15 | fn steps_more_than_10000000() { 16 | let mut i = 0; 17 | 18 | while i != 680_000 { 19 | i = i + 1; 20 | assert(1 + 1 == 2, 'who knows?'); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/custom_target/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "custom_target" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [[test]] 15 | name = "custom_target_integrationtest" 16 | kind = "test" 17 | source-path = "./tests/tests.cairo" 18 | test-type = "integration" 19 | 20 | [[test]] 21 | name = "custom_target_unittest" 22 | kind = "test" 23 | test-type = "unit" 24 | 25 | [tool.snforge] 26 | exit_first = false 27 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/custom_target_custom_names/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "custom_target_custom_names" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | 13 | [[test]] 14 | name = "custom_first" 15 | kind = "my_kind" 16 | source-path = "./tests/tests.cairo" 17 | test-type = "integration" 18 | build-external-contracts = ["custom_target_custom_names::*"] 19 | 20 | [[test]] 21 | name = "custom_second" 22 | kind = "my_other_kind" 23 | test-type = "unit" 24 | 25 | [tool.snforge] 26 | exit_first = false 27 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/custom_target_only_integration/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "custom_target_only_integration" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [[test]] 15 | name = "custom_first" 16 | kind = "test" 17 | source-path = "./tests/tests.cairo" 18 | test-type = "integration" 19 | build-external-contracts = ["custom_target_only_integration::*"] 20 | 21 | [tool.snforge] 22 | exit_first = false 23 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/only_integration/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "only_integration" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/only_lib_integration/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "only_lib_integration" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/only_lib_integration/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod tests; 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/only_unit/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "only_unit" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/unit_and_integration/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unit_and_integration" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/unit_and_lib_integration/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unit_and_lib_integration" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/unit_and_lib_integration/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod tests; 2 | -------------------------------------------------------------------------------- /crates/forge/tests/data/targets/with_features/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "with_features" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | 14 | [tool.snforge] 15 | exit_first = false 16 | 17 | [features] 18 | enable_for_tests = [] 19 | -------------------------------------------------------------------------------- /crates/forge/tests/data/trace/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trace_info" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | -------------------------------------------------------------------------------- /crates/forge/tests/data/trace_resources/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trace_resources" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.4.0" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/trace_resources/src/empty.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod Empty { 3 | #[storage] 4 | struct Storage {} 5 | } 6 | -------------------------------------------------------------------------------- /crates/forge/tests/data/trace_resources/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod test_call; 2 | mod test_deploy; 3 | mod test_l1_handler; 4 | mod test_lib_call; 5 | mod test_failed_call; 6 | mod test_failed_lib_call; 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/Scarb.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "dummy_name/*", 4 | ] 5 | 6 | [workspace.scripts] 7 | test = "snforge" 8 | 9 | [workspace.tool.snforge] 10 | exit_first = true 11 | 12 | [workspace.dependencies] 13 | starknet = "2.4.0" 14 | snforge_std = { path = "../../../../../snforge_std" } 15 | 16 | [workspace.package] 17 | version = "0.1.0" 18 | edition = "2024_07" 19 | 20 | [scripts] 21 | test.workspace = true 22 | 23 | [tool] 24 | snforge.workspace = true 25 | 26 | [[target.starknet-contract]] 27 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/fibonacci2/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fibonacci2" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [scripts] 7 | test.workspace = true 8 | 9 | [tool] 10 | snforge.workspace = true 11 | 12 | [dependencies] 13 | subtraction = { path = "../subtraction" } 14 | starknet.workspace = true 15 | 16 | [dev-dependencies] 17 | snforge_std.workspace = true 18 | 19 | [[target.starknet-contract]] 20 | 21 | build-external-contracts = ["subtraction::SubtractionContract"] 22 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/fibonacci2/tests/abc.cairo: -------------------------------------------------------------------------------- 1 | mod efg; 2 | 3 | #[test] 4 | fn abc_test() { 5 | assert(foo() == 1, ''); 6 | } 7 | 8 | pub fn foo() -> u8 { 9 | 1 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/fibonacci2/tests/abc/efg.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn efg_test() { 3 | assert(super::foo() == 1, ''); 4 | } 5 | 6 | #[test] 7 | fn failing_test() { 8 | assert(1 == 2, ''); 9 | } 10 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/fibonacci2/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod abc; 2 | 3 | #[test] 4 | fn lib_test() { 5 | assert(abc::foo() == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/fibonacci2/tests/not_collected.cairo: -------------------------------------------------------------------------------- 1 | // should not be collected 2 | 3 | #[test] 4 | fn not_collected() { 5 | assert(1 == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/subtraction/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "subtraction" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet.workspace = true 8 | 9 | [dev-dependencies] 10 | snforge_std.workspace = true 11 | 12 | [[target.starknet-contract]] 13 | 14 | [lib] 15 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/subtraction/tests/nested.cairo: -------------------------------------------------------------------------------- 1 | use snforge_std::declare; 2 | 3 | mod test_nested; 4 | 5 | fn foo() -> u8 { 6 | 2 7 | } 8 | 9 | #[test] 10 | fn simple_case() { 11 | assert(1 == 1, 'simple check'); 12 | } 13 | 14 | #[test] 15 | fn contract_test() { 16 | declare("SubtractionContract").unwrap(); 17 | } 18 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/dummy_name/subtraction/tests/nested/test_nested.cairo: -------------------------------------------------------------------------------- 1 | use super::foo; 2 | 3 | #[test] 4 | fn test_two() { 5 | assert(foo() == 2, 'foo() == 2'); 6 | } 7 | 8 | #[test] 9 | fn test_two_and_two() { 10 | assert(2 == 2, '2 == 2'); 11 | assert(2 == 2, '2 == 2'); 12 | } 13 | -------------------------------------------------------------------------------- /crates/forge/tests/data/virtual_workspace/not_collected.cairo: -------------------------------------------------------------------------------- 1 | // This file shouldn't be collected 2 | 3 | #[test] 4 | fn test_simple() { 5 | assert(1 == 1, 'simple check'); 6 | } 7 | -------------------------------------------------------------------------------- /crates/forge/tests/e2e/common/mod.rs: -------------------------------------------------------------------------------- 1 | use cairo_annotations::trace_data::{ 2 | CallTraceNode as ProfilerCallTraceNode, CallTraceV1 as ProfilerCallTrace, 3 | }; 4 | 5 | pub mod runner; 6 | 7 | pub fn get_trace_from_trace_node(trace_node: &ProfilerCallTraceNode) -> &ProfilerCallTrace { 8 | if let ProfilerCallTraceNode::EntryPointCall(trace) = trace_node { 9 | trace 10 | } else { 11 | panic!("Deploy without constructor node was not expected") 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/tests/e2e/components.rs: -------------------------------------------------------------------------------- 1 | use super::common::runner::{setup_package, test_runner}; 2 | 3 | #[test] 4 | fn contract_components() { 5 | let temp = setup_package("component_macros"); 6 | 7 | test_runner(&temp).assert().success(); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/main.rs: -------------------------------------------------------------------------------- 1 | mod code_quality; 2 | mod e2e; 3 | mod integration; 4 | -------------------------------------------------------------------------------- /crates/foundry-ui/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-ui" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | serde.workspace = true 8 | serde_json.workspace = true 9 | anyhow.workspace = true 10 | starknet-types-core.workspace = true 11 | console.workspace = true 12 | -------------------------------------------------------------------------------- /crates/foundry-ui/src/components/mod.rs: -------------------------------------------------------------------------------- 1 | //! This module provides various ready to use message types for use with 2 | //! a [`UI`]. 3 | 4 | pub mod error; 5 | pub mod labeled; 6 | pub mod tagged; 7 | pub mod warning; 8 | -------------------------------------------------------------------------------- /crates/foundry-ui/src/output.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/crates/foundry-ui/src/output.rs -------------------------------------------------------------------------------- /crates/runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [features] 7 | testing = [] 8 | 9 | [dependencies] 10 | indoc.workspace = true 11 | anyhow.workspace = true 12 | conversions.workspace = true 13 | cairo-lang-casm.workspace = true 14 | cairo-lang-utils.workspace = true 15 | starknet-types-core.workspace = true 16 | starknet_api.workspace = true 17 | starknet.workspace = true 18 | blockifier.workspace = true 19 | cairo-vm.workspace = true 20 | serde_json.workspace = true 21 | serde.workspace = true 22 | thiserror.workspace = true 23 | num-traits.workspace = true 24 | shared.workspace = true 25 | -------------------------------------------------------------------------------- /crates/runtime/src/starknet/constants.rs: -------------------------------------------------------------------------------- 1 | pub const TEST_ENTRY_POINT_SELECTOR: &str = "TEST_CONTRACT_SELECTOR"; 2 | pub const TEST_CONTRACT_CLASS_HASH: &str = "0x117"; 3 | // snforge_std/src/cheatcodes.cairo::test_address 4 | pub const TEST_ADDRESS: &str = "0x01724987234973219347210837402"; 5 | -------------------------------------------------------------------------------- /crates/runtime/src/starknet/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod constants; 2 | pub mod context; 3 | pub mod state; 4 | -------------------------------------------------------------------------------- /crates/scarb-api/src/metadata.rs: -------------------------------------------------------------------------------- 1 | use anyhow::{Context, Result}; 2 | pub use scarb_metadata::{Metadata, MetadataCommand, MetadataCommandError, PackageMetadata}; 3 | 4 | pub trait MetadataCommandExt { 5 | fn run(&mut self) -> Result; 6 | } 7 | 8 | impl MetadataCommandExt for MetadataCommand { 9 | fn run(&mut self) -> Result { 10 | self.inherit_stdout() 11 | .exec() 12 | .context("error: could not gather project metadata from Scarb due to previous error") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/scarb-api/tests/data/basic_package/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic_package" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | snforge_std = { path = "../../../../../snforge_std" } 9 | 10 | [[target.starknet-contract]] 11 | -------------------------------------------------------------------------------- /crates/scarb-api/tests/data/basic_package/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod HelloStarknet { 3 | #[storage] 4 | struct Storage { 5 | balance: felt252, 6 | } 7 | } 8 | 9 | #[starknet::contract] 10 | mod ERC20 { 11 | #[storage] 12 | struct Storage { 13 | balance: felt252, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /crates/scarb-api/tests/data/empty_lib/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "empty_lib" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | -------------------------------------------------------------------------------- /crates/scarb-api/tests/data/empty_lib/src/lib.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /crates/shared/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shared" 3 | version = "0.1.0" 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | starknet_api.workspace = true 8 | anyhow.workspace = true 9 | starknet-types-core.workspace = true 10 | console.workspace = true 11 | semver.workspace = true 12 | starknet.workspace = true 13 | url.workspace = true 14 | regex.workspace = true 15 | snapbox.workspace = true 16 | indicatif.workspace = true 17 | clap.workspace = true 18 | clap_complete.workspace = true 19 | cairo-vm.workspace = true 20 | num-traits.workspace = true 21 | foundry-ui ={ path = "../foundry-ui" } 22 | 23 | [features] 24 | testing = [] 25 | -------------------------------------------------------------------------------- /crates/shared/src/consts.rs: -------------------------------------------------------------------------------- 1 | pub const EXPECTED_RPC_VERSION: &str = "0.8.1"; 2 | pub const RPC_URL_VERSION: &str = "v0_8"; 3 | pub const SNFORGE_TEST_FILTER: &str = "SNFORGE_TEST_FILTER"; 4 | pub const FREE_RPC_PROVIDER_URL: &str = "https://starknet-sepolia.public.blastapi.io/rpc/v0_8"; 5 | -------------------------------------------------------------------------------- /crates/shared/src/test_utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod node_url; 2 | pub mod output_assert; 3 | -------------------------------------------------------------------------------- /crates/shared/src/test_utils/node_url.rs: -------------------------------------------------------------------------------- 1 | use url::Url; 2 | 3 | /// #### Note: 4 | /// - `node_rpc_url()` -> 5 | /// - `node_url()` -> 6 | #[must_use] 7 | pub fn node_rpc_url() -> Url { 8 | Url::parse("http://188.34.188.184:7070/rpc/v0_8").expect("Failed to parse the sepolia RPC URL") 9 | } 10 | 11 | /// returning URL with no slug (`rpc/v0_7` suffix). 12 | #[must_use] 13 | pub fn node_url() -> Url { 14 | let mut node_url = node_rpc_url(); 15 | node_url.set_path(""); 16 | node_url.set_query(None); 17 | 18 | node_url 19 | } 20 | -------------------------------------------------------------------------------- /crates/sncast/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | "test e2e" = "test --test main e2e" 3 | "test integration" = "test --test main integration" 4 | -------------------------------------------------------------------------------- /crates/sncast/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | tests/utils/cairo 3 | tests/utils/scarb* 4 | /tests/data/contracts/**/*.tool-versions 5 | /tests/utils/compiler/ 6 | .env* 7 | tests/data/contracts/constructor_with_params[0-9]/ 8 | tests/data/contracts/map[0-9]/ 9 | tests/utils/devnet 10 | tests/**/*state.json 11 | 12 | -------------------------------------------------------------------------------- /crates/sncast/src/helpers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod block_explorer; 3 | pub mod braavos; 4 | pub mod config; 5 | pub mod configuration; 6 | pub mod constants; 7 | pub mod fee; 8 | pub mod interactive; 9 | pub mod output_format; 10 | pub mod rpc; 11 | pub mod scarb_utils; 12 | -------------------------------------------------------------------------------- /crates/sncast/src/helpers/output_format.rs: -------------------------------------------------------------------------------- 1 | use foundry_ui::OutputFormat; 2 | 3 | #[must_use] 4 | pub fn output_format_from_json_flag(json: bool) -> OutputFormat { 5 | if json { 6 | OutputFormat::Json 7 | } else { 8 | OutputFormat::Human 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/sncast/src/response/account/delete.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | use crate::response::command::CommandResponse; 4 | 5 | #[derive(Serialize, Clone)] 6 | pub struct AccountDeleteResponse { 7 | pub result: String, 8 | } 9 | 10 | impl CommandResponse for AccountDeleteResponse {} 11 | 12 | // TODO(#3391): Update text output to be more user friendly 13 | // impl Message for SncastMessage {} 14 | -------------------------------------------------------------------------------- /crates/sncast/src/response/account/import.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | use crate::response::command::CommandResponse; 4 | 5 | #[derive(Serialize, Clone)] 6 | pub struct AccountImportResponse { 7 | pub add_profile: String, 8 | pub account_name: Option, 9 | } 10 | 11 | impl CommandResponse for AccountImportResponse {} 12 | 13 | // TODO(#3391): Update text output to be more user friendly 14 | // impl Message for SncastMessage {} 15 | -------------------------------------------------------------------------------- /crates/sncast/src/response/account/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod create; 2 | pub mod delete; 3 | pub mod deploy; 4 | pub mod import; 5 | -------------------------------------------------------------------------------- /crates/sncast/src/response/call.rs: -------------------------------------------------------------------------------- 1 | use super::command::CommandResponse; 2 | use conversions::serde::serialize::CairoSerialize; 3 | use serde::Serialize; 4 | use starknet_types_core::felt::Felt; 5 | 6 | #[derive(Serialize, CairoSerialize, Clone)] 7 | pub struct CallResponse { 8 | pub response: Vec, 9 | } 10 | 11 | impl CommandResponse for CallResponse {} 12 | 13 | // TODO(#3391): Update text output to be more user friendly 14 | // impl Message for SncastMessage { } 15 | -------------------------------------------------------------------------------- /crates/sncast/src/response/command.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | pub trait CommandResponse: Serialize {} 4 | -------------------------------------------------------------------------------- /crates/sncast/src/response/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod call; 3 | pub mod cast_message; 4 | pub mod command; 5 | pub mod declare; 6 | pub mod deploy; 7 | pub mod errors; 8 | pub mod explorer_link; 9 | pub mod invoke; 10 | pub mod multicall; 11 | pub mod print; 12 | pub mod script; 13 | pub mod show_config; 14 | pub mod transformed_call; 15 | pub mod tx_status; 16 | pub mod verify; 17 | -------------------------------------------------------------------------------- /crates/sncast/src/response/multicall/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod new; 2 | pub mod run; 3 | -------------------------------------------------------------------------------- /crates/sncast/src/response/multicall/new.rs: -------------------------------------------------------------------------------- 1 | use camino::Utf8PathBuf; 2 | use serde::Serialize; 3 | 4 | use crate::response::command::CommandResponse; 5 | 6 | #[derive(Serialize, Clone)] 7 | pub struct MulticallNewResponse { 8 | pub path: Utf8PathBuf, 9 | pub content: String, 10 | } 11 | 12 | impl CommandResponse for MulticallNewResponse {} 13 | 14 | // TODO(#3391): Update text output to be more user friendly 15 | // impl Message for SncastMessage {} 16 | -------------------------------------------------------------------------------- /crates/sncast/src/response/script/init.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | use crate::response::command::CommandResponse; 4 | 5 | #[derive(Serialize, Clone)] 6 | pub struct ScriptInitResponse { 7 | pub message: String, 8 | } 9 | 10 | impl CommandResponse for ScriptInitResponse {} 11 | 12 | // TODO(#3391): Update text output to be more user friendly 13 | // impl Message for SncastMessage {} 14 | -------------------------------------------------------------------------------- /crates/sncast/src/response/script/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod init; 2 | pub mod run; 3 | -------------------------------------------------------------------------------- /crates/sncast/src/response/script/run.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | use crate::response::command::CommandResponse; 4 | 5 | #[derive(Serialize, Debug, Clone)] 6 | pub struct ScriptRunResponse { 7 | pub status: String, 8 | pub message: Option, 9 | } 10 | 11 | impl CommandResponse for ScriptRunResponse {} 12 | 13 | // TODO(#3391): Update text output to be more user friendly 14 | // impl Message for SncastMessage {} 15 | -------------------------------------------------------------------------------- /crates/sncast/src/response/transformed_call.rs: -------------------------------------------------------------------------------- 1 | use super::command::CommandResponse; 2 | use serde::Serialize; 3 | use starknet_types_core::felt::Felt; 4 | 5 | #[derive(Serialize, Clone)] 6 | pub struct TransformedCallResponse { 7 | pub response: String, 8 | pub response_raw: Vec, 9 | } 10 | 11 | impl CommandResponse for TransformedCallResponse {} 12 | 13 | // TODO(#3391): Update text output to be more user friendly 14 | // impl Message for SncastMessage {} 15 | -------------------------------------------------------------------------------- /crates/sncast/src/response/verify.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | use super::command::CommandResponse; 4 | 5 | #[derive(Serialize, Clone)] 6 | pub struct VerifyResponse { 7 | pub message: String, 8 | } 9 | 10 | impl CommandResponse for VerifyResponse {} 11 | 12 | // TODO(#3391): Update text output to be more user friendly 13 | // impl Message for SncastMessage {} 14 | -------------------------------------------------------------------------------- /crates/sncast/src/starknet_commands/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod call; 3 | pub mod declare; 4 | pub mod deploy; 5 | pub mod invoke; 6 | pub mod multicall; 7 | pub mod script; 8 | pub mod show_config; 9 | pub mod tx_status; 10 | pub mod verify; 11 | -------------------------------------------------------------------------------- /crates/sncast/src/starknet_commands/multicall/mod.rs: -------------------------------------------------------------------------------- 1 | use clap::{Args, Subcommand}; 2 | 3 | pub mod new; 4 | pub mod run; 5 | 6 | use new::New; 7 | use run::Run; 8 | 9 | #[derive(Args)] 10 | #[command(about = "Execute multiple calls at once", long_about = None)] 11 | pub struct Multicall { 12 | #[command(subcommand)] 13 | pub command: Commands, 14 | } 15 | 16 | #[derive(Debug, Subcommand)] 17 | pub enum Commands { 18 | Run(Box), 19 | New(New), 20 | } 21 | -------------------------------------------------------------------------------- /crates/sncast/src/starknet_commands/script/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::starknet_commands::script::init::Init; 2 | use crate::starknet_commands::script::run::Run; 3 | use clap::{Args, Subcommand}; 4 | 5 | pub mod init; 6 | pub mod run; 7 | 8 | #[derive(Args)] 9 | pub struct Script { 10 | #[command(subcommand)] 11 | pub command: Commands, 12 | } 13 | 14 | #[derive(Debug, Subcommand)] 15 | pub enum Commands { 16 | Init(Init), 17 | Run(Run), 18 | } 19 | -------------------------------------------------------------------------------- /crates/sncast/src/state/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hashing; 2 | pub mod state_file; 3 | -------------------------------------------------------------------------------- /crates/sncast/tests/code_quality.rs: -------------------------------------------------------------------------------- 1 | use camino::Utf8PathBuf; 2 | use packages_validation::check_and_lint; 3 | 4 | #[test] 5 | fn validate_sncast_std() { 6 | let package_path = Utf8PathBuf::from("../../sncast_std") 7 | .canonicalize() 8 | .unwrap() 9 | .try_into() 10 | .unwrap(); 11 | check_and_lint(&package_path); 12 | } 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/accounts/faulty_accounts_invalid_felt.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha-sepolia": { 3 | "with_invalid_private_key": { 4 | "private_key": "private_key", 5 | "public_key": "0x14b491156e96ecf11dace8999b1e5e30888548a581c067b1956b7468bb279b9", 6 | "salt": "0x14b6b215424909f34f417ddd7cbaca48de2d505d03c92467367d275e847d252", 7 | "address": "0x76e7ce6466e353a00b614ee763f1bc93dba01a57925784a7682efa6b1879c3d", 8 | "deployed": true 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/build_fails/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "build_fails" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.0.2" 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | sierra = false 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/build_fails/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod BuildFails { 3 | #[storage] 4 | struct Storage { 5 | storage: felt2, 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/constructor_with_params/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "constructor_with_params" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.0.2" 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | sierra = false 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/constructor_with_params/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod ConstructorWithParams { 3 | #[storage] 4 | struct Storage { 5 | value1: felt252, 6 | value2: u256, 7 | } 8 | 9 | #[constructor] 10 | fn constructor(ref self: ContractState, first: felt252, second: u256) { 11 | self.value1.write(first); 12 | self.value2.write(second); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/map/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "map" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.0.2" 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | sierra = false 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/Scarb.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "crates/*", 4 | ] 5 | 6 | [workspace.dependencies] 7 | starknet = "2.4.0" 8 | 9 | [workspace.package] 10 | version = "0.1.0" 11 | 12 | [package] 13 | name = "main_workspace" 14 | version.workspace = true 15 | edition = "2024_07" 16 | 17 | [dependencies] 18 | starknet.workspace = true 19 | package1 = { path = "crates/package1" } 20 | package2 = { path = "crates/package2" } 21 | 22 | [[target.starknet-contract]] 23 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/crates/package1/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "package1" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet.workspace = true 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/crates/package1/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | pub mod supercomplexcode1 { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[abi(embed_v0)] 7 | fn whatever(ref self: ContractState) -> felt252 { 8 | 1 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/crates/package2/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "package2" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet.workspace = true 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/crates/package2/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | pub mod supercomplexcode2 { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[abi(embed_v0)] 7 | fn whatever(ref self: ContractState) -> felt252 { 8 | 2 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/multiple_packages/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | mod supercomplexcode { 3 | use package1::supercomplexcode1; 4 | use package2::supercomplexcode2; 5 | 6 | #[storage] 7 | struct Storage {} 8 | 9 | #[abi(embed_v0)] 10 | fn whatever(ref self: ContractState) -> felt252 { 11 | 3 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/no_casm/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "build_fails_no_casm" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.0.2" 8 | 9 | [[target.starknet-contract]] 10 | sierra = true 11 | casm = false 12 | 13 | [lib] 14 | sierra = true 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/no_casm/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | trait Iminimal_contract { 3 | fn empty(ref self: TContractState); 4 | } 5 | 6 | #[starknet::contract] 7 | mod minimal_contract { 8 | #[storage] 9 | struct Storage {} 10 | 11 | #[abi(embed_v0)] 12 | impl minimal_contractImpl of super::Iminimal_contract { 13 | fn empty(ref self: ContractState) {} 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/no_sierra/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "build_fails_no_sierra" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.0.2" 8 | 9 | [[target.starknet-contract]] 10 | sierra = false 11 | 12 | [lib] 13 | sierra = false 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/no_sierra/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | trait Iminimal_contract { 3 | fn empty(ref self: TContractState); 4 | } 5 | 6 | #[starknet::contract] 7 | mod minimal_contract { 8 | #[storage] 9 | struct Storage {} 10 | 11 | #[abi(embed_v0)] 12 | impl minimal_contractImpl of super::Iminimal_contract { 13 | fn empty(ref self: ContractState) {} 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/virtual_workspace/Scarb.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "crates/*", 4 | ] 5 | 6 | [workspace.package] 7 | version = "0.1.0" 8 | 9 | [workspace.dependencies] 10 | starknet = "2.4.0" 11 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/virtual_workspace/crates/cast_addition/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cast_addition" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet.workspace = true 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/virtual_workspace/crates/cast_addition/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub fn add(a: felt252, b: felt252) -> felt252 { 2 | a + b 3 | } 4 | 5 | #[starknet::contract] 6 | mod AdditionContract { 7 | use cast_addition::add; 8 | 9 | #[storage] 10 | struct Storage {} 11 | 12 | #[external(v0)] 13 | fn answer(ref self: ContractState) -> felt252 { 14 | add(10, 20) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/virtual_workspace/crates/cast_fibonacci/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cast_fibonacci" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | cast_addition = { path = "../cast_addition" } 8 | starknet.workspace = true 9 | 10 | [[target.starknet-contract]] 11 | build-external-contracts = ["cast_addition::AdditionContract"] 12 | 13 | [lib] 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/contracts/virtual_workspace/crates/cast_fibonacci/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use cast_addition::add; 2 | 3 | fn fib(a: felt252, b: felt252, n: felt252) -> felt252 { 4 | match n { 5 | 0 => a, 6 | _ => fib(b, add(a, b), n - 1), 7 | } 8 | } 9 | 10 | #[starknet::contract] 11 | mod FibonacciContract { 12 | use cast_addition::add; 13 | use cast_fibonacci::fib; 14 | 15 | #[storage] 16 | struct Storage {} 17 | 18 | #[external(v0)] 19 | fn answer(ref self: ContractState) -> felt252 { 20 | add(fib(0, 1, 16), fib(0, 1, 8)) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/files/pre_0.34.0_state_with_tx.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "transactions": [{ 4 | "123abc789": { 5 | "name": "declare", 6 | "output": { 7 | "type": "DeclareResponse", 8 | "class_hash": "0x123", 9 | "transaction_hash": "0x321" 10 | }, 11 | "status": "Success", 12 | "timestamp": 1706093159, 13 | "misc": null 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/files/state_corrupt_missing_field.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "transactions": { 4 | "123abc789": { 5 | "name": "declare", 6 | "output": { 7 | "class_hash": "0x123", 8 | "transaction_hash": "0x321" 9 | }, 10 | "status": "success", 11 | "misc": null 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/files/state_no_txs.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "transactions": null 4 | } 5 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/files/state_with_tx.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "transactions": [{ 4 | "123abc789": { 5 | "name": "declare", 6 | "output": { 7 | "type": "DeclareResponse", 8 | "status": "Success", 9 | "class_hash": "0x0000000000000000000000000000000000000000000000000000000000000123", 10 | "transaction_hash": "0x0000000000000000000000000000000000000000000000000000000000000321" 11 | }, 12 | "status": "Success", 13 | "timestamp": 1706093159, 14 | "misc": null 15 | } 16 | }] 17 | } 18 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/files/state_wrong_version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 0, 3 | "transactions": null 4 | } 5 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "open_zeppelin", 5 | "version": 1, 6 | "public_key": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a", 7 | "legacy": true 8 | }, 9 | "deployment": { 10 | "status": "deployed", 11 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 12 | "address": "0xcce3217e4aea0ab738b55446b1b378750edfca617db549fda1ede28435206c" 13 | } 14 | } -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account_argent_undeployed_happy_case.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "argent", 5 | "version": 1, 6 | "owner": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a", 7 | "guardian": "0x0" 8 | }, 9 | "deployment": { 10 | "status": "undeployed", 11 | "class_hash": "0x36078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f", 12 | "salt": "0x1924d8e7415bd440195fefa23a1ce71b106252109bdbc59e51afb9229f136f5" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account_invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "open_zeppelin", 5 | "version": 1, 6 | "public_key": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a" 7 | }, 8 | "deployment": { 9 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 10 | "salt": "0x14df438ac6825165c7a0af29decd5892528b763a333f93a5f6b12980dbddd9f" 11 | } 12 | } -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account_oz_undeployed_happy_case.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "open_zeppelin", 5 | "version": 1, 6 | "public_key": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a" 7 | }, 8 | "deployment": { 9 | "status": "undeployed", 10 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 11 | "salt": "0x14df438ac6825165c7a0af29decd5892528b763a333f93a5f6b12980dbddd9b" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account_undeployed.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "open_zeppelin", 5 | "version": 1, 6 | "public_key": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a" 7 | }, 8 | "deployment": { 9 | "status": "undeployed", 10 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 11 | "salt": "0x14df438ac6825165c7a0af29decd5892528b763a333f93a5f6b12980dbddd9f" 12 | } 13 | } -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/my_account_undeployed_happy_case_other_args.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "variant": { 4 | "type": "open_zeppelin", 5 | "version": 1, 6 | "public_key": "0xe2d3d7080bfc665e0060a06e8e95c3db3ff78a1fec4cc81ddc87e49a12e0a" 7 | }, 8 | "deployment": { 9 | "status": "undeployed", 10 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 11 | "salt": "0x14df438ac6825165c7a0af29decd5892528b763a333f93a5f6b12980dbddd9a" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/predeployed_account.json: -------------------------------------------------------------------------------- 1 | { 2 | "deployment": { 3 | "address": "0x4ee94bdf625820bc562c49c4d1ca4b2ef82bcfc5ed0cf67464770bea333b19a", 4 | "class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", 5 | "status": "deployed" 6 | }, 7 | "variant": { 8 | "public_key": "0xd39cc3278f855cb025b28409d16137792175638a8acec3b5b3d2487d2472a6", 9 | "type": "open_zeppelin", 10 | "version": 1 11 | }, 12 | "version": 1 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/keystore/predeployed_key.json: -------------------------------------------------------------------------------- 1 | { 2 | "crypto": { 3 | "cipher": "aes-128-ctr", 4 | "cipherparams": { "iv": "969dc1d196eccd96518b4945820a7ac0" }, 5 | "ciphertext": "fd20c0dfa110976bffa70b54321487c4546d0c26816c8383ffcfa1ba099f73b1", 6 | "kdf": "scrypt", 7 | "kdfparams": { 8 | "dklen": 32, 9 | "n": 8192, 10 | "p": 1, 11 | "r": 8, 12 | "salt": "177919634a458573cf15ee537f658cca630d32aaae1a3b7cecf86a427ef01ea9" 13 | }, 14 | "mac": "adada9c6d157999ba340dc99c6b6596698904026e3f619d025962d1cbcd2a50e" 15 | }, 16 | "id": "caf9c371-4e46-45c7-b682-a44667a83725", 17 | "version": 3 18 | } 19 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_invalid.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x1" 4 | inputs = [] 5 | id = "Map" 6 | unique = false 7 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_invoke.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x02a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321" 4 | inputs = [] 5 | id = "map_contract" 6 | unique = false 7 | 8 | [[call]] 9 | call_type = "invoke" 10 | contract_address = "0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008" 11 | function = "put" 12 | inputs = ["0x123", "234"] 13 | 14 | [[call]] 15 | call_type = "invoke" 16 | contract_address = "map_contract" 17 | function = "put" 18 | inputs = ["0x123", "234"] 19 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_invoke_calldata_ids.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x02a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321" 4 | inputs = [] 5 | id = "map_contract" 6 | unique = false 7 | 8 | [[call]] 9 | call_type = "invoke" 10 | contract_address = "0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008" 11 | function = "put" 12 | inputs = ["0x123", "map_contract"] 13 | 14 | [[call]] 15 | call_type = "deploy" 16 | class_hash = "0x059426c817fb8103edebdbf1712fa084c6744b2829db9c62d1ea4dce14ee6ded" 17 | inputs = ["map_contract", "0x1", "0x1"] 18 | id = "constructor-params" 19 | unique = false 20 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_invoke_numeric_inputs.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x02a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321" 4 | inputs = [] 5 | id = "map_contract" 6 | unique = false 7 | 8 | [[call]] 9 | call_type = "invoke" 10 | contract_address = "0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008" 11 | function = "put" 12 | inputs = [0x123, 234] 13 | 14 | [[call]] 15 | call_type = "invoke" 16 | contract_address = "map_contract" 17 | function = "put" 18 | inputs = [0x123, 9223372036854775807] 19 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_invoke_numeric_overflow.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x02a09379665a749e609b4a8459c86fe954566a6beeaddd0950e43f6c700ed321" 4 | inputs = [] 5 | id = "map_contract" 6 | unique = false 7 | 8 | [[call]] 9 | call_type = "invoke" 10 | contract_address = "0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008" 11 | function = "put" 12 | inputs = [0x123, 9223372036854775808] 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/deploy_succ_invoke_fail.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "deploy" 3 | class_hash = "0x7644be7f58307726aa836e945edede13e9e08c38eaf2186d4d48eca7dd435ac" 4 | inputs = [] 5 | id = "Map" 6 | unique = false 7 | 8 | [[call]] 9 | call_type = "invoke" 10 | contract_address = "0x1" 11 | function = "put" 12 | inputs = ["0x123", "234"] 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/multicall_configs/invoke_invalid.toml: -------------------------------------------------------------------------------- 1 | [[call]] 2 | call_type = "invoke" 3 | contract_address = "0x1" 4 | function = "put" 5 | inputs = ["123", "234"] 6 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/call/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "call_test_scripts" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/call/src/invalid_address.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{call, CallResult, ScriptCommandError, ProviderError, StarknetError}; 2 | 3 | fn main() { 4 | let eth = 0x049; 5 | let call_err: ScriptCommandError = call( 6 | eth.try_into().expect('bad address'), selector!("decimals"), array![], 7 | ) 8 | .unwrap_err(); 9 | 10 | println!("{:?}", call_err); 11 | 12 | assert( 13 | ScriptCommandError::ProviderError( 14 | ProviderError::StarknetError(StarknetError::ContractNotFound), 15 | ) == call_err, 16 | 'ohno', 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/call/src/invalid_entry_point.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{call, CallResult, ScriptCommandError, ProviderError, StarknetError, ErrorData}; 2 | 3 | fn main() { 4 | let eth = 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7; 5 | let call_err: ScriptCommandError = call( 6 | eth.try_into().expect('bad address'), selector!("gimme_money"), array![], 7 | ) 8 | .unwrap_err(); 9 | 10 | println!("{:?}", call_err); 11 | } 12 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/call/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod invalid_entry_point; 2 | mod invalid_address; 3 | mod invalid_calldata; 4 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/declare/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "declare_test_scripts" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | map1 = { path = "../map_script/contracts" } 10 | 11 | [lib] 12 | sierra = true 13 | casm = true 14 | 15 | [[target.starknet-contract]] 16 | build-external-contracts = ["map1::Mapa"] 17 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/declare/src/fee_settings.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{ 2 | get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, 3 | FeeSettingsTrait, 4 | }; 5 | 6 | fn main() { 7 | let fee_settings = FeeSettingsTrait::resource_bounds( 8 | 100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000, 9 | ); 10 | let declare_nonce = get_nonce('latest'); 11 | declare("Mapa", fee_settings, Option::Some(declare_nonce)).expect('declare failed'); 12 | println!("success"); 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/declare/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod no_contract; 2 | mod same_contract_twice; 3 | mod with_invalid_max_fee; 4 | mod with_invalid_nonce; 5 | mod insufficient_account_balance; 6 | mod time_out; 7 | mod fee_settings; 8 | 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/declare/src/no_contract.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{ 2 | declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, FeeSettingsTrait, 3 | }; 4 | 5 | fn main() { 6 | let fee_settings = FeeSettingsTrait::estimate(); 7 | let declare_result = declare("Mapaaaa", fee_settings, Option::None).unwrap_err(); 8 | println!("{:?}", declare_result); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/declare/src/time_out.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{ 2 | get_nonce, declare, DeclareResult, ScriptCommandError, ProviderError, StarknetError, 3 | FeeSettingsTrait, 4 | }; 5 | 6 | fn main() { 7 | let fee_settings = FeeSettingsTrait::resource_bounds( 8 | 100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000, 9 | ); 10 | let declare_nonce = get_nonce('latest'); 11 | let declare_result = declare("Mapa", fee_settings, Option::Some(declare_nonce)).unwrap_err(); 12 | 13 | println!("{:?}", declare_result); 14 | } 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/deploy/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deploy_test_scripts" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.4.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | 10 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/deploy/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod with_calldata; 2 | mod same_class_hash_and_salt; 3 | mod invalid_class_hash; 4 | mod invalid_calldata; 5 | mod invalid_nonce; 6 | mod fee_settings; 7 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/invoke/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "invoke_script" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | 10 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/invoke/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod contract_does_not_exist; 2 | mod max_fee_too_low; 3 | mod wrong_calldata; 4 | mod wrong_function_name; 5 | 6 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/map_script/contracts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "map1" 3 | version = "0.2.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.4.0" 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | sierra = false 13 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "map_script" 3 | version = "0.1.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../../sncast_std" } 9 | map1 = { path = "../contracts" } 10 | 11 | [lib] 12 | sierra = true 13 | casm = true 14 | 15 | [[target.starknet-contract]] 16 | build-external-contracts = ["map1::Mapa", "map1::Mapa2"] 17 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/map_script/scripts/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod map_script; 2 | mod display_debug_traits_for_subcommand_responses; 3 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/misc/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "misc_script" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/misc/src/call_fail.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{call, CallResult}; 2 | 3 | fn main() { 4 | let strk = 0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d; 5 | let call_result = call(strk.try_into().unwrap(), selector!("gimme_money"), array![]); 6 | call_result.expect('call failed'); 7 | } 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/misc/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod call_happy; 2 | mod call_fail; 3 | mod using_starknet_syscall; 4 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/misc/src/using_starknet_syscall.cairo: -------------------------------------------------------------------------------- 1 | use starknet::get_execution_info; 2 | use core::box::BoxTrait; 3 | 4 | fn main() { 5 | let exec_info = get_execution_info().unbox(); 6 | assert(1 == 2, 'unreachable'); 7 | } 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/missing_field/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "missing_field_script" 3 | version = "0.1.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/missing_field/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod missing_field; 2 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/missing_field/src/missing_field.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{declare, DeclareResult}; 2 | 3 | fn main() { 4 | let declare_result = declare("Mapa", max_fee: Option::None); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/old_sncast_std/scripts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "old_sncast_std" 3 | version = "0.1.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.13.1" } 9 | 10 | [lib] 11 | sierra = true 12 | casm = true 13 | 14 | [[target.starknet-contract]] 15 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/old_sncast_std/scripts/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod map_script; 2 | 3 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/old_sncast_std/scripts/src/map_script.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{ 2 | declare, deploy, invoke, call, DeclareResult, DeployResult, InvokeResult, CallResult, get_nonce, 3 | }; 4 | 5 | fn main() {} 6 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/packages/Scarb.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "crates/scripts/*", 4 | ] 5 | 6 | [workspace.package] 7 | version = "0.1.0" 8 | 9 | [workspace.dependencies] 10 | starknet = "2.4.0" 11 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/packages/crates/scripts/script1/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "script1" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/packages/crates/scripts/script1/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::get_nonce; 2 | 3 | fn main() { 4 | get_nonce('latest'); 5 | } 6 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/packages/crates/scripts/script2/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "script2" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/packages/crates/scripts/script2/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{declare, DeclareResult}; 2 | 3 | fn main() { 4 | declare("whatever", Option::None, Option::None); 5 | } 6 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_file/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "state_file_test_script" 3 | version = "0.1.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.3.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_file/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod all_tx_fail; 2 | mod rerun_failed_tx; 3 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_file/src/rerun_failed_tx.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{invoke, FeeSettingsTrait}; 2 | 3 | fn main() { 4 | let fee_settings = FeeSettingsTrait::resource_bounds( 5 | 100000, 10000000000000, 1000000000, 100000000000000000000, 100000, 10000000000000, 6 | ); 7 | let map_contract_address = 0xcd8f9ab31324bb93251837e4efb4223ee195454f6304fcfcb277e277653008 8 | .try_into() 9 | .expect('Invalid contract address value'); 10 | 11 | invoke(map_contract_address, selector!("put"), array![0x10, 0x1], fee_settings, Option::None) 12 | .unwrap(); 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_script/contracts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "state" 3 | version = "0.2.0" 4 | edition = "2023_11" 5 | 6 | [dependencies] 7 | starknet = ">=2.4.0" 8 | 9 | [[target.starknet-contract]] 10 | 11 | [lib] 12 | sierra = false 13 | 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_script/scripts/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "state_script" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.4.0" 8 | sncast_std = { path = "../../../../../../../sncast_std" } 9 | state = { path = "../contracts" } 10 | 11 | [lib] 12 | sierra = true 13 | casm = true 14 | 15 | [[target.starknet-contract]] 16 | build-external-contracts = [ 17 | "state::State" 18 | ] 19 | 20 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/state_script/scripts/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod state_script; 2 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/tx_status/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tx_status_test_scripts" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = ">=2.4.0" 8 | sncast_std = { path = "../../../../../../sncast_std" } 9 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/tx_status/src/incorrect_transaction_hash.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{tx_status, ScriptCommandError, ProviderError, StarknetError}; 2 | 3 | fn main() { 4 | let incorrect_tx_hash = 0x1; 5 | let status = tx_status(incorrect_tx_hash).unwrap_err(); 6 | println!("{:?}", status); 7 | 8 | assert!( 9 | ScriptCommandError::ProviderError( 10 | ProviderError::StarknetError(StarknetError::TransactionHashNotFound(())), 11 | ) == status, 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/tx_status/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod incorrect_transaction_hash; 2 | mod status_reverted; 3 | mod status_succeeded; 4 | -------------------------------------------------------------------------------- /crates/sncast/tests/data/scripts/tx_status/src/status_succeeded.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{tx_status, TxStatusResult, ExecutionStatus, FinalityStatus}; 2 | 3 | fn main() { 4 | let succeeded_tx_hash = 0x07d2067cd7675f88493a9d773b456c8d941457ecc2f6201d2fe6b0607daadfd1; 5 | let status = tx_status(succeeded_tx_hash).unwrap(); 6 | 7 | println!("{}", status); 8 | println!("{:?}", status); 9 | 10 | assert!( 11 | TxStatusResult { 12 | finality_status: FinalityStatus::AcceptedOnL1, 13 | execution_status: Option::Some(ExecutionStatus::Succeeded), 14 | } == status, 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /crates/sncast/tests/docs_snippets/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod validation; 2 | -------------------------------------------------------------------------------- /crates/sncast/tests/e2e/account/mod.rs: -------------------------------------------------------------------------------- 1 | mod create; 2 | mod delete; 3 | mod deploy; 4 | mod helpers; 5 | mod import; 6 | mod list; 7 | -------------------------------------------------------------------------------- /crates/sncast/tests/e2e/mod.rs: -------------------------------------------------------------------------------- 1 | mod account; 2 | mod call; 3 | mod completions; 4 | mod declare; 5 | mod deploy; 6 | mod fee; 7 | mod invoke; 8 | mod main_tests; 9 | mod multicall; 10 | mod script; 11 | mod show_config; 12 | mod tx_status; 13 | mod verify; 14 | -------------------------------------------------------------------------------- /crates/sncast/tests/e2e/multicall/mod.rs: -------------------------------------------------------------------------------- 1 | mod new; 2 | mod run; 3 | -------------------------------------------------------------------------------- /crates/sncast/tests/e2e/script/mod.rs: -------------------------------------------------------------------------------- 1 | mod call; 2 | mod declare; 3 | mod deploy; 4 | mod general; 5 | mod init; 6 | mod invoke; 7 | mod tx_status; 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/e2e/verify/mod.rs: -------------------------------------------------------------------------------- 1 | mod walnut; 2 | -------------------------------------------------------------------------------- /crates/sncast/tests/helpers/fee.rs: -------------------------------------------------------------------------------- 1 | const TEST_RESOURCE_BOUNDS_FLAGS: [&str; 12] = [ 2 | "--l1-gas", 3 | "100000", 4 | "--l1-gas-price", 5 | "10000000000000", 6 | "--l2-gas", 7 | "1000000000", 8 | "--l2-gas-price", 9 | "100000000000000000000", 10 | "--l1-data-gas", 11 | "100000", 12 | "--l1-data-gas-price", 13 | "10000000000000", 14 | ]; 15 | 16 | #[must_use] 17 | pub fn apply_test_resource_bounds_flags(mut args: Vec<&str>) -> Vec<&str> { 18 | args.extend(TEST_RESOURCE_BOUNDS_FLAGS); 19 | args 20 | } 21 | -------------------------------------------------------------------------------- /crates/sncast/tests/helpers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod constants; 2 | pub mod devnet; 3 | pub mod env; 4 | pub mod fee; 5 | pub mod fixtures; 6 | pub mod runner; 7 | pub mod shell; 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/helpers/runner.rs: -------------------------------------------------------------------------------- 1 | use snapbox::cmd::{Command, cargo_bin}; 2 | 3 | #[must_use] 4 | pub fn runner(args: &[&str]) -> Command { 5 | let command = Command::new(cargo_bin!("sncast")).args(args); 6 | command 7 | } 8 | -------------------------------------------------------------------------------- /crates/sncast/tests/helpers/shell.rs: -------------------------------------------------------------------------------- 1 | use camino::Utf8PathBuf; 2 | use snapbox::cmd::Command; 3 | 4 | #[must_use] 5 | pub fn os_specific_shell(script_path: &Utf8PathBuf) -> Command { 6 | let script_extension = if cfg!(windows) { "ps1" } else { "sh" }; 7 | let test_path = script_path.with_extension(script_extension); 8 | let absolute_test_path = test_path.canonicalize_utf8().unwrap(); 9 | 10 | if cfg!(windows) { 11 | Command::new("powershell") 12 | .arg("-ExecutionPolicy") 13 | .arg("Bypass") 14 | .arg("-File") 15 | .arg(absolute_test_path) 16 | } else { 17 | Command::new(absolute_test_path) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/sncast/tests/integration/mod.rs: -------------------------------------------------------------------------------- 1 | mod fee; 2 | mod lib_tests; 3 | mod wait_for_tx; 4 | -------------------------------------------------------------------------------- /crates/sncast/tests/main.rs: -------------------------------------------------------------------------------- 1 | mod docs_snippets; 2 | mod e2e; 3 | pub mod helpers; 4 | mod integration; 5 | -------------------------------------------------------------------------------- /crates/sncast/tests/shell/call.ps1: -------------------------------------------------------------------------------- 1 | $CAST_BINARY = $args[0] 2 | $URL = $args[1] 3 | $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA = $args[2] 4 | & $CAST_BINARY ` 5 | --int-format ` 6 | --json ` 7 | call ` 8 | --url $URL ` 9 | --contract-address $DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA ` 10 | --function complex_fn ` 11 | --arguments @' 12 | array![array![1, 2], array![3, 4, 5], array![6]], 13 | 12, 14 | -128_i8, 15 | \"Some string (a ByteArray)\", 16 | ('a shortstring', 32_u32), 17 | true, 18 | 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 19 | '@ 20 | -------------------------------------------------------------------------------- /crates/sncast/tests/shell/call.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CAST_BINARY="$1" 4 | URL="$2" 5 | DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA="$3" 6 | 7 | $CAST_BINARY \ 8 | --int-format \ 9 | --json \ 10 | call \ 11 | --url \ 12 | "$URL" \ 13 | --contract-address \ 14 | "$DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA" \ 15 | --function \ 16 | complex_fn \ 17 | --arguments 'array![array![1, 2], array![3, 4, 5], array![6]],'\ 18 | '12,'\ 19 | '-128_i8,'\ 20 | '"Some string (a ByteArray)",'\ 21 | "('a shortstring', 32_u32),"\ 22 | 'true,'\ 23 | '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' 24 | -------------------------------------------------------------------------------- /crates/sncast/tests/shell/call_unsigned.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CAST_BINARY="$1" 4 | URL="$2" 5 | DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA="$3" 6 | 7 | $CAST_BINARY \ 8 | --int-format \ 9 | --json \ 10 | call \ 11 | --url \ 12 | "$URL" \ 13 | --contract-address \ 14 | "$DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA" \ 15 | --function \ 16 | multiple_signed_fn \ 17 | --arguments '-3_i32, -4' 18 | -------------------------------------------------------------------------------- /crates/sncast/tests/shell/deploy.ps1: -------------------------------------------------------------------------------- 1 | $CAST_BINARY = $args[0] 2 | $URL = $args[1] 3 | $CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA = $args[2] 4 | & $CAST_BINARY ` 5 | --accounts-file accounts.json ` 6 | --account my_account ` 7 | --int-format ` 8 | --json ` 9 | deploy ` 10 | --url $URL ` 11 | --class-hash $CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA ` 12 | --arguments '0x420, 0x2137_u256' ` 13 | --max-fee 99999999999999999 ` 14 | -------------------------------------------------------------------------------- /crates/snforge-scarb-plugin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "snforge_scarb_plugin" 3 | version = "0.44.0" 4 | edition = "2021" 5 | publish = false 6 | rust-version = "1.80.1" 7 | 8 | [lib] 9 | crate-type = ["rlib", "cdylib"] 10 | 11 | [dependencies] 12 | cairo-lang-macro = "=0.1.0" 13 | cairo-lang-parser = "=2.10.1" 14 | cairo-lang-utils = "=2.10.1" 15 | cairo-lang-syntax = "=2.10.1" 16 | url = "=2.5.4" 17 | indoc = "=2.0.5" 18 | smol_str = "=0.2.2" 19 | num-bigint = "=0.4.6" 20 | 21 | [dev-dependencies] 22 | cairo-lang-formatter = "=2.10.0" 23 | -------------------------------------------------------------------------------- /crates/snforge-scarb-plugin/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "snforge_scarb_plugin" 3 | version = "0.44.0" 4 | edition = "2024_07" 5 | include = ["target/scarb/cairo-plugin/"] 6 | 7 | [cairo-plugin] 8 | -------------------------------------------------------------------------------- /crates/snforge-scarb-plugin/src/asserts.rs: -------------------------------------------------------------------------------- 1 | use crate::attributes::{AttributeInfo, ErrorExt}; 2 | use cairo_lang_macro::Diagnostic; 3 | use cairo_lang_syntax::node::{ast::FunctionWithBody, db::SyntaxGroup, helpers::QueryAttrs}; 4 | 5 | pub fn assert_is_used_once( 6 | db: &dyn SyntaxGroup, 7 | func: &FunctionWithBody, 8 | ) -> Result<(), Diagnostic> { 9 | if func.attributes(db).has_attr(db, T::ATTR_NAME) { 10 | Err(T::error("can only be used once per item")) 11 | } else { 12 | Ok(()) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/snforge-scarb-plugin/tests/integration/main.rs: -------------------------------------------------------------------------------- 1 | mod multiple_attributes; 2 | mod single_attributes; 3 | mod utils; 4 | -------------------------------------------------------------------------------- /crates/snforge-scarb-plugin/tests/integration/single_attributes.rs: -------------------------------------------------------------------------------- 1 | mod available_gas; 2 | mod disable_predeployed_contracts; 3 | mod fork; 4 | mod fuzzer; 5 | mod ignore; 6 | mod internal_config_statement; 7 | mod should_panic; 8 | mod test; 9 | -------------------------------------------------------------------------------- /crates/testing/packages_validation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "packages_validation" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [lib] 7 | 8 | [dependencies] 9 | camino.workspace = true 10 | scarb-api = { path = "../../scarb-api" } 11 | project-root.workspace = true 12 | 13 | [dev-dependencies] 14 | test-case.workspace = true 15 | 16 | [features] 17 | scarb_since_2_10 = [] 18 | -------------------------------------------------------------------------------- /crates/universal-sierra-compiler-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "universal-sierra-compiler-api" 3 | version = "1.0.0" 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | anyhow.workspace = true 8 | shared.workspace = true 9 | serde.workspace = true 10 | serde_json.workspace = true 11 | which.workspace = true 12 | tempfile.workspace = true 13 | num-bigint.workspace = true 14 | cairo-lang-casm.workspace = true 15 | camino.workspace = true 16 | -------------------------------------------------------------------------------- /design_documents/state_forking/new_CheatnetState_interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/design_documents/state_forking/new_CheatnetState_interface.png -------------------------------------------------------------------------------- /design_documents/state_forking/read_state_flow_diag.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/design_documents/state_forking/read_state_flow_diag.jpg -------------------------------------------------------------------------------- /design_documents/state_forking/state_forking_arch_diag.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/design_documents/state_forking/state_forking_arch_diag.jpg -------------------------------------------------------------------------------- /design_documents/transactional_testing/txn_based_testing_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/design_documents/transactional_testing/txn_based_testing_arch.png -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Starknet Foundry Book 2 | 3 | ## Installation 4 | 5 | Install mdBook 6 | 7 | ```shell 8 | $ cargo install mdbook 9 | ``` 10 | 11 | ## Building 12 | 13 | ```shell 14 | $ mdbook build 15 | ``` 16 | 17 | ## Open preview and reload on every change 18 | 19 | ```shell 20 | $ mdbook serve 21 | ``` -------------------------------------------------------------------------------- /docs/example_workflows/basic_workflow.yml: -------------------------------------------------------------------------------- 1 | name: My workflow 2 | on: 3 | push: 4 | pull_request: 5 | jobs: 6 | check: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | 11 | - name: Setup Starknet Foundry 12 | uses: foundry-rs/setup-snfoundry@v3 13 | 14 | - name: Setup Scarb 15 | uses: software-mansion/setup-scarb@v1 16 | with: 17 | scarb-lock: ./hello_starknet/Scarb.lock 18 | 19 | - name: Run tests 20 | run: cd hello_starknet && snforge test 21 | -------------------------------------------------------------------------------- /docs/listings/basic_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | snforge_std = { path = "../../../snforge_std" } 11 | sncast_std = { path = "../../../sncast_std" } 12 | 13 | [[target.lib]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/basic_example/src/basic_example.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::call; 2 | 3 | // A real contract deployed on Sepolia network 4 | const CONTRACT_ADDRESS: felt252 = 5 | 0x07e867f1fa6da2108dd2b3d534f1fbec411c5ec9504eb3baa1e49c7a0bef5ab5; 6 | 7 | fn main() { 8 | let call_result = call( 9 | CONTRACT_ADDRESS.try_into().unwrap(), selector!("get_greeting"), array![], 10 | ) 11 | .expect('call failed'); 12 | 13 | assert(*call_result.data[1] == 'Hello, Starknet!', *call_result.data[1]); 14 | 15 | println!("{:?}", call_result); 16 | } 17 | -------------------------------------------------------------------------------- /docs/listings/basic_example/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod basic_example; 2 | -------------------------------------------------------------------------------- /docs/listings/call/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "call" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | sncast_std = { path = "../../../sncast_std" } 9 | snforge_std = { path = "../../../snforge_std" } 10 | 11 | [[target.lib]] 12 | sierra = true 13 | 14 | [scripts] 15 | test = "snforge test" 16 | -------------------------------------------------------------------------------- /docs/listings/call/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::call; 2 | use starknet::ContractAddress; 3 | 4 | fn main() { 5 | let contract_address: ContractAddress = 6 | 0x1e52f6ebc3e594d2a6dc2a0d7d193cb50144cfdfb7fdd9519135c29b67e427 7 | .try_into() 8 | .expect('Invalid contract address value'); 9 | 10 | let result = call(contract_address, selector!("get"), array![0x1]).expect('call failed'); 11 | 12 | println!("call result: {}", result); 13 | println!("debug call result: {:?}", result); 14 | } 15 | -------------------------------------------------------------------------------- /docs/listings/conditional_compilation/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "conditional_compilation" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [features] 7 | default = ["enable_for_tests"] 8 | enable_for_tests = [] 9 | 10 | [dependencies] 11 | starknet = "2.8.5" 12 | assert_macros = "2.8.5" 13 | 14 | [dev-dependencies] 15 | snforge_std = { path = "../../../snforge_std" } 16 | 17 | [[target.starknet-contract]] 18 | sierra = true 19 | 20 | [scripts] 21 | test = "snforge test" 22 | -------------------------------------------------------------------------------- /docs/listings/conditional_compilation/src/contract.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | pub trait IMockContract { 3 | fn response(self: @TContractState) -> u32; 4 | } 5 | 6 | #[starknet::contract] 7 | #[cfg(feature: 'enable_for_tests')] 8 | mod MockContract { 9 | #[storage] 10 | struct Storage {} 11 | 12 | #[abi(embed_v0)] 13 | impl IMockContractImpl of super::IMockContract { 14 | fn response(self: @ContractState) -> u32 { 15 | 1 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/listings/conditional_compilation/src/function.cairo: -------------------------------------------------------------------------------- 1 | #[cfg(feature: 'enable_for_tests')] 2 | fn foo() -> u32 { 3 | 2 4 | } 5 | 6 | #[cfg(feature: 'enable_for_tests')] 7 | #[cfg(test)] 8 | mod tests { 9 | #[test] 10 | fn test_using_conditionally_compiled_function() { 11 | assert_eq!(foo(), 2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docs/listings/conditional_compilation/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | // pub mod function; // TODO: include this module (issue #2515) 3 | 4 | mod dummy {} // trick `scarb fmt -c` 5 | -------------------------------------------------------------------------------- /docs/listings/conditional_compilation/tests/test.cairo: -------------------------------------------------------------------------------- 1 | use snforge_std::{declare, ContractClassTrait, DeclareResultTrait}; 2 | 3 | use conditional_compilation::contract::{IMockContractDispatcher, IMockContractDispatcherTrait}; 4 | 5 | #[test] 6 | fn test_mock_contract() { 7 | let (contract_address, _) = declare("MockContract") 8 | .unwrap() 9 | .contract_class() 10 | .deploy(@array![]) 11 | .unwrap(); 12 | 13 | let dispatcher = IMockContractDispatcher { contract_address }; 14 | let response = dispatcher.response(); 15 | 16 | assert_eq!(response, 1); 17 | } 18 | -------------------------------------------------------------------------------- /docs/listings/declare/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "declare" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | sncast_std = { path = "../../../sncast_std" } 9 | snforge_std = { path = "../../../snforge_std" } 10 | 11 | [[target.starknet-contract]] 12 | sierra = true 13 | 14 | [[target.lib]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/declare/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{declare, FeeSettingsTrait}; 2 | 3 | fn main() { 4 | let fee_settings = FeeSettingsTrait::max_fee(9999999); 5 | 6 | let result = declare("HelloStarknet", fee_settings, Option::None).expect('declare failed'); 7 | 8 | println!("declare result: {}", result); 9 | println!("debug declare result: {:?}", result); 10 | } 11 | -------------------------------------------------------------------------------- /docs/listings/deploy/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deploy" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | sncast_std = { path = "../../../sncast_std" } 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.lib]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/detailed_resources_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "detailed_resources_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/detailed_resources_example/tests/test_contract.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_abc() { 3 | assert(1 == 1, 1); 4 | } 5 | 6 | #[test] 7 | fn test_failing() { 8 | assert(1 == 2, 'failing check'); 9 | } 10 | 11 | #[test] 12 | fn test_xyz() { 13 | assert(1 == 1, 1); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /docs/listings/direct_storage_access/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "direct_storage_access" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/direct_storage_access/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod felts_only; 2 | pub mod complex_structures; 3 | pub mod using_enums; 4 | -------------------------------------------------------------------------------- /docs/listings/direct_storage_access/tests/felts_only.cairo: -------------------------------------------------------------------------------- 1 | pub mod field; 2 | pub mod map_entry; 3 | -------------------------------------------------------------------------------- /docs/listings/direct_storage_access/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod felts_only; 2 | pub mod complex_structures; 3 | pub mod storage_address; 4 | pub mod using_storage_address_from_base; 5 | pub mod using_enums; 6 | -------------------------------------------------------------------------------- /docs/listings/direct_storage_access/tests/storage_address.cairo: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/listings/error_handling/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "error_handling" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | snforge_std = { path = "../../../snforge_std" } 10 | sncast_std = { path = "../../../sncast_std" } 11 | starknet = "2.8.5" 12 | assert_macros = "2.8.5" 13 | 14 | [[target.lib]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/error_handling/src/error_handling.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::call; 2 | 3 | // Some nonexistent contract 4 | const CONTRACT_ADDRESS: felt252 = 0x2137; 5 | 6 | fn main() { 7 | // This call fails 8 | let call_result = call( 9 | CONTRACT_ADDRESS.try_into().unwrap(), selector!("get_greeting"), array![], 10 | ); 11 | 12 | // Make some assertion 13 | assert!(call_result.is_err()); 14 | 15 | // Print the result error 16 | println!("Received error: {:?}", call_result.unwrap_err()); 17 | } 18 | -------------------------------------------------------------------------------- /docs/listings/error_handling/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod error_handling; 2 | -------------------------------------------------------------------------------- /docs/listings/failing_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "failing_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/failing_example/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_abc() { 3 | assert(1 == 1, 1); 4 | } 5 | 6 | #[test] 7 | fn test_failing() { 8 | assert(1 == 2, 'failing check'); 9 | } 10 | 11 | #[test] 12 | fn test_xyz() { 13 | assert(1 == 1, 1); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /docs/listings/first_test/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "first_test" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/first_test/src/lib.cairo: -------------------------------------------------------------------------------- 1 | fn sum(a: felt252, b: felt252) -> felt252 { 2 | return a + b; 3 | } 4 | 5 | #[cfg(test)] 6 | mod tests { 7 | use super::sum; 8 | 9 | #[test] 10 | fn test_sum() { 11 | assert(sum(2, 3) == 5, 'sum incorrect'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docs/listings/fork_testing/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fork_testing" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | 19 | [[tool.snforge.fork]] 20 | name = "SEPOLIA_LATEST" 21 | url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" 22 | block_id.tag = "latest" 23 | -------------------------------------------------------------------------------- /docs/listings/fork_testing/tests/explicit.cairo: -------------------------------------------------------------------------------- 1 | pub mod block_number; 2 | pub mod block_hash; 3 | pub mod block_tag; 4 | -------------------------------------------------------------------------------- /docs/listings/fork_testing/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod name; 2 | pub mod explicit; 3 | pub mod overridden_name; 4 | -------------------------------------------------------------------------------- /docs/listings/fork_testing/tests/name.cairo: -------------------------------------------------------------------------------- 1 | use fork_testing::{IPokemonGalleryDispatcher, IPokemonGalleryDispatcherTrait}; 2 | 3 | const CONTRACT_ADDRESS: felt252 = 4 | 0x0522dc7cbe288037382a02569af5a4169531053d284193623948eac8dd051716; 5 | 6 | #[test] 7 | #[fork("SEPOLIA_LATEST")] 8 | fn test_using_forked_state() { 9 | let dispatcher = IPokemonGalleryDispatcher { 10 | contract_address: CONTRACT_ADDRESS.try_into().unwrap(), 11 | }; 12 | 13 | dispatcher.like("Charizard"); 14 | let pokemon = dispatcher.pokemon("Charizard"); 15 | 16 | assert!(pokemon.is_some()); 17 | assert_eq!(pokemon.unwrap().likes, 1); 18 | } 19 | -------------------------------------------------------------------------------- /docs/listings/fork_testing/tests/overridden_name.cairo: -------------------------------------------------------------------------------- 1 | use fork_testing::{IPokemonGalleryDispatcher, IPokemonGalleryDispatcherTrait}; 2 | 3 | const CONTRACT_ADDRESS: felt252 = 4 | 0x0522dc7cbe288037382a02569af5a4169531053d284193623948eac8dd051716; 5 | 6 | #[test] 7 | #[fork("SEPOLIA_LATEST", block_number: 200000)] 8 | fn test_using_forked_state() { 9 | let dispatcher = IPokemonGalleryDispatcher { 10 | contract_address: CONTRACT_ADDRESS.try_into().unwrap(), 11 | }; 12 | 13 | dispatcher.like("Charizard"); 14 | let pokemon = dispatcher.pokemon("Charizard"); 15 | 16 | assert!(pokemon.is_some()); 17 | assert_eq!(pokemon.unwrap().likes, 1); 18 | } 19 | -------------------------------------------------------------------------------- /docs/listings/full_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "full_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | snforge_std = { path = "../../../snforge_std" } 10 | sncast_std = { path = "../../../sncast_std" } 11 | map3 = { path = "../map3" } 12 | 13 | [[target.starknet-contract]] 14 | build-external-contracts = ["map3::MapContract"] 15 | 16 | [[target.lib]] 17 | sierra = true 18 | 19 | [scripts] 20 | test = "snforge test" 21 | -------------------------------------------------------------------------------- /docs/listings/full_example/src/lib.cairo: -------------------------------------------------------------------------------- 1 | mod full_example; 2 | -------------------------------------------------------------------------------- /docs/listings/fuzz_testing/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fuzz_testing" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.lib]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/fuzz_testing/src/basic_example.cairo: -------------------------------------------------------------------------------- 1 | fn sum(a: felt252, b: felt252) -> felt252 { 2 | return a + b; 3 | } 4 | 5 | #[cfg(test)] 6 | mod tests { 7 | use super::sum; 8 | 9 | #[test] 10 | #[fuzzer] 11 | fn test_sum(x: felt252, y: felt252) { 12 | assert_eq!(sum(x, y), x + y); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/listings/fuzz_testing/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod basic_example; 2 | pub mod with_parameters; 3 | -------------------------------------------------------------------------------- /docs/listings/fuzz_testing/src/with_parameters.cairo: -------------------------------------------------------------------------------- 1 | fn sum(a: felt252, b: felt252) -> felt252 { 2 | return a + b; 3 | } 4 | 5 | #[cfg(test)] 6 | mod tests { 7 | use super::sum; 8 | 9 | #[test] 10 | #[fuzzer(runs: 22, seed: 38)] 11 | fn test_sum(x: felt252, y: felt252) { 12 | assert_eq!(sum(x, y), x + y); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/listings/get_nonce/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "get_nonce" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | snforge_std = { path = "../../../snforge_std" } 9 | sncast_std = { path = "../../../sncast_std" } 10 | 11 | [[target.starknet-contract]] 12 | sierra = true 13 | 14 | [scripts] 15 | test = "snforge test" 16 | -------------------------------------------------------------------------------- /docs/listings/get_nonce/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::get_nonce; 2 | 3 | fn main() { 4 | let nonce = get_nonce('latest'); 5 | println!("nonce: {}", nonce); 6 | println!("debug nonce: {:?}", nonce); 7 | } 8 | -------------------------------------------------------------------------------- /docs/listings/hello_sncast/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_sncast" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | sncast_std = { path = "../../../sncast_std" } 11 | 12 | [dev-dependencies] 13 | snforge_std = { path = "../../../snforge_std" } 14 | 15 | [[target.starknet-contract]] 16 | sierra = true 17 | 18 | [scripts] 19 | test = "snforge test" 20 | -------------------------------------------------------------------------------- /docs/listings/hello_sncast/accounts.json: -------------------------------------------------------------------------------- 1 | { 2 | "alpha-sepolia": { 3 | "my_account": { 4 | "address": "0x6f4621e7ad43707b3f69f9df49425c3d94fdc5ab2e444bfa0e7e4edeff7992d", 5 | "deployed": true, 6 | "private_key": "0x0000000000000000000000000000000056c12e097e49ea382ca8eadec0839401", 7 | "public_key": "0x048234b9bc6c1e749f4b908d310d8c53dae6564110b05ccf79016dca8ce7dfac", 8 | "type": "open_zeppelin" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /docs/listings/hello_sncast/snfoundry.toml: -------------------------------------------------------------------------------- 1 | [sncast.default] 2 | account = "my_account" 3 | accounts-file = "accounts.json" 4 | url = "http://127.0.0.1:5055/rpc" 5 | 6 | [sncast.myprofile] 7 | account = "my_account" 8 | accounts-file = "accounts.json" 9 | url = "http://127.0.0.1:5055/rpc" 10 | -------------------------------------------------------------------------------- /docs/listings/hello_sncast/src/constructor_contract.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | pub mod ConstructorContract { 3 | #[storage] 4 | struct Storage {} 5 | 6 | #[constructor] 7 | fn constructor(ref self: ContractState, x: felt252, y: felt252, z: felt252) {} 8 | } 9 | -------------------------------------------------------------------------------- /docs/listings/hello_sncast/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod hello_sncast; 2 | pub mod data_transformer_contract; 3 | pub mod constructor_contract; 4 | -------------------------------------------------------------------------------- /docs/listings/hello_snforge/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_snforge" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/hello_snforge/tests/test_contract.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_executing() { 3 | assert(1 == 1, 1); 4 | } 5 | 6 | #[test] 7 | fn test_calling() { 8 | assert(2 == 2, 2); 9 | } 10 | 11 | #[test] 12 | fn test_calling_another() { 13 | assert(3 == 3, 3); 14 | } 15 | -------------------------------------------------------------------------------- /docs/listings/hello_starknet/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_starknet" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html 7 | 8 | [dependencies] 9 | starknet = "2.8.5" 10 | 11 | [dev-dependencies] 12 | snforge_std = { path = "../../../snforge_std" } 13 | 14 | [[target.starknet-contract]] 15 | sierra = true 16 | 17 | [scripts] 18 | test = "snforge test" 19 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/addition/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "addition" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std.workspace = true 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [lib] 16 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/addition/tests/nested.cairo: -------------------------------------------------------------------------------- 1 | use snforge_std::declare; 2 | 3 | mod test_nested; 4 | 5 | fn foo() -> u8 { 6 | 2 7 | } 8 | 9 | #[test] 10 | fn simple_case() { 11 | assert(1 == 1, 'simple check'); 12 | } 13 | 14 | #[test] 15 | fn contract_test() { 16 | declare("AdditionContract").unwrap(); 17 | } 18 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/addition/tests/nested/test_nested.cairo: -------------------------------------------------------------------------------- 1 | use super::foo; 2 | 3 | #[test] 4 | fn test_two() { 5 | assert(foo() == 2, 'foo() == 2'); 6 | } 7 | 8 | #[test] 9 | fn test_two_and_two() { 10 | assert(2 == 2, '2 == 2'); 11 | assert(2 == 2, '2 == 2'); 12 | } 13 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/fibonacci/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fibonacci" 3 | version.workspace = true 4 | edition = "2024_07" 5 | 6 | [scripts] 7 | test.workspace = true 8 | 9 | [tool] 10 | snforge.workspace = true 11 | 12 | [dependencies] 13 | addition = { path = "../addition" } 14 | starknet = "2.8.5" 15 | 16 | [dev-dependencies] 17 | snforge_std.workspace = true 18 | 19 | [[target.starknet-contract]] 20 | sierra = true 21 | build-external-contracts = ["addition::AdditionContract"] 22 | 23 | [lib] 24 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/fibonacci/tests/abc.cairo: -------------------------------------------------------------------------------- 1 | mod efg; 2 | 3 | #[test] 4 | fn abc_test() { 5 | assert(foo() == 1, ''); 6 | } 7 | 8 | pub fn foo() -> u8 { 9 | 1 10 | } 11 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/fibonacci/tests/abc/efg.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn efg_test() { 3 | assert(super::foo() == 1, ''); 4 | } 5 | 6 | #[test] 7 | fn failing_test() { 8 | assert(1 == 2, ''); 9 | } 10 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/fibonacci/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | mod abc; 2 | 3 | #[test] 4 | fn lib_test() { 5 | assert(abc::foo() == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/crates/fibonacci/tests/not_collected.cairo: -------------------------------------------------------------------------------- 1 | // should not be collected 2 | 3 | #[test] 4 | fn not_collected() { 5 | assert(1 == 1, ''); 6 | } 7 | -------------------------------------------------------------------------------- /docs/listings/hello_workspaces/tests/test_failing.cairo: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_failing() { 3 | assert(1 == 2, 'failing check'); 4 | } 5 | 6 | #[test] 7 | fn test_another_failing() { 8 | assert(2 == 3, 'failing check'); 9 | } 10 | -------------------------------------------------------------------------------- /docs/listings/ignoring_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ignoring_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/ignoring_example/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | #[ignore] 5 | fn ignored_test() { // test code 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /docs/listings/invoke/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "invoke" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | snforge_std = { path = "../../../snforge_std" } 9 | sncast_std = { path = "../../../sncast_std" } 10 | 11 | [[target.starknet-contract]] 12 | sierra = true 13 | 14 | [scripts] 15 | test = "snforge test" 16 | -------------------------------------------------------------------------------- /docs/listings/invoke/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use starknet::ContractAddress; 2 | use sncast_std::{invoke, FeeSettingsTrait}; 3 | 4 | fn main() { 5 | let contract_address: ContractAddress = 6 | 0x1e52f6ebc3e594d2a6dc2a0d7d193cb50144cfdfb7fdd9519135c29b67e427 7 | .try_into() 8 | .expect('Invalid contract address value'); 9 | let fee_settings = FeeSettingsTrait::estimate(); 10 | 11 | let result = invoke( 12 | contract_address, selector!("put"), array![0x1, 0x2], fee_settings, Option::None, 13 | ) 14 | .expect('invoke failed'); 15 | 16 | println!("invoke result: {}", result); 17 | println!("debug invoke result: {:?}", result); 18 | } 19 | -------------------------------------------------------------------------------- /docs/listings/map3/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "map3" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [[target.starknet-contract]] 7 | sierra = true 8 | 9 | [[target.lib]] 10 | sierra = false 11 | 12 | [dependencies] 13 | snforge_std = { path = "../../../snforge_std" } 14 | starknet = "2.8.5" 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/map3/snfoundry.toml: -------------------------------------------------------------------------------- 1 | [sncast.default] 2 | url = "http://127.0.0.1:5050/rpc" 3 | # [sncast.default] 4 | # url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" 5 | -------------------------------------------------------------------------------- /docs/listings/panicking_test/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "panicking_test" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/panicking_test/src/lib.cairo: -------------------------------------------------------------------------------- 1 | fn panicking_function() { 2 | let mut data = array![]; 3 | data.append('panic message'); 4 | panic(data) 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::panicking_function; 10 | 11 | #[test] 12 | fn failing() { 13 | panicking_function(); 14 | assert(2 == 2, '2 == 2'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/listings/should_panic_example/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "should_panic_example" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_contract_internals/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_contract_internals" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_contract_internals/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod basic_example; 2 | pub mod spying_for_events; 3 | pub mod using_library_calls; 4 | -------------------------------------------------------------------------------- /docs/listings/testing_contract_internals/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod mocking_the_context_info; 2 | pub mod spying_for_events; 3 | pub mod using_library_calls; 4 | -------------------------------------------------------------------------------- /docs/listings/testing_contract_internals/tests/spying_for_events.cairo: -------------------------------------------------------------------------------- 1 | pub mod tests; 2 | pub mod syscall_tests; 3 | -------------------------------------------------------------------------------- /docs/listings/testing_events/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_events" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_events/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod syscall; // syscall_dummy intentionally excluded 3 | -------------------------------------------------------------------------------- /docs/listings/testing_messages_to_l1/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_messages_to_l1" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_messages_to_l1/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | pub trait IMessageSender { 3 | fn greet_ethereum(ref self: TContractState, receiver: felt252); 4 | } 5 | 6 | #[starknet::contract] 7 | pub mod MessageSender { 8 | #[storage] 9 | struct Storage {} 10 | 11 | use starknet::syscalls::send_message_to_l1_syscall; 12 | 13 | #[external(v0)] 14 | pub fn greet_ethereum(ref self: ContractState, receiver: felt252) { 15 | let payload = array!['hello']; 16 | send_message_to_l1_syscall(receiver, payload.span()).unwrap(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/listings/testing_messages_to_l1/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod simple; 2 | pub mod detailed; 3 | -------------------------------------------------------------------------------- /docs/listings/testing_smart_contracts_handling_errors/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_smart_contracts_handling_errors" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_smart_contracts_safe_dispatcher/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_smart_contracts_safe_dispatcher" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/testing_smart_contracts_writing_tests/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testing_smart_contracts_writing_tests" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | 9 | [dev-dependencies] 10 | snforge_std = { path = "../../../snforge_std" } 11 | 12 | [[target.starknet-contract]] 13 | sierra = true 14 | 15 | [scripts] 16 | test = "snforge test" 17 | -------------------------------------------------------------------------------- /docs/listings/tx_status/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tx_status" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | snforge_std = { path = "../../../snforge_std" } 9 | sncast_std = { path = "../../../sncast_std" } 10 | 11 | [[target.starknet-contract]] 12 | sierra = true 13 | 14 | [scripts] 15 | test = "snforge test" 16 | -------------------------------------------------------------------------------- /docs/listings/tx_status/src/lib.cairo: -------------------------------------------------------------------------------- 1 | use sncast_std::{tx_status}; 2 | 3 | fn main() { 4 | let transaction_hash = 0x00ae35dacba17cde62b8ceb12e3b18f4ab6e103fa2d5e3d9821cb9dc59d59a3c; 5 | let status = tx_status(transaction_hash).expect('Failed to get status'); 6 | 7 | println!("transaction status: {:?}", status); 8 | } 9 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "using_cheatcodes" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes_cancelling_cheat/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "using_cheatcodes_cancelling_cheat" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes_cheat_address/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "using_cheatcodes_cheat_address" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes_others/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "using_cheatcodes_others" 3 | version = "0.1.0" 4 | edition = "2024_07" 5 | 6 | [dependencies] 7 | starknet = "2.8.5" 8 | assert_macros = "2.8.5" 9 | 10 | [dev-dependencies] 11 | snforge_std = { path = "../../../snforge_std" } 12 | 13 | [[target.starknet-contract]] 14 | sierra = true 15 | 16 | [scripts] 17 | test = "snforge test" 18 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes_others/tests/caller_address.cairo: -------------------------------------------------------------------------------- 1 | pub mod proper_use_global; 2 | pub mod span; 3 | -------------------------------------------------------------------------------- /docs/listings/using_cheatcodes_others/tests/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod caller_address; 2 | pub mod cheat_constructor; 3 | pub mod set_balance_strk; 4 | pub mod set_balance_custom_token; 5 | -------------------------------------------------------------------------------- /docs/src/README.md: -------------------------------------------------------------------------------- 1 | logo 2 | 3 | # The Starknet Foundry 4 | 5 | Starknet Foundry is a toolchain for developing Starknet smart contracts. 6 | It helps with writing, deploying, and testing your smart contracts. 7 | It is inspired by Foundry. 8 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/cheat_span.md: -------------------------------------------------------------------------------- 1 | # `CheatSpan` 2 | 3 | ```rust 4 | enum CheatSpan { 5 | Indefinite: (), 6 | TargetCalls: usize 7 | } 8 | ``` 9 | 10 | `CheatSpan` is an enum used to specify for how long the target should be cheated for. 11 | - `Indefinite` applies the cheatcode indefinitely, until the cheat is canceled manually (e.g. using `stop_cheat_block_timestamp`). 12 | - `TargetCalls` applies the cheatcode for a specified number of calls to the target, after which the cheat is canceled (or until the cheat is canceled manually). 13 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/generate_arg.md: -------------------------------------------------------------------------------- 1 | # `generate_arg` 2 | 3 | > `fn generate_arg, +Drop, +Into>(min_value: T, max_value: T) -> T` 4 | 5 | Returns a random number from a range `[min_value, max_value]`. 6 | It is used in the context of fuzz testing to implement [`Fuzzable`](../snforge-library/fuzzable.md) trait. 7 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/generate_random_felt.md: -------------------------------------------------------------------------------- 1 | # `generate_random_felt` 2 | 3 | > `fn generate_random_felt() -> Felt252` 4 | 5 | Generates a (pseudo) random `Felt252` value. 6 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/get_class_hash.md: -------------------------------------------------------------------------------- 1 | # `get_class_hash` 2 | 3 | > `fn get_class_hash(contract_address: ContractAddress) -> ClassHash` 4 | 5 | Returns a class hash of a contract at the specified address. 6 | 7 | > 💡 **Tip** 8 | > 9 | > This cheatcode can be used to test if your contract upgrade procedure is correct 10 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/global.md: -------------------------------------------------------------------------------- 1 | # Cheating Globally 2 | 3 | Cheatcodes which have `_global` suffix allow to change specific properties in blockchain state for all targets and for indefinite time span. Therefore, you don't pass the target address, nor the span. 4 | 5 | See the [Cheating Addresses Globally](../../testing/using-cheatcodes.md#cheating-addresses-globally) example. 6 | 7 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/l1_handler.md: -------------------------------------------------------------------------------- 1 | # `l1_handler` 2 | 3 | > `fn new(target: ContractAddress, selector: felt252) -> L1Handler` 4 | 5 | Returns a structure referring to an L1 handler function. 6 | 7 | > `fn execute(self: L1Handler) -> SyscallResult<()>` 8 | 9 | Mocks an L1 -> L2 message from Ethereum handled by the given L1 handler function. 10 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/load.md: -------------------------------------------------------------------------------- 1 | # `load` 2 | 3 | > `fn load(target: ContractAddress, storage_address: felt252, size: felt252) -> Array ` 4 | 5 | Loads `size` felts from `target` contract's storage into an `Array`, starting at `storage_address`. 6 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/set_balance.md: -------------------------------------------------------------------------------- 1 | # `set_balance` 2 | 3 | > `fn set_balance(target: ContractAddress, new_balance: u256, token: Token)` 4 | 5 | Sets balance of `token` for `target` contract to `new_balance`. 6 | 7 | See [`Token`](../cheatcodes/token.md) docs on how to define and use tokens. 8 | -------------------------------------------------------------------------------- /docs/src/appendix/cheatcodes/store.md: -------------------------------------------------------------------------------- 1 | # `store` 2 | 3 | > `fn store(target: ContractAddress, storage_address: felt252, serialized_value: Span)` 4 | 5 | Stores felts from `serialized_value` in `target` contract's storage, starting at `storage_address`. 6 | 7 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast-library/get_nonce.md: -------------------------------------------------------------------------------- 1 | # `get_nonce` 2 | 3 | > `pub fn get_nonce(block_tag: felt252) -> felt252` 4 | 5 | Gets nonce of an account for a given block tag (`pending` or `latest`) and returns nonce as `felt252`. 6 | 7 | - `block_tag` - block tag name, one of `pending` or `latest`. 8 | 9 | ```rust 10 | {{#include ../../../listings/get_nonce/src/lib.cairo}} 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/account/account.md: -------------------------------------------------------------------------------- 1 | # `account` 2 | Provides a set of account management commands. 3 | 4 | It has the following subcommands: 5 | * [`import`](./import.md) 6 | * [`create`](./create.md) 7 | * [`deploy`](./deploy.md) 8 | * [`delete`](./delete.md) 9 | * [`list`](./list.md) 10 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/completion.md: -------------------------------------------------------------------------------- 1 | # `completion` 2 | Generates a completion script for the specified shell and writes it to `stdout`. 3 | 4 | ## `[SHELL]` 5 | Optional 6 | 7 | If not specified, the script will be generated for the shell detected under `$SHELL` variable. 8 | 9 | Possible values: `bash`, `elvish`, `fish`, `powershell`, `zsh` 10 | 11 | ## `-h`, `--help` 12 | 13 | Print help. 14 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/multicall/multicall.md: -------------------------------------------------------------------------------- 1 | # `multicall` 2 | Provides utilities for performing multicalls on Starknet. 3 | 4 | Multicall has the following subcommands: 5 | * [`new`](./new.md) 6 | * [`run`](./run.md) 7 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/script/init.md: -------------------------------------------------------------------------------- 1 | # `init` 2 | Create a deployment script template. 3 | 4 | The command creates the following file and directory structure: 5 | ``` 6 | . 7 | └── scripts 8 | └── my_script 9 | ├── Scarb.toml 10 | └── src 11 | ├── lib.cairo 12 | └── my_script.cairo 13 | ``` 14 | 15 | ## `` 16 | Required. 17 | 18 | Name of a script to create. 19 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/script/script.md: -------------------------------------------------------------------------------- 1 | # `script` 2 | Provides a set of commands to manage deployment scripts. 3 | 4 | Script has the following subcommands: 5 | * [`init`](./init.md) 6 | * [`run`](./run.md) 7 | -------------------------------------------------------------------------------- /docs/src/appendix/sncast/show_config.md: -------------------------------------------------------------------------------- 1 | # `show_config` 2 | Prints the config currently being used 3 | 4 | ## `--url, -u ` 5 | Optional. 6 | 7 | Starknet RPC node url address. 8 | 9 | Overrides url from `snfoundry.toml`. 10 | 11 | ## `--network ` 12 | Optional. 13 | 14 | Use predefined network with public provider 15 | 16 | Possible values: `mainnet`, `sepolia`. -------------------------------------------------------------------------------- /docs/src/appendix/sncast/tx-status.md: -------------------------------------------------------------------------------- 1 | # `tx-status` 2 | 3 | Get the status of a transaction 4 | 5 | ## `` 6 | 7 | Required. 8 | 9 | Hash of the transaction 10 | 11 | ## `--url, -u ` 12 | Optional. 13 | 14 | Starknet RPC node url address. 15 | 16 | Overrides url from `snfoundry.toml`. 17 | 18 | ## `--network ` 19 | Optional. 20 | 21 | Use predefined network with public provider 22 | 23 | Possible values: `mainnet`, `sepolia`. 24 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge-library/byte_array.md: -------------------------------------------------------------------------------- 1 | # `byte_array` Module 2 | 3 | Module containing utilities for manipulating `ByteArray`s. 4 | 5 | ## Functions 6 | 7 | > `fn try_deserialize_bytearray_error(x: Span) -> Result` 8 | 9 | This function is meant to transform a serialized output from a contract call into a `ByteArray`. 10 | Returns the parsed `ByteArray`, or an `Err` with reason, if the parsing failed. -------------------------------------------------------------------------------- /docs/src/appendix/snforge-library/env.md: -------------------------------------------------------------------------------- 1 | # `env` Module 2 | 3 | Module containing functions for interacting with the system environment. 4 | 5 | ## `var` 6 | 7 | > `fn var(name: ByteArray) -> Array` 8 | 9 | Reads an environment variable, without parsing it. 10 | 11 | The serialized output is correlated with the inferred input type, same as 12 | during [reading from a file](./fs.md#file-format). 13 | 14 | > 📝 **Note** 15 | > 16 | > If you want snfoundry to treat your variable like a short string, surround it with 'single quotes'. 17 | > 18 | > If you would like it to be serialized as a `ByteArray`, use "double quoting". It will be then de-serializable 19 | > with `Serde`. 20 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge.md: -------------------------------------------------------------------------------- 1 | # `snforge` CLI Reference 2 | 3 | * [`snforge test`](./snforge/test.md) 4 | * [`snforge init`](./snforge/init.md) 5 | * [`snforge new`](./snforge/new.md) 6 | * [`snforge clean`](./snforge/clean.md) 7 | * [`snforge clean-cache`](./snforge/clean-cache.md) 8 | * [`snforge check-requirements`](./snforge/check-requirements.md) 9 | 10 | You can check your version of `snforge` via `snforge --version`. 11 | To display help run `snforge --help`. 12 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge/check-requirements.md: -------------------------------------------------------------------------------- 1 | # `snforge check-requirements` 2 | 3 | Validate if all `snforge` requirements are installed. 4 | 5 | ## `-h`, `--help` 6 | 7 | Print help. 8 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge/clean-cache.md: -------------------------------------------------------------------------------- 1 | # `snforge clean-cache` 2 | 3 | Clean `snforge` cache directory. 4 | 5 | ## `-h`, `--help` 6 | 7 | Print help. 8 | 9 | > ⚠️ **Warning** 10 | > 11 | > The `snforge clean-cache` command is deprecated. Please use the [`snforge clean`](./clean.md) command instead. 12 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge/clean.md: -------------------------------------------------------------------------------- 1 | # `snforge clean` 2 | 3 | Remove files generated by `snforge`. 4 | 5 | ## `all` 6 | 7 | Clean all generated directories 8 | 9 | ## `cache` 10 | 11 | Clean the `.snfoundry_cache` directory. 12 | 13 | ## `trace` 14 | 15 | Clean the `snfoundry_trace` directory. 16 | 17 | ## `coverage` 18 | 19 | Clean the `coverage` directory. 20 | 21 | ## `profile` 22 | 23 | Clean the `profile` directory. 24 | 25 | ## `-h`, `--help` 26 | 27 | Print help. 28 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge/completion.md: -------------------------------------------------------------------------------- 1 | # `completion` 2 | Generates a completion script for the specified shell and writes it to `stdout`. 3 | 4 | ## `[SHELL]` 5 | Optional 6 | 7 | If not specified, the script will be generated for the shell detected under via `$SHELL` variable. 8 | 9 | Possible values: `bash`, `elvish`, `fish`, `powershell`, `zsh` 10 | 11 | ## `-h`, `--help` 12 | 13 | Print help. 14 | -------------------------------------------------------------------------------- /docs/src/appendix/snforge/init.md: -------------------------------------------------------------------------------- 1 | # `snforge init` 2 | 3 | Create a new directory with a `snforge` project. 4 | 5 | ## `` 6 | 7 | Name of a new project. 8 | 9 | ## `-h`, `--help` 10 | 11 | Print help. 12 | 13 | > ⚠️ **Warning** 14 | > 15 | > The `snforge init` command is deprecated. Please use the [`snforge new`](./new.md) command instead. 16 | -------------------------------------------------------------------------------- /docs/src/images/foundry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/images/foundry.png -------------------------------------------------------------------------------- /docs/src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/images/logo.png -------------------------------------------------------------------------------- /docs/src/starknet/images/starknet-faucet-sepolia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/images/starknet-faucet-sepolia.png -------------------------------------------------------------------------------- /docs/src/starknet/img/argent_export_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/argent_export_1.png -------------------------------------------------------------------------------- /docs/src/starknet/img/argent_export_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/argent_export_2.png -------------------------------------------------------------------------------- /docs/src/starknet/img/argent_export_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/argent_export_3.png -------------------------------------------------------------------------------- /docs/src/starknet/img/argent_export_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/argent_export_4.png -------------------------------------------------------------------------------- /docs/src/starknet/img/argent_export_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/argent_export_5.png -------------------------------------------------------------------------------- /docs/src/starknet/img/braavos_export_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/braavos_export_1.png -------------------------------------------------------------------------------- /docs/src/starknet/img/braavos_export_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/braavos_export_2.png -------------------------------------------------------------------------------- /docs/src/starknet/img/braavos_export_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/braavos_export_3.png -------------------------------------------------------------------------------- /docs/src/starknet/img/braavos_export_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/braavos_export_4.png -------------------------------------------------------------------------------- /docs/src/starknet/img/braavos_export_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/src/starknet/img/braavos_export_5.png -------------------------------------------------------------------------------- /docs/theme/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/starknet-foundry/cfd7819cd6e357627c46b847de2c6b52be8f61ef/docs/theme/favicon.png -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.86.0" 3 | components = ["rustfmt", "clippy"] 4 | -------------------------------------------------------------------------------- /scripts/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # TODO(#2781) 4 | 5 | pushd docs 6 | 7 | OUTPUT=$(mdbook build 2>&1) 8 | 9 | echo "$OUTPUT" 10 | 11 | if echo "$OUTPUT" | grep -q "\[ERROR\]"; then 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /scripts/compareVersions.js: -------------------------------------------------------------------------------- 1 | const semver = require('semver') 2 | 3 | if (process.argv.length !== 4) { 4 | console.error('Two arguments required'); 5 | process.exit(1); 6 | } 7 | 8 | const old_version = process.argv[2]; 9 | const new_version = process.argv[3]; 10 | 11 | console.log((semver.gt(new_version, old_version)).toString()) 12 | -------------------------------------------------------------------------------- /scripts/handle_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | get_version() { 4 | local overridden_version=$1 5 | local default_version=$(grep "^version =" crates/snforge-scarb-plugin/Scarb.toml | cut -d '"' -f 2) 6 | 7 | if [ -z "$overridden_version" ]; then 8 | echo "$default_version" 9 | else 10 | echo "$overridden_version" 11 | fi 12 | } 13 | 14 | update_version_in_file() { 15 | local file=$1 16 | local version=$2 17 | 18 | if [ -n "$version" ]; then 19 | sed -i.bak "/\[package\]/,/version =/ s/version = \".*/version = \"$version\"/" "$file" 20 | rm "$file.bak" 2> /dev/null 21 | fi 22 | } 23 | 24 | export -f get_version 25 | export -f update_version_in_file 26 | -------------------------------------------------------------------------------- /scripts/install_devnet.ps1: -------------------------------------------------------------------------------- 1 | Set-StrictMode -Version Latest 2 | 3 | $ErrorActionPreference = "Stop" 4 | 5 | $DEVNET_INSTALL_DIR = Join-Path (git rev-parse --show-toplevel) "crates\sncast\tests\utils\devnet" 6 | 7 | $DEVNET_REPO = "https://github.com/0xSpaceShard/starknet-devnet.git" 8 | $DEVNET_REV = "e0613b1028013dfd7ee8239d677e3a544fd808c8" # v0.4.2 9 | 10 | cargo install --locked --git $DEVNET_REPO --rev $DEVNET_REV --root $DEVNET_INSTALL_DIR --force 11 | 12 | Write-Host "All done!" 13 | 14 | exit 0 15 | -------------------------------------------------------------------------------- /scripts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "semver": "^7.5.4" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /scripts/package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euxo pipefail 3 | 4 | TARGET="$1" 5 | PKG_FULL_NAME="$2" 6 | 7 | rm -rf "$PKG_FULL_NAME" 8 | mkdir -p "$PKG_FULL_NAME/bin" 9 | 10 | bin_ext="" 11 | [[ "$TARGET" == *-windows-* ]] && bin_ext=".exe" 12 | 13 | binary_crates=("snforge" "sncast") 14 | for crate in "${binary_crates[@]}"; do 15 | cp "./target/${TARGET}/release/${crate}${bin_ext}" "$PKG_FULL_NAME/bin/" 16 | done 17 | 18 | cp -r README.md LICENSE "$PKG_FULL_NAME/" 19 | 20 | if [[ "$TARGET" == *-windows-* ]]; then 21 | 7z a "${PKG_FULL_NAME}.zip" "$PKG_FULL_NAME" 22 | else 23 | tar czvf "${PKG_FULL_NAME}.tar.gz" "$PKG_FULL_NAME" 24 | fi 25 | -------------------------------------------------------------------------------- /scripts/scarbfmt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SNFOUNDRY_ROOT="$(git rev-parse --show-toplevel)" 4 | 5 | pushd "$SNFOUNDRY_ROOT" || exit 6 | 7 | find . -type f -name "Scarb.toml" -execdir sh -c ' 8 | echo "Running \"scarb fmt\" in directory: $PWD" 9 | scarb fmt 10 | ' \; 11 | 12 | popd || exit 13 | -------------------------------------------------------------------------------- /scripts/verify_cairo_listings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -xe 3 | 4 | # TODO(#2718) 5 | for d in ./docs/listings/*; do (cd "$d" && scarb build); done 6 | -------------------------------------------------------------------------------- /sncast_std/README.md: -------------------------------------------------------------------------------- 1 | # sncast_std 2 | 3 | For a library reference please visit https://foundry-rs.github.io/starknet-foundry/appendix/sncast-library.html 4 | 5 | Full documentation can be found at https://foundry-rs.github.io/starknet-foundry/sncast_std/ 6 | -------------------------------------------------------------------------------- /sncast_std/Scarb.lock: -------------------------------------------------------------------------------- 1 | # Code generated by scarb DO NOT EDIT. 2 | version = 1 3 | 4 | [[package]] 5 | name = "sncast_std" 6 | version = "0.44.0" 7 | -------------------------------------------------------------------------------- /sncast_std/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sncast_std" 3 | version = "0.44.0" 4 | edition = "2023_11" 5 | description = "Library used for writing deployment scripts in Cairo" 6 | homepage = "https://foundry-rs.github.io/starknet-foundry/starknet/script.html" 7 | documentation = "https://foundry-rs.github.io/starknet-foundry/appendix/sncast-library.html" 8 | repository = "https://github.com/foundry-rs/starknet-foundry" 9 | license-file = "../LICENSE" 10 | -------------------------------------------------------------------------------- /snforge_std/README.md: -------------------------------------------------------------------------------- 1 | # snforge_std 2 | 3 | For a library reference please visit https://foundry-rs.github.io/starknet-foundry/appendix/snforge-library.html 4 | 5 | Full documentation can be found at https://foundry-rs.github.io/starknet-foundry/snforge_std/ 6 | -------------------------------------------------------------------------------- /snforge_std/Scarb.lock: -------------------------------------------------------------------------------- 1 | # Code generated by scarb DO NOT EDIT. 2 | version = 1 3 | 4 | [[package]] 5 | name = "snforge_scarb_plugin" 6 | version = "0.44.0" 7 | 8 | [[package]] 9 | name = "snforge_std" 10 | version = "0.44.0" 11 | dependencies = [ 12 | "snforge_scarb_plugin", 13 | ] 14 | -------------------------------------------------------------------------------- /snforge_std/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "snforge_std" 3 | version = "0.44.0" 4 | edition = "2024_07" 5 | description = "Cairo testing library" 6 | documentation = "https://foundry-rs.github.io/starknet-foundry/appendix/snforge-library.html" 7 | repository = "https://github.com/foundry-rs/starknet-foundry" 8 | license-file = "../LICENSE" 9 | re-export-cairo-plugins = ["snforge_scarb_plugin"] 10 | 11 | [dependencies] 12 | snforge_scarb_plugin = { path = "../crates/snforge-scarb-plugin" } 13 | -------------------------------------------------------------------------------- /snforge_std/src/cheatcodes/generate_arg.cairo: -------------------------------------------------------------------------------- 1 | use crate::cheatcode::execute_cheatcode_and_deserialize; 2 | 3 | // Generates a random number that is used for creating data for fuzz tests 4 | pub fn generate_arg, +Drop, +Into>(min_value: T, max_value: T) -> T { 5 | execute_cheatcode_and_deserialize::< 6 | 'generate_arg', 7 | >(array![min_value.into(), max_value.into()].span()) 8 | } 9 | -------------------------------------------------------------------------------- /snforge_std/src/cheatcodes/generate_random_felt.cairo: -------------------------------------------------------------------------------- 1 | use crate::cheatcode::execute_cheatcode_and_deserialize; 2 | 3 | 4 | /// Generates a random felt value 5 | /// 6 | /// Returns a random felt within the range of 0 and 2^252 - 1 7 | pub fn generate_random_felt() -> felt252 { 8 | execute_cheatcode_and_deserialize::<'generate_random_felt'>(array![].span()) 9 | } 10 | -------------------------------------------------------------------------------- /snforge_std/src/env.cairo: -------------------------------------------------------------------------------- 1 | mod env_vars; 2 | 3 | pub use env_vars::var; 4 | -------------------------------------------------------------------------------- /snforge_std/src/env/env_vars.cairo: -------------------------------------------------------------------------------- 1 | use crate::byte_array::byte_array_as_felt_array; 2 | use crate::cheatcode::execute_cheatcode; 3 | 4 | /// Reads an environment variable, without parsing it 5 | /// `name` - name of an environment variable 6 | /// Returns the read array of felts 7 | pub fn var(name: ByteArray) -> Array { 8 | execute_cheatcode::<'var'>(byte_array_as_felt_array(@name).span()).into() 9 | } 10 | -------------------------------------------------------------------------------- /snforge_std/src/fs.cairo: -------------------------------------------------------------------------------- 1 | mod file_operations; 2 | 3 | pub use file_operations::File; 4 | pub use file_operations::FileTrait; 5 | pub use file_operations::read_txt; 6 | pub use file_operations::read_json; 7 | pub use file_operations::FileParser; 8 | -------------------------------------------------------------------------------- /snforge_templates/cairo_program/src/lib.cairo: -------------------------------------------------------------------------------- 1 | fn main() -> u32 { 2 | fib(16) 3 | } 4 | 5 | fn fib(mut n: u32) -> u32 { 6 | let mut a: u32 = 0; 7 | let mut b: u32 = 1; 8 | while n != 0 { 9 | n = n - 1; 10 | let temp = b; 11 | b = a + b; 12 | a = temp; 13 | }; 14 | a 15 | } 16 | 17 | #[cfg(test)] 18 | mod tests { 19 | use super::fib; 20 | 21 | #[test] 22 | fn it_works() { 23 | assert(fib(16) == 987, 'it works!'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /snforge_templates/erc20_contract/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod mock_erc20; 2 | pub mod token_sender; 3 | --------------------------------------------------------------------------------