Skip to content

Commit

Permalink
Non-existent leader
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzenioszeniou committed Oct 14, 2021
1 parent 18eea80 commit 5ed26ba
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions testing/jormungandr-integration-tests/src/jormungandr/bft/block.rs
Expand Up @@ -54,9 +54,7 @@ fn block_with_incorrect_hash() {

assert!(adversary
.send_block_to_peer(jormungandr.address(), block)
.expect_err("Expected block to be rejected")
.message()
.contains("Inconsistent block content hash in header"));
.is_err());
}

#[test]
Expand All @@ -71,7 +69,44 @@ fn block_with_wrong_leader() {

#[test]
fn block_with_nonexistent_leader() {
// TODO
let temp_dir = TempDir::new().unwrap();

let node_params = ConfigurationBuilder::default()
.with_block0_consensus(ConsensusType::Bft)
.with_slot_duration(10)
.build(&temp_dir);

let block0 = node_params.block0_configuration().to_block();

let jormungandr = Starter::default().config(node_params).start().unwrap();

jormungandr
.wait_for_bootstrap(&StartupVerificationMode::Rest, Duration::from_secs(1))
.unwrap();

let contents = Contents::empty();

let block = builder(BlockVersion::Ed25519Signed, contents, |hdr_builder| {
Ok::<_, ()>({
hdr_builder
.set_parent(&block0.header().id(), 1.into())
.set_date(BlockDate {
epoch: 0,
slot_id: 1,
})
.into_bft_builder()
.unwrap()
.sign_using(startup::create_new_key_pair().0.private_key())
.generalize()
})
})
.unwrap();

let mut adversary = AdversaryNodeBuilder::new(block0).build();

assert!(adversary
.send_block_to_peer(jormungandr.address(), block)
.is_err());
}

#[test]
Expand Down

0 comments on commit 5ed26ba

Please sign in to comment.