Skip to content

Commit

Permalink
revive vote_plan_in_block0_with_input test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Sep 21, 2020
1 parent 2f1370f commit 071f119
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions chain-impl-mockchain/src/ledger/tests/certificate_tests/voting.rs
Expand Up @@ -2,9 +2,11 @@

use crate::{
key::BftLeaderId,
ledger::ledger::{Block0Error, Error},
testing::{
builders::{
create_initial_vote_cast, create_initial_vote_plan, InitialFaultTolerantTxCertBuilder,
create_initial_vote_cast, create_initial_vote_plan, create_initial_vote_tally,
InitialFaultTolerantTxCertBuilder,
},
data::Wallet,
ConfigBuilder, LedgerBuilder, VoteTestGen,
Expand All @@ -28,24 +30,19 @@ pub fn vote_plan_in_block0() {
.expect("ledger should be built with vote plan certificate");
}

#[ignore]
#[test]
#[should_panic]
pub fn vote_plan_in_block0_with_input() {
let alice = Wallet::from_value(Value(100));
let vote_plan = VoteTestGen::vote_plan();
let vote_plan_certificate =
InitialFaultTolerantTxCertBuilder::new(vote_plan.into(), alice.clone())
.transaction_with_input_only();

let ledger_build_result = LedgerBuilder::from_config(ConfigBuilder::new(0))
let _ = LedgerBuilder::from_config(ConfigBuilder::new(0))
.faucets_wallets(vec![&alice])
.certs(&[vote_plan_certificate])
.build();

assert!(
ledger_build_result.is_err(),
"ledger should not be built with faulty vote plan certificate"
);
}

#[test]
Expand Down Expand Up @@ -85,3 +82,38 @@ pub fn vote_cast_in_block0() {
"ledger should not be built with faulty vote plan certificate"
);
}

#[test]
pub fn vote_cast_is_not_allowed_in_block0() {
let alice = Wallet::from_value(Value(100));
let vote_cast = VoteTestGen::vote_cast();
let vote_cast_cert = create_initial_vote_cast(&vote_cast, &[alice.clone()]);

let ledger_builder_result = LedgerBuilder::from_config(ConfigBuilder::new(0))
.faucets_wallets(vec![&alice])
.certs(&[vote_cast_cert])
.build();

assert_eq!(
ledger_builder_result.err().unwrap(),
Error::Block0(Block0Error::HasVoteCast)
);
}

#[test]
pub fn vote_tally_is_not_allowed_in_block0() {
let alice = Wallet::from_value(Value(100));
let vote_tally = VoteTestGen::vote_tally();

let vote_tally_cert = create_initial_vote_tally(&vote_tally, &[alice.clone()]);

let ledger_builder_result = LedgerBuilder::from_config(ConfigBuilder::new(0))
.faucets_wallets(vec![&alice])
.certs(&[vote_tally_cert])
.build();

assert_eq!(
ledger_builder_result.err().unwrap(),
Error::Block0(Block0Error::HasVoteTally)
);
}

0 comments on commit 071f119

Please sign in to comment.