Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Jan 23, 2025
1 parent 7243c40 commit 0307421
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
title: "Advanced Tutorials"
---

# Documentation
# Advanced Tutorials
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {
// setup: { title: "Initial Setup" },
"txn-importer": {
title: "Importing Transactions",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ title: "Aptos Transaction Import"

## Overview

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

## General Flow of Transaction Importing

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

## Prerequisites

1. Access to a Network (Testnet/Mainnet):
- A valid API key for the gRPC endpoint. ([Refer here](https://developers.aptoslabs.com/docs/api-access))
- A valid API key for the gRPC endpoint. ([Refer here](https://aptos.dev/en/build/indexer/txn-stream/aptos-hosted-txn-stream))
2. Clone the [aptos-core](https://github.com/aptos-labs/aptos-core) repository:
- Navigate to the `aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator` directory.

Expand Down Expand Up @@ -52,19 +52,39 @@ mainnet:
### 2. Run the Command to Import Transactions
Navigate to the `indexer-transaction-generator` directory:

```bash
cd aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator
```

To import the specified transaction versions, execute the following command:

```bash
cargo run -- --testing-folder ./imported_transactions --output-folder ../indexer-test-transactions/src/
cargo run -- --testing-folder ./imported_transactions --output-folder /path/to/your/processor-repo/src
```

This command will:

1. Read the configuration from the `imported_transactions.yaml` file.
2. Fetch the specified transaction versions from the selected network (Testnet or Mainnet).
3. Store the resulting JSON files in the specified output folder (`../indexer-test-transactions/src/json_transactions`).
1. Read the configuration from the `imported_transactions.yaml` file located in the folder specified by the --testing-folder flag.
2. Fetch the specified transaction versions from the selected network (Devnet, Testnet or Mainnet).
3. Store the resulting JSON files in the specified output folder (/path/to/your/processor-repo/src/json_transactions).
4. Generate a Rust file (`generated_transactions.rs`) that converts the generated transaction JSON files into constant variables for use in tests.

Note: Replace /path/to/your/processor-repo with the path to your processor repository or preferred storage location.

**Explanation of Command Flags**
1. `--testing-folder`
What is the --testing-folder flag?
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.
- Ensure the folder path matches the location of your imported_transactions.yaml file.
- By default, this guide assumes the configuration is stored in ./imported_transactions. Adjust the flag value if you place the file elsewhere.

2. `--output-folder`
Specifies the destination directory where the generated transaction JSON files and Rust constants will be saved.
- Replace /path/to/your/processor-repo with your processor repository src directory or desired storage location.
- Ensure this folder is part of your version control setup if these files need to be shared.

## How to Use the Testing Transactions

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

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

Example usage:

[Example Crate](https://github.com/aptos-labs/aptos-indexer-processor-example/tree/main/test-transactions-example).

## Next Steps
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 comments on commit 0307421

Please sign in to comment.