From 733788d3303a37b58b38c667f652b8831f1081d8 Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Mon, 6 May 2024 13:43:09 +0100 Subject: [PATCH] Fix integration tests --- crates/tests/src/integration/ledger_tests.rs | 83 +++++++++++++++++--- crates/tests/src/integration/masp.rs | 26 +++--- 2 files changed, 86 insertions(+), 23 deletions(-) diff --git a/crates/tests/src/integration/ledger_tests.rs b/crates/tests/src/integration/ledger_tests.rs index c983aaef53..4b044a1a8c 100644 --- a/crates/tests/src/integration/ledger_tests.rs +++ b/crates/tests/src/integration/ledger_tests.rs @@ -19,8 +19,8 @@ use test_log::test; use crate::e2e::ledger_tests::prepare_proposal_data; use crate::e2e::setup::constants::{ - ALBERT, ALBERT_KEY, BERTHA, BERTHA_KEY, CHRISTEL, CHRISTEL_KEY, DAEWON, - ESTER, GOVERNANCE_ADDRESS, NAM, + ALBERT, ALBERT_KEY, APFEL, BERTHA, BERTHA_KEY, BTC, CHRISTEL, CHRISTEL_KEY, + DAEWON, DOT, ESTER, ETH, GOVERNANCE_ADDRESS, KARTOFFEL, NAM, SCHNITZEL, }; use crate::integration::helpers::{ find_address, prepare_steward_commission_update_data, @@ -209,19 +209,80 @@ fn ledger_txs_and_queries() -> Result<()> { // expect a decimal vec![r"nam: \d+(\.\d+)?"], ), - // Unspecified token expect all tokens from wallet derived from genesis + // Test balance of tokens generated at genesis ( - vec!["balance", "--owner", ALBERT, "--node", &validator_one_rpc], - // expect all genesis tokens, sorted by alias vec![ - r"apfel: \d+(\.\d+)?", - r"btc: \d+(\.\d+)?", - r"dot: \d+(\.\d+)?", - r"eth: \d+(\.\d+)?", - r"kartoffel: \d+(\.\d+)?", - r"schnitzel: \d+(\.\d+)?", + "balance", + "--owner", + ALBERT, + "--token", + APFEL, + "--node", + &validator_one_rpc, + ], + vec![r"apfel: \d+(\.\d+)?"], + ), + ( + vec![ + "balance", + "--owner", + ALBERT, + "--token", + BTC, + "--node", + &validator_one_rpc, + ], + vec![r"btc: \d+(\.\d+)?"], + ), + ( + vec![ + "balance", + "--owner", + ALBERT, + "--token", + DOT, + "--node", + &validator_one_rpc, + ], + vec![r"dot: \d+(\.\d+)?"], + ), + ( + vec![ + "balance", + "--owner", + ALBERT, + "--token", + ETH, + "--node", + &validator_one_rpc, + ], + vec![r"eth: \d+(\.\d+)?"], + ), + ( + vec![ + "balance", + "--owner", + ALBERT, + "--token", + KARTOFFEL, + "--node", + &validator_one_rpc, + ], + vec![r"kartoffel: \d+(\.\d+)?"], + ), + ( + vec![ + "balance", + "--owner", + ALBERT, + "--token", + SCHNITZEL, + "--node", + &validator_one_rpc, ], + vec![r"schnitzel: \d+(\.\d+)?"], ), + // Account query ( vec![ "query-account", diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 68fdae89e3..4e4ad6de94 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -109,7 +109,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found")); + assert!(captured.contains("nam: 0")); // Wait till epoch boundary node.next_epoch(); @@ -318,7 +318,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found")); + assert!(captured.contains("nam: 0")); // Wait till epoch boundary node.next_epoch(); @@ -439,7 +439,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded eth balance found")); + assert!(captured.contains("eth: 0")); node.next_epoch(); // sync the shielded context @@ -549,7 +549,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded btc balance found")); + assert!(captured.contains("btc: 0")); // Assert VK(A) retained the NAM rewards let captured = CapturedOutput::of(|| { @@ -750,7 +750,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found")); + assert!(captured.contains("nam: 0")); // sync the shielded context run( @@ -776,7 +776,7 @@ fn masp_incentives() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found")); + assert!(captured.contains("nam: 0")); // Assert NAM balance at MASP pool is nearly 0 let captured = CapturedOutput::of(|| { @@ -1132,7 +1132,7 @@ fn masp_txs_and_queries() -> Result<()> { "--node", validator_one_rpc, ], - Response::Ok("No shielded btc balance found"), + Response::Ok("btc: 0"), ), // 9. Assert ETH balance at VK(A) is 0 ( @@ -1145,7 +1145,7 @@ fn masp_txs_and_queries() -> Result<()> { "--node", validator_one_rpc, ], - Response::Ok("No shielded eth balance found"), + Response::Ok("eth: 0"), ), // 10. Assert balance at VK(B) is 20 BTC ( @@ -1153,10 +1153,12 @@ fn masp_txs_and_queries() -> Result<()> { "balance", "--owner", AB_VIEWING_KEY, + "--token", + BTC, "--node", validator_one_rpc, ], - Response::Ok("btc : 20"), + Response::Ok("btc: 20"), ), // 11. Send 20 BTC from SK(B) to Bertha ( @@ -2155,7 +2157,7 @@ fn dynamic_assets() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found for given key")); + assert!(captured.contains("nam: 0")); { // Start decoding and distributing shielded rewards for BTC in next @@ -2224,7 +2226,7 @@ fn dynamic_assets() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found for given key")); + assert!(captured.contains("nam: 0")); // Send 1 BTC from Albert to PA run( @@ -2289,7 +2291,7 @@ fn dynamic_assets() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("No shielded nam balance found for given key")); + assert!(captured.contains("nam: 0")); // Wait till epoch boundary node.next_epoch();