From 523184a0cde2380015e1289478e9247463d41b4e Mon Sep 17 00:00:00 2001 From: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:59:53 -0500 Subject: [PATCH] patch tests --- src/load_tx_cypher.rs | 1 + tests/test_json_rescue_v5_load.rs | 21 ++++++++++++++++++++- tests/test_load_tx.rs | 25 ++++++++++++------------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/load_tx_cypher.rs b/src/load_tx_cypher.rs index 1906381..0e64864 100644 --- a/src/load_tx_cypher.rs +++ b/src/load_tx_cypher.rs @@ -121,6 +121,7 @@ pub async fn impl_batch_tx_insert( .context("no unchanged_accounts field")?; let cypher_string = write_batch_tx_string(&list_str); + // Execute the query let cypher_query = query(&cypher_string); let mut res = pool.execute(cypher_query).await.context(format!( diff --git a/tests/test_json_rescue_v5_load.rs b/tests/test_json_rescue_v5_load.rs index cf42244..3fbb143 100644 --- a/tests/test_json_rescue_v5_load.rs +++ b/tests/test_json_rescue_v5_load.rs @@ -92,7 +92,26 @@ async fn test_rescue_v5_parse_set_wallet_tx() -> anyhow::Result<()> { .await .expect("could start index"); - let _res = tx_batch(&vec_tx, &pool, 100, "test-set-wallet").await?; + let res = tx_batch(&vec_tx, &pool, 100, "test-set-wallet").await?; + assert!(res.created_tx > 0); + dbg!(&res); + + // check there are transaction records with function args. + let cypher_query = neo4rs::query( + "MATCH ()-[r:Tx]->() + // WHERE r.args IS NOT NULL + RETURN r + LIMIT 1 + ", + ); + + // Execute the query + let mut result = pool.execute(cypher_query).await?; + + // Fetch the first row only + let row = result.next().await?; + // let total_tx_count: i64 = row.get("total_tx_count").unwrap(); + dbg!(&row); Ok(()) } diff --git a/tests/test_load_tx.rs b/tests/test_load_tx.rs index 7ec07c2..25bcf6c 100644 --- a/tests/test_load_tx.rs +++ b/tests/test_load_tx.rs @@ -19,9 +19,7 @@ async fn test_tx_batch() -> anyhow::Result<()> { libra_forensic_db::log_setup(); let archive_path = support::fixtures::v6_tx_manifest_fixtures_path(); let (txs, events) = extract_current_transactions(&archive_path).await?; - dbg!(&txs.len()); - // assert!(txs.len() == 705); - // assert!(events.len() == 52); + assert!(txs.len() == 27); let c = start_neo4j_container(); let port = c.get_host_port_ipv4(7687); @@ -35,11 +33,12 @@ async fn test_tx_batch() -> anyhow::Result<()> { // load in batches let archive_id = archive_path.file_name().unwrap().to_str().unwrap(); let res = tx_batch(&txs, &graph, 100, archive_id).await?; - dbg!(&res); - // assert!(res.created_accounts == 60); - // assert!(res.modified_accounts == 228); - // assert!(res.unchanged_accounts == 0); - // assert!(res.created_tx == txs.len() as u64); + + assert!(res.unique_accounts == 25); + assert!(res.created_accounts == 25); + assert!(res.modified_accounts == 0); + assert!(res.unchanged_accounts == 0); + assert!(res.created_tx == txs.len() as u64); let cypher_query = query( "MATCH ()-[r:Tx]->() @@ -52,13 +51,13 @@ async fn test_tx_batch() -> anyhow::Result<()> { // Fetch the first row only let row = result.next().await?.unwrap(); let total_tx_count: i64 = row.get("total_tx_count").unwrap(); - // assert!(total_tx_count == txs.len() as i64); + assert!(total_tx_count == txs.len() as i64); // check there are transaction records with function args. let cypher_query = query( "MATCH ()-[r:Tx]->() - WHERE r.args IS NOT NULL - RETURN count(r) AS total_tx_count", + WHERE r.V7_OlAccountTransfer_amount IS NOT NULL + RETURN COUNT(r) AS total_tx_count", ); // Execute the query @@ -67,8 +66,8 @@ async fn test_tx_batch() -> anyhow::Result<()> { // Fetch the first row only let row = result.next().await?.unwrap(); let total_tx_count: i64 = row.get("total_tx_count").unwrap(); - dbg!(&total_tx_count); - // assert!(total_tx_count == txs.len() as i64); + + assert!(total_tx_count == 24); Ok(()) }