Skip to content
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

Improve error handling and use new SdkTestContext methods #595

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ testing-transactions = { path = "testing-transactions" }

ahash = { version = "0.8.7", features = ["serde"] }
anyhow = "1.0.86"
aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "c8f12a75c3648fba889c3da657ff713cd5e676dc" }
aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "c8f12a75c3648fba889c3da657ff713cd5e676dc" }
aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" }
aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" }
aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" }
aptos-system-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "202bdccff2b2d333a385ae86a4fcf23e89da9f62" }
aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "4b67e5d816d554b5af4b2c130b283d00799268b7" }
aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "c8f12a75c3648fba889c3da657ff713cd5e676dc" }
aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "e6867c50a2c30ef16ad6f82e02313b2ba5ce361a" }
async-trait = "0.1.53"
backtrace = "0.3.58"
base64 = "0.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ use std::collections::HashSet;

pub async fn setup_acc_txn_processor_config(
test_context: &SdkTestContext,
staring_version: u64,
txn_count: usize,
db_url: &str,
) -> (IndexerProcessorConfig, &'static str) {
let transaction_stream_config =
test_context.create_transaction_stream_config(staring_version, txn_count as u64); // since this will be always 1, we can remove from the arg list
let transaction_stream_config = test_context.create_transaction_stream_config();
let postgres_config = PostgresConfig {
connection_string: db_url.to_string(),
db_pool_size: 100,
Expand Down Expand Up @@ -69,7 +66,6 @@ mod tests {
async fn mainnet_acc_txns_processor() {
process_single_mainnet_txn(
IMPORTED_MAINNET_TXNS_145959468_ACCOUNT_TRANSACTION,
145959468,
Some("account_transaction_test".to_string()),
)
.await;
Expand All @@ -83,18 +79,13 @@ mod tests {
async fn mainnet_acc_txns_processor_delete() {
process_single_mainnet_txn(
IMPORTED_MAINNET_TXNS_423176063_ACCOUNT_TRANSACTION_DELETE,
423176063,
Some("account_transaction_delete_test".to_string()),
)
.await;
}

// Helper function to abstract out the single transaction processing
async fn process_single_mainnet_txn(
txn: &[u8],
txn_version: i64,
test_case_name: Option<String>,
) {
async fn process_single_mainnet_txn(txn: &[u8], test_case_name: Option<String>) {
let (diff_flag, custom_output_path) = get_test_config();
let output_path = custom_output_path
.unwrap_or_else(|| format!("{}/imported_mainnet_txns", DEFAULT_OUTPUT_FOLDER));
Expand All @@ -103,7 +94,7 @@ mod tests {

let db_url = db.get_db_url();
let (indexer_processor_config, processor_name) =
setup_acc_txn_processor_config(&test_context, txn_version as u64, 1, &db_url).await;
setup_acc_txn_processor_config(&test_context, &db_url).await;

let acc_txns_processor = AccountTransactionsProcessor::new(indexer_processor_config)
.await
Expand All @@ -114,7 +105,6 @@ mod tests {
acc_txns_processor,
load_data,
db_url,
vec![txn_version],
diff_flag,
output_path.clone(),
test_case_name.clone(),
Expand All @@ -124,18 +114,18 @@ mod tests {
Ok(mut db_value) => {
let _ = validate_json(
&mut db_value,
txn_version as u64,
test_context.get_request_start_version(),
processor_name,
output_path.clone(),
test_case_name,
);
},
Err(e) => {
eprintln!(
"[ERROR] Failed to run processor for txn version {}: {}",
1, e
panic!(
"Test failed on transactions {:?} due to processor error: {}",
test_context.get_test_transaction_versions(),
e
);
panic!("Test failed due to processor error");
},
}
}
Expand Down
27 changes: 8 additions & 19 deletions rust/integration-tests/src/sdk_tests/ans_processor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ use std::collections::HashSet;

pub async fn setup_ans_processor_config(
test_context: &SdkTestContext,
staring_version: u64,
txn_count: usize,
db_url: &str,
) -> (IndexerProcessorConfig, &'static str) {
let transaction_stream_config =
test_context.create_transaction_stream_config(staring_version, txn_count as u64); // since this will be always 1, we can remove from the arg list
let transaction_stream_config = test_context.create_transaction_stream_config(); // since this will be always 1, we can remove from the arg list
let postgres_config = PostgresConfig {
connection_string: db_url.to_string(),
db_pool_size: 100,
Expand Down Expand Up @@ -82,7 +79,6 @@ mod tests {
async fn mainnet_current_ans_primary_name_v2() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_1056780409_ANS_CURRENT_ANS_PRIMARY_NAME_V2,
1056780409,
Some("test_current_ans_primary_name_v2".to_string()),
)
.await;
Expand All @@ -98,7 +94,6 @@ mod tests {
async fn mainnet_ans_lookup_v2() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_303690531_ANS_LOOKUP_V2,
303690531,
Some("test_ans_lookup_v2".to_string()),
)
.await;
Expand All @@ -114,17 +109,12 @@ mod tests {
async fn mainnet_current_ans_lookup_v2() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_438536688_ANS_CURRENT_ANS_LOOKUP_V2,
438536688,
Some("test_current_ans_lookup_v2".to_string()),
)
.await;
}
// Helper function to abstract out the single transaction processing
async fn process_single_mainnet_event_txn(
txn: &[u8],
txn_version: i64,
test_case_name: Option<String>,
) {
async fn process_single_mainnet_event_txn(txn: &[u8], test_case_name: Option<String>) {
let (diff_flag, custom_output_path) = get_test_config();
let output_path = custom_output_path
.unwrap_or_else(|| format!("{}/imported_mainnet_txns", DEFAULT_OUTPUT_FOLDER));
Expand All @@ -133,7 +123,7 @@ mod tests {

let db_url = db.get_db_url();
let (indexer_processor_config, processor_name) =
setup_ans_processor_config(&test_context, txn_version as u64, 1, &db_url).await;
setup_ans_processor_config(&test_context, &db_url).await;

let ans_processor = AnsProcessor::new(indexer_processor_config)
.await
Expand All @@ -144,7 +134,6 @@ mod tests {
ans_processor,
load_data,
db_url,
vec![txn_version],
diff_flag,
output_path.clone(),
test_case_name.clone(),
Expand All @@ -154,18 +143,18 @@ mod tests {
Ok(mut db_value) => {
let _ = validate_json(
&mut db_value,
txn_version as u64,
test_context.get_request_start_version(),
rtso marked this conversation as resolved.
Show resolved Hide resolved
processor_name,
output_path.clone(),
test_case_name,
);
},
Err(e) => {
eprintln!(
"[ERROR] Failed to run processor for txn version {}: {}",
1, e
panic!(
"Test failed on transactions {:?} due to processor error: {}",
test_context.get_test_transaction_versions(),
e
);
panic!("Test failed due to processor error");
},
}
}
Expand Down
27 changes: 8 additions & 19 deletions rust/integration-tests/src/sdk_tests/default_processor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ use std::collections::HashSet;

pub async fn setup_default_processor_config(
test_context: &SdkTestContext,
staring_version: u64,
txn_count: usize,
db_url: &str,
) -> (IndexerProcessorConfig, &'static str) {
let transaction_stream_config =
test_context.create_transaction_stream_config(staring_version, txn_count as u64); // since this will be always 1, we can remove from the arg list
let transaction_stream_config = test_context.create_transaction_stream_config(); // since this will be always 1, we can remove from the arg list
let postgres_config = PostgresConfig {
connection_string: db_url.to_string(),
db_pool_size: 100,
Expand Down Expand Up @@ -62,7 +59,6 @@ mod tests {
async fn mainnet_table_items() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_155112189_DEFAULT_TABLE_ITEMS,
155112189,
Some("test_table_items".to_string()),
)
.await;
Expand All @@ -72,7 +68,6 @@ mod tests {
async fn mainnet_current_table_items() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_1845035942_DEFAULT_CURRENT_TABLE_ITEMS,
1845035942,
Some("test_current_table_items".to_string()),
)
.await;
Expand All @@ -82,18 +77,13 @@ mod tests {
async fn mainnet_block_metadata_txns() {
process_single_mainnet_event_txn(
IMPORTED_MAINNET_TXNS_513424821_DEFAULT_BLOCK_METADATA_TRANSACTIONS,
513424821,
Some("block_metadata_transactions".to_string()),
)
.await;
}

// Helper function to abstract out the single transaction processing
async fn process_single_mainnet_event_txn(
txn: &[u8],
txn_version: i64,
test_case_name: Option<String>,
) {
async fn process_single_mainnet_event_txn(txn: &[u8], test_case_name: Option<String>) {
let (diff_flag, custom_output_path) = get_test_config();
let output_path = custom_output_path
.unwrap_or_else(|| format!("{}/imported_mainnet_txns", DEFAULT_OUTPUT_FOLDER));
Expand All @@ -102,7 +92,7 @@ mod tests {

let db_url = db.get_db_url();
let (indexer_processor_config, processor_name) =
setup_default_processor_config(&test_context, txn_version as u64, 1, &db_url).await;
setup_default_processor_config(&test_context, &db_url).await;

let default_processor = DefaultProcessor::new(indexer_processor_config)
.await
Expand All @@ -113,7 +103,6 @@ mod tests {
default_processor,
load_data,
db_url,
vec![txn_version],
diff_flag,
output_path.clone(),
test_case_name.clone(),
Expand All @@ -123,18 +112,18 @@ mod tests {
Ok(mut db_value) => {
let _ = validate_json(
&mut db_value,
txn_version as u64,
test_context.get_request_start_version(),
processor_name,
output_path.clone(),
test_case_name,
);
},
Err(e) => {
eprintln!(
"[ERROR] Failed to run processor for txn version {}: {}",
1, e
panic!(
"Test failed on transactions {:?} due to processor error: {}",
test_context.get_test_transaction_versions(),
e
);
panic!("Test failed due to processor error");
},
}
}
Expand Down
Loading
Loading