Skip to content

Commit

Permalink
add an e2e test to check for some governance behaviours
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Nov 20, 2024
1 parent 6d0c6a7 commit 0924f2e
Showing 1 changed file with 47 additions and 12 deletions.
59 changes: 47 additions & 12 deletions crates/tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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",
Expand All @@ -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);
Expand All @@ -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();

Expand Down

0 comments on commit 0924f2e

Please sign in to comment.