Skip to content

Commit

Permalink
support multi txn test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuunlimm committed Feb 3, 2025
1 parent 4928c52 commit a3f3fc6
Show file tree
Hide file tree
Showing 11 changed files with 316 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"transaction_version": 1680592683,
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"coin_type": "0x1::aptos_coin::AptosCoin",
"supply": "111442820397688086",
"transaction_timestamp": "2024-09-05T11:52:16",
"transaction_epoch": 8371
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"storage_id": "0xfa4e15c47bc6b38cc404cf08e30e69fd14ff2cc82b136ef3630445a66605653c",
"owner_address": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06",
"asset_type_v2": null,
"asset_type_v1": "0x1::aptos_coin::AptosCoin",
"is_primary": true,
"is_frozen": false,
"amount_v1": "997323833",
"amount_v2": null,
"amount": "997323833",
"last_transaction_version_v1": 1680592683,
"last_transaction_version_v2": null,
"last_transaction_version": 1680592683,
"last_transaction_timestamp_v1": "2024-09-05T11:52:16",
"last_transaction_timestamp_v2": null,
"last_transaction_timestamp": "2024-09-05T11:52:16",
"token_standard": "v1",
"asset_type": "0x1::aptos_coin::AptosCoin"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"transaction_version": 1680592683,
"event_index": -1,
"owner_address": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06",
"storage_id": "0xfa4e15c47bc6b38cc404cf08e30e69fd14ff2cc82b136ef3630445a66605653c",
"asset_type": "0x1::aptos_coin::AptosCoin",
"is_frozen": null,
"amount": "205700",
"type_": "0x1::aptos_coin::GasFeeEvent",
"is_gas_fee": true,
"gas_fee_payer_address": null,
"is_transaction_success": true,
"entry_function_id_str": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::managed_mkl_token::initialize_module",
"block_height": 222731447,
"token_standard": "v1",
"transaction_timestamp": "2024-09-05T11:52:16",
"storage_refund_amount": "47280"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"asset_type": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_token::MKL",
"creator_address": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06",
"name": "MKL",
"symbol": "MKL",
"decimals": 6,
"icon_uri": null,
"project_uri": null,
"last_transaction_version": 1680592683,
"last_transaction_timestamp": "2024-09-05T11:52:16",
"supply_aggregator_table_handle_v1": null,
"supply_aggregator_table_key_v1": null,
"token_standard": "v1",
"maximum_v2": null,
"is_token_v2": null,
"supply_v2": null
},
{
"asset_type": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"creator_address": "0x000000000000000000000000000000000000000000000000000000000000000a",
"name": "MKL",
"symbol": "MKL",
"decimals": 6,
"icon_uri": "",
"project_uri": "",
"last_transaction_version": 1680592683,
"last_transaction_timestamp": "2024-09-05T11:52:16",
"supply_aggregator_table_handle_v1": null,
"supply_aggregator_table_key_v1": null,
"token_standard": "v2",
"maximum_v2": "340282366920938463463374607431768211455",
"is_token_v2": null,
"supply_v2": "0"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"transaction_version": 1957950162,
"coin_type_hash": "91ceb1308a98389691e05158b07ed5f079ab78461a6bb8d5a4054b1bb5cb8bb6",
"coin_type": "0x1::aptos_coin::AptosCoin",
"supply": "112743621173497128",
"transaction_timestamp": "2024-11-23T22:32:30",
"transaction_epoch": 9331
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"storage_id": "0x1734f2619bb775e59d04469663b9c05614b5ada6afbf2f750095f43cb8d41e40",
"owner_address": "0x345ced5d7c67360d61a1d59d8cd83cb53095a81aa24a337027391b1c7dd1786f",
"asset_type_v2": null,
"asset_type_v1": "0x1::aptos_coin::AptosCoin",
"is_primary": true,
"is_frozen": false,
"amount_v1": "115245132",
"amount_v2": null,
"amount": "115245132",
"last_transaction_version_v1": 1957950162,
"last_transaction_version_v2": null,
"last_transaction_version": 1957950162,
"last_transaction_timestamp_v1": "2024-11-23T22:32:30",
"last_transaction_timestamp_v2": null,
"last_transaction_timestamp": "2024-11-23T22:32:30",
"token_standard": "v1",
"asset_type": "0x1::aptos_coin::AptosCoin"
},
{
"storage_id": "0xa1ddab83c8209aabffc66264730ba95bcc7d7a7966192c00d800ab734729622c",
"owner_address": "0x7ae7cc51c4fab67181a969f53a5d01a292dad0baf259c92c4e1a13f056768e1c",
"asset_type_v2": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"asset_type_v1": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_token::MKL",
"is_primary": true,
"is_frozen": false,
"amount_v1": null,
"amount_v2": "431101567356",
"amount": "431101567356",
"last_transaction_version_v1": null,
"last_transaction_version_v2": 1957950162,
"last_transaction_version": 1957950162,
"last_transaction_timestamp_v1": null,
"last_transaction_timestamp_v2": "2024-11-23T22:32:30",
"last_transaction_timestamp": "2024-11-23T22:32:30",
"token_standard": "v1",
"asset_type": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_token::MKL"
},
{
"storage_id": "0xd29b17433643769f27d89851553ec2ab5e4204b66eceecb6eec774668117c3e0",
"owner_address": "0x345ced5d7c67360d61a1d59d8cd83cb53095a81aa24a337027391b1c7dd1786f",
"asset_type_v2": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"asset_type_v1": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_token::MKL",
"is_primary": true,
"is_frozen": false,
"amount_v1": null,
"amount_v2": "3643926",
"amount": "3643926",
"last_transaction_version_v1": null,
"last_transaction_version_v2": 1957950162,
"last_transaction_version": 1957950162,
"last_transaction_timestamp_v1": null,
"last_transaction_timestamp_v2": "2024-11-23T22:32:30",
"last_transaction_timestamp": "2024-11-23T22:32:30",
"token_standard": "v1",
"asset_type": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::mkl_token::MKL"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
"transaction_version": 1957950162,
"event_index": -1,
"owner_address": "0x345ced5d7c67360d61a1d59d8cd83cb53095a81aa24a337027391b1c7dd1786f",
"storage_id": "0x1734f2619bb775e59d04469663b9c05614b5ada6afbf2f750095f43cb8d41e40",
"asset_type": "0x1::aptos_coin::AptosCoin",
"is_frozen": null,
"amount": "2100",
"type_": "0x1::aptos_coin::GasFeeEvent",
"is_gas_fee": true,
"gas_fee_payer_address": null,
"is_transaction_success": true,
"entry_function_id_str": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::managed_liquidity_auction::claim_mkl_reward",
"block_height": 256094969,
"token_standard": "v1",
"transaction_timestamp": "2024-11-23T22:32:30",
"storage_refund_amount": "0"
},
{
"transaction_version": 1957950162,
"event_index": 0,
"owner_address": "0x7ae7cc51c4fab67181a969f53a5d01a292dad0baf259c92c4e1a13f056768e1c",
"storage_id": "0xa1ddab83c8209aabffc66264730ba95bcc7d7a7966192c00d800ab734729622c",
"asset_type": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"is_frozen": null,
"amount": "3643926",
"type_": "0x1::fungible_asset::Withdraw",
"is_gas_fee": false,
"gas_fee_payer_address": null,
"is_transaction_success": true,
"entry_function_id_str": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::managed_liquidity_auction::claim_mkl_reward",
"block_height": 256094969,
"token_standard": "v2",
"transaction_timestamp": "2024-11-23T22:32:30",
"storage_refund_amount": "0"
},
{
"transaction_version": 1957950162,
"event_index": 1,
"owner_address": "0x345ced5d7c67360d61a1d59d8cd83cb53095a81aa24a337027391b1c7dd1786f",
"storage_id": "0xd29b17433643769f27d89851553ec2ab5e4204b66eceecb6eec774668117c3e0",
"asset_type": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"is_frozen": null,
"amount": "3643926",
"type_": "0x1::fungible_asset::Deposit",
"is_gas_fee": false,
"gas_fee_payer_address": null,
"is_transaction_success": true,
"entry_function_id_str": "0x5ae6789dd2fec1a9ec9cccfb3acaf12e93d432f0a3a42c92fe1a9d490b7bbc06::managed_liquidity_auction::claim_mkl_reward",
"block_height": 256094969,
"token_standard": "v2",
"transaction_timestamp": "2024-11-23T22:32:30",
"storage_refund_amount": "0"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"asset_type": "0x878370592f9129e14b76558689a4b570ad22678111df775befbfcbc9fb3d90ab",
"creator_address": "0x000000000000000000000000000000000000000000000000000000000000000a",
"name": "MKL",
"symbol": "MKL",
"decimals": 6,
"icon_uri": "",
"project_uri": "",
"last_transaction_version": 1957950162,
"last_transaction_timestamp": "2024-11-23T22:32:30",
"supply_aggregator_table_handle_v1": null,
"supply_aggregator_table_key_v1": null,
"token_standard": "v2",
"maximum_v2": "340282366920938463463374607431768211455",
"is_token_v2": null,
"supply_v2": "96895109643615"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ mod sdk_fungible_asset_processor_tests {
setup_test_environment, validate_json, DEFAULT_OUTPUT_FOLDER,
},
};
use aptos_indexer_testing_framework::{
database::{PostgresTestDatabase},
sdk_test_context::{SdkTestContext},
};
use aptos_indexer_test_transactions::json_transactions::generated_transactions::{
IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS,
IMPORTED_MAINNET_TXNS_1680592683_FA_MIGRATION_COIN_INFO,
Expand Down Expand Up @@ -270,6 +274,85 @@ mod sdk_fungible_asset_processor_tests {
// .await;
// }

/// Tests processing of two transactions sequentially
/// Validates handling of multiple transactions with shared context
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_fungible_asset_processor_two_transactions() {
let (diff_flag, custom_output_path) = get_test_config();
let output_path = custom_output_path.unwrap_or_else(|| DEFAULT_OUTPUT_FOLDER.to_string());

let mut db = PostgresTestDatabase::new();
db.setup().await.unwrap();

// Process each transaction with a helper function
process_transaction(
&mut db,
&[IMPORTED_MAINNET_TXNS_1680592683_FA_MIGRATION_COIN_INFO],
"first_transaction",
diff_flag,
&output_path,
)
.await;

process_transaction(
&mut db,
&[IMPORTED_MAINNET_TXNS_1957950162_FA_MIGRATION_V2_STORE_ONLY],
"second_transaction",
diff_flag,
&output_path,
)
.await;
}

async fn process_transaction(
db: &mut PostgresTestDatabase,
txns: &[&[u8]],
transaction_name: &str,
diff_flag: bool,
output_path: &str,
) {
let mut test_context = SdkTestContext::new(txns);
if test_context.init_mock_grpc().await.is_err() {
panic!("Failed to initialize mock grpc");

Check warning on line 316 in rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs

View check run for this annotation

Codecov / codecov/patch

rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs#L316

Added line #L316 was not covered by tests
};

let db_url = db.get_db_url();
let (indexer_processor_config, processor_name) =
setup_fa_processor_config(&test_context, &db_url);

let fungible_asset_processor = FungibleAssetProcessor::new(indexer_processor_config)
.await
.expect("Failed to create FungibleAssetProcessor");

match run_processor_test(
&mut test_context,
fungible_asset_processor,
load_data,
db_url,
diff_flag,
output_path.to_string(),
Some(transaction_name.to_string()),
)
.await
{
Ok(mut db_value) => {
let _ = validate_json(
&mut db_value,
test_context.get_request_start_version(),
processor_name,
output_path.to_string(),
Some(transaction_name.to_string()),
);
}
Err(e) => {
panic!(
"Test failed on {} due to processor error: {}",
transaction_name, e
);

Check warning on line 351 in rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs

View check run for this annotation

Codecov / codecov/patch

rust/integration-tests/src/sdk_tests/fungible_asset_processor_tests.rs#L347-L351

Added lines #L347 - L351 were not covered by tests
}
}
}

// Helper function to abstract out the transaction processing
async fn process_fa_txns(txns: &[&[u8]], test_case_name: Option<String>) {
let (diff_flag, custom_output_path) = get_test_config();
Expand Down

0 comments on commit a3f3fc6

Please sign in to comment.