Non-existent leader
@@ -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]
@@ -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]
