You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will guide how to generate test transactions using the `importer` tool for Aptos networks (Devnet/Testnet/Mainnet). These transactions are then used in automated tests, local development, or regression checks.
7
+
This will guide how to generate test transactions using the `aptos-indexer-transactions-generator` tool for Aptos networks (Devnet/Testnet/Mainnet). These transactions are then used in automated tests, local development, or regression checks.
8
8
9
9
## General Flow of Transaction Importing
10
10
11
-
First, identify the transaction versions you need to fetch from the Aptos network. This tool interacts with the Aptos gRPC endpoint to retrieve transaction data in JSON format. The transactions are then consolidated into a Rust file, where each transaction is represented as a constant variable. These constants can be seamlessly used as mocked inputs in a testing framework. During testing, the processor fetches the specified transactions, processes them, and writes the results to a database. You can then verify the outcomes by loading the written data and validating it against the expected schema.
11
+
First, identify the transaction versions you need to fetch from the Aptos network. This tool interacts with the [Transaction Stream](https://aptos.dev/en/build/indexer/txn-stream) to retrieve transaction data in JSON format. The transactions are then consolidated into a Rust file, where each transaction is represented as a constant variable. These constants can be seamlessly used as mocked inputs in a testing framework. During testing, the processor fetches the specified transactions, processes them, and writes the results to a database. You can then verify the outcomes by loading the written data and validating it against the expected schema.
12
12
13
13
## Prerequisites
14
14
15
15
1. Access to a Network (Testnet/Mainnet):
16
-
- A valid API key for the gRPC endpoint. ([Refer here](https://developers.aptoslabs.com/docs/api-access))
16
+
- A valid API key for the gRPC endpoint. ([Refer here](https://aptos.dev/en/build/indexer/txn-stream/aptos-hosted-txn-stream))
17
17
2. Clone the [aptos-core](https://github.com/aptos-labs/aptos-core) repository:
18
18
- Navigate to the `aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator` directory.
19
19
@@ -52,19 +52,39 @@ mainnet:
52
52
53
53
### 2. Run the Command to Import Transactions
54
54
55
+
Navigate to the `indexer-transaction-generator` directory:
56
+
57
+
```bash
58
+
cd aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator
59
+
```
60
+
55
61
To import the specified transaction versions, execute the following command:
56
62
57
63
```bash
58
-
cargo run -- --testing-folder ./imported_transactions --output-folder ../indexer-test-transactions/src/
64
+
cargo run -- --testing-folder ./imported_transactions --output-folder /path/to/your/processor-repo/src
59
65
```
60
66
61
67
This command will:
62
68
63
-
1. Read the configuration from the `imported_transactions.yaml` file.
64
-
2. Fetch the specified transaction versions from the selected network (Testnet or Mainnet).
65
-
3. Store the resulting JSON files in the specified output folder (`../indexer-test-transactions/src/json_transactions`).
69
+
1. Read the configuration from the `imported_transactions.yaml` file located in the folder specified by the --testing-folder flag.
70
+
2. Fetch the specified transaction versions from the selected network (Devnet, Testnet or Mainnet).
71
+
3. Store the resulting JSON files in the specified output folder (/path/to/your/processor-repo/src/json_transactions).
66
72
4. Generate a Rust file (`generated_transactions.rs`) that converts the generated transaction JSON files into constant variables for use in tests.
67
73
74
+
Note: Replace /path/to/your/processor-repo with the path to your processor repository or preferred storage location.
75
+
76
+
**Explanation of Command Flags**
77
+
1. `--testing-folder`
78
+
What is the --testing-folder flag?
79
+
The --testing-folder flag specifies the directory containing the imported_transactions.yaml configuration file. The tool uses this folder to read versions you wish to import.
80
+
- Ensure the folder path matches the location of your imported_transactions.yaml file.
81
+
- By default, this guide assumes the configuration is stored in ./imported_transactions. Adjust the flag value if you place the file elsewhere.
82
+
83
+
2. `--output-folder`
84
+
Specifies the destination directory where the generated transaction JSON files and Rust constants will be saved.
85
+
- Replace /path/to/your/processor-repo with your processor repository src directory or desired storage location.
86
+
- Ensure this folder is part of your version control setup if these files need to be shared.
87
+
68
88
## How to Use the Testing Transactions
69
89
70
90
### Export the Generated File
@@ -87,6 +107,7 @@ Include the crate containing the generated transactions as a dependency in the `
87
107
88
108
Use the exported transaction constants directly in your test cases to simulate real transactions and validate processing logic.
Once the transaction constants are integrated, you can use them in processor tests to validate functionality. For detailed instructions on writing processor tests, refer to [Writing Processor Tests](TBD).
0 commit comments