Skip to content

Commit 18f5a07

Browse files
committed
update
1 parent 7243c40 commit 18f5a07

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Aptos Indexer Testing Framework Overview
2+
3+
The Aptos Indexer Testing Framework provides two methods to generate testing transactions: **aptos-indexer-transaction-generator** and **Move Scripts**. Both approaches are suited for specific scenarios based on your development and testing requirements, enabling you to test how your system handles various transaction types.
4+
5+
6+
## When to Use **aptos-indexer-transaction-generator**
7+
## 1. Fetching Historical Transactions
8+
- Retrieve specific historical transactions from the Aptos blockchain (Testnet or Mainnet) for testing or analysis.
9+
- Ideal for creating mocked transaction inputs for processor tests or regression checks.
10+
11+
### 2. Simulating Real-World Scenarios
12+
- Validate processor logic or database integrity by replaying transactions from live networks.
13+
- Simulate conditions that mirror real-world environments to ensure robustness.
14+
15+
16+
## When to Use **Move Script**
17+
### 1. Deploying Custom Logic
18+
- Write, deploy, and execute custom logic using Move to test your new AIPs (Aptos Improvement Proposals).
19+
- Ideal for creating smart contracts, defining new modules, or implementing specific on-chain functionalities.
20+
21+
### 2. Prototyping New Features
22+
- Experiment with new decentralized application (dApp) ideas or test custom on-chain workflows.
23+
- Perform operations like:
24+
- Account creation
25+
- Token minting
26+
- Custom transactions
27+
- Define business rules and execute state changes directly on the Aptos blockchain.
28+
29+
## Summary
30+
31+
Both **aptos-indexer-transaction-generator** and **Move Scripts** are essential tools in the Aptos Indexer Testing Framework. Use the **aptos-indexer-transaction-generator** for replaying and analyzing real-world transactions, while **Move Scripts** are best for testing custom logic and prototyping features. Choose the method that aligns with your testing goals to ensure a comprehensive validation process.

apps/nextra/pages/en/build/indexer/indexer-sdk/documentation/advanced-tutorials/txn-importer.mdx

+30-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ title: "Aptos Transaction Import"
44

55
## Overview
66

7-
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.
88

99
## General Flow of Transaction Importing
1010

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.
1212

1313
## Prerequisites
1414

1515
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))
1717
2. Clone the [aptos-core](https://github.com/aptos-labs/aptos-core) repository:
1818
- Navigate to the `aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator` directory.
1919

@@ -52,19 +52,39 @@ mainnet:
5252
5353
### 2. Run the Command to Import Transactions
5454
55+
Navigate to the `indexer-transaction-generator` directory:
56+
57+
```bash
58+
cd aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator
59+
```
60+
5561
To import the specified transaction versions, execute the following command:
5662

5763
```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
5965
```
6066

6167
This command will:
6268

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).
6672
4. Generate a Rust file (`generated_transactions.rs`) that converts the generated transaction JSON files into constant variables for use in tests.
6773

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+
6888
## How to Use the Testing Transactions
6989

7090
### Export the Generated File
@@ -87,6 +107,7 @@ Include the crate containing the generated transactions as a dependency in the `
87107

88108
Use the exported transaction constants directly in your test cases to simulate real transactions and validate processing logic.
89109

90-
Example usage:
91-
92110
[Example Crate](https://github.com/aptos-labs/aptos-indexer-processor-example/tree/main/test-transactions-example).
111+
112+
## Next Steps
113+
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

Comments
 (0)