Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed May 6, 2024
1 parent 9aa20ad commit 733788d
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 23 deletions.
83 changes: 72 additions & 11 deletions crates/tests/src/integration/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
26 changes: 14 additions & 12 deletions crates/tests/src/integration/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(|| {
Expand Down Expand Up @@ -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(
Expand All @@ -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(|| {
Expand Down Expand Up @@ -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
(
Expand All @@ -1145,18 +1145,20 @@ 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
(
vec![
"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
(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 733788d

Please sign in to comment.