From 0924f2edb3c6fe9bc7f3237c03a8ed4ed0a4e8e0 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Wed, 20 Nov 2024 12:42:11 +0100 Subject: [PATCH] add an e2e test to check for some governance behaviours --- crates/tests/src/e2e/ledger_tests.rs | 59 ++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/crates/tests/src/e2e/ledger_tests.rs b/crates/tests/src/e2e/ledger_tests.rs index 0f5a78bef66..8ea35ca8048 100644 --- a/crates/tests/src/e2e/ledger_tests.rs +++ b/crates/tests/src/e2e/ledger_tests.rs @@ -1985,7 +1985,6 @@ fn test_governance_voting() -> Result<()> { client.exp_string(TX_APPLIED_SUCCESS)?; client.assert_success(); - // 9. Send a yay vote from a validator let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap(); while epoch.0 <= 4 { sleep(10); @@ -2003,14 +2002,7 @@ fn test_governance_voting() -> Result<()> { "--node", &validator_one_rpc, ]; - - let mut client = run_as!( - test, - Who::Validator(0), - Bin::Client, - submit_proposal_vote, - Some(15) - )?; + let mut client = run!(test, Bin::Client, submit_proposal_vote, Some(40))?; client.exp_string(TX_APPLIED_SUCCESS)?; client.assert_success(); @@ -2044,6 +2036,27 @@ fn test_governance_voting() -> Result<()> { client.exp_string(TX_APPLIED_SUCCESS)?; client.assert_success(); + let tx_args = apply_use_device(vec![ + "bond", + "--validator", + "validator-1", + "--source", + CHRISTEL, + "--amount", + "300", + "--node", + &validator_0_rpc, + ]); + let mut client = run!(test, Bin::Client, tx_args, Some(40))?; + client.exp_string(TX_APPLIED_SUCCESS)?; + client.assert_success(); + + let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap(); + while epoch.0 <= 10 { + sleep(10); + epoch = get_epoch(&test, &validator_one_rpc).unwrap(); + } + let submit_proposal_vote = vec![ "vote-proposal", "--proposal-id", @@ -2066,6 +2079,28 @@ fn test_governance_voting() -> Result<()> { client.exp_string(TX_APPLIED_SUCCESS)?; client.assert_success(); + let submit_proposal_vote = vec![ + "vote-proposal", + "--proposal-id", + "0", + "--vote", + "yay", + "--address", + CHRISTEL, + "--node", + &validator_one_rpc, + ]; + + let mut client = run_as!( + test, + Who::Validator(0), + Bin::Client, + submit_proposal_vote, + Some(15) + )?; + client.exp_string(TX_REJECTED)?; + client.assert_success(); + let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap(); while epoch.0 <= 21 { sleep(10); @@ -2083,9 +2118,9 @@ fn test_governance_voting() -> Result<()> { let mut client = run!(test, Bin::Client, query_proposal, Some(15))?; client.exp_string("Proposal Id: 0")?; client.exp_string( - " Rejected with 0.000000 yay votes, 1800.000000 nay votes \ - and 0.000000 abstain votes, total voting power: 102300.000000, \ - threshold (fraction) of total voting power needed to tally: 40920.00000", + " Rejected with 0.000000 yay votes, 2300.000000 nay votes \ + and 0.000000 abstain votes, total voting power: 102600.000000, \ + threshold (fraction) of total voting power needed to tally: 41040.00000", )?; client.assert_success();