Overview:
This section outlines the steps for creating a testing transaction with a Move script.
Steps:
-
Create Your Move Project
Create your Move project and write a module to output the scenario that you would like to test in your processor. You can refer to an example here.
-
Set Up Accounts
-
These accounts will be used to deploy your module.
-
Set up as many accounts as you need. Refer to the guide here.
-
Update
aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/testing_accounts.yaml
with your accounts.
💡 Note: Do not use real accounts here. Only use test accounts created in the CLI specifically for testing.
-
-
Create a Configuration File
-
This configuration file should include unique transaction names and details for each transaction. Example configuration: output_name: the name of the transaction json output script_path: the path to the Move script sender_address: the address of the account that will send the transaction
transactions: - output_name: simple_user_script1 script_path: simple_user_script sender_address: <account_address> - output_name: simple_user_script2 script_path: simple_user_script2 sender_address: <account_address>
-
Generate JSON Files and Rust File
Once the Move files and configuration are set up, run the same command used to import transactions:
- testing-folder is where your Move files are stored.
- output-foler can be set to any folder where you want to store the generated files.
cargo run -- --testing-folder ./imported_transactions --output-folder ../indexer-test-transactions/src/
This command will:
- Read the configuration in the
move_fixtures
folder. - Execute the specified Move scripts.
- Output the generated JSON files to the designated folder (
~/aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator/json_transactions
). - Update
generated_transactions.rs
with the new transaction names specified in step 3.
How to Use the Testing Transactions
-
Export the Generated File:
Update the
mod.rs
file to include the generated Rust file containing the transaction constants. -
Export the
json_transactions
Folder:Ensure the
json_transactions
folder is properly exported in the library file. -
Add as a Dependency:
Include the crate containing the generated transactions as a dependency in the
Cargo.toml
file of your test crate. (Internally, transactions are stored inaptos-core
and used in the processor repo). -
Integrate into Test Cases:
Use the exported transaction constants directly in your test cases to simulate real transactions and validate processing logic.