Skip to content

Commit

Permalink
patch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Dec 4, 2024
1 parent e8fd667 commit 523184a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/load_tx_cypher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
21 changes: 20 additions & 1 deletion tests/test_json_rescue_v5_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
25 changes: 12 additions & 13 deletions tests/test_load_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Check failure on line 21 in tests/test_load_tx.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `events`
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);
Expand All @@ -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]->()
Expand All @@ -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
Expand All @@ -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(())
}
Expand Down

0 comments on commit 523184a

Please sign in to comment.