-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generating test transactions with move script #775
base: 01-17-importing_test_transactions
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: "Aptos Transaction Import" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The title Spotted by Graphite Reviewer |
||
--- | ||
|
||
## Overview: | ||
|
||
This section outlines the steps for creating a testing transaction with a Move script. | ||
|
||
### Steps: | ||
|
||
1. **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](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/move_fixtures). | ||
|
||
2. **Set Up Accounts** | ||
|
||
1. These accounts will be used to deploy your module. | ||
2. Set up as many accounts as you need. Refer to the guide [here](https://aptos.dev/en/build/cli/setup-cli). | ||
3. 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. | ||
|
||
3. **Create a Configuration File** | ||
|
||
1. Create a [configuration file in the `move_fixtures` directory](https://github.com/aptos-labs/aptos-core/blob/main/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/move_fixtures/simple_user_script.yaml). | ||
2. 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 | ||
|
||
```yaml | ||
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> | ||
``` | ||
|
||
4. **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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo: Spotted by Graphite Reviewer |
||
|
||
```bash | ||
cargo run -- --testing-folder ./imported_transactions --output-folder ../indexer-test-transactions/src/ | ||
``` | ||
|
||
This command will: | ||
|
||
1. Read the configuration in the `move_fixtures` folder. | ||
2. Execute the specified Move scripts. | ||
3. Output the generated JSON files to the designated folder (`~/aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator/json_transactions`). | ||
4. 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`](https://github.com/aptos-labs/aptos-indexer-processor-example/blob/main/test-transactions-example/src/json_transactions/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. | ||
|
||
[Example](https://github.com/aptos-labs/aptos-indexer-processor-example/blob/main/test-transactions-example/src/lib.rs). | ||
|
||
- **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 in `aptos-core` and used in the [processor repo](https://github.com/aptos-labs/aptos-indexer-processors/blob/0c92d323b0f560b5f8601a831a36520ad9b72d68/rust/Cargo.toml#L34)). | ||
|
||
- **Integrate into Test Cases**: | ||
|
||
Use the exported transaction constants directly in your test cases to simulate real transactions and validate processing logic. | ||
|
||
[Example usage](https://github.com/aptos-labs/aptos-indexer-processor-example/tree/main/test-transactions-example). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The redirect paths (
txn-scripts
) don't match the actual file name (txn-script
). This mismatch will cause the redirect to fail. The paths in the redirect configuration should be updated to usetxn-script
to match the MDX file name.Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.