hbbft/tests/subset.rs

166 lines
5.1 KiB
Rust
Raw Permalink Normal View History

#![deny(unused_must_use)]
2018-05-15 04:49:39 -07:00
use std::collections::{BTreeMap, BTreeSet};
use std::iter::once;
use std::sync::Arc;
2018-05-15 04:49:39 -07:00
use hbbft::subset::{Subset, SubsetOutput};
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
use hbbft::ConsensusProtocol;
use hbbft_testing::adversary::{Adversary, NodeOrderAdversary, ReorderingAdversary};
use hbbft_testing::proptest::{gen_seed, TestRng, TestRngSeed};
use hbbft_testing::{NetBuilder, NewNodeInfo, VirtualNet};
use proptest::{prelude::ProptestConfig, proptest};
use rand::SeedableRng;
2018-05-15 04:49:39 -07:00
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
type NodeId = u16;
type ProposedValue = Vec<u8>;
2018-05-15 04:49:39 -07:00
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
fn test_subset<A>(
mut net: VirtualNet<Subset<NodeId, u8>, A>,
2018-08-29 09:08:35 -07:00
inputs: &BTreeMap<NodeId, ProposedValue>,
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
mut rng: &mut TestRng,
) where
A: Adversary<Subset<NodeId, u8>>,
{
let ids: Vec<NodeId> = net.nodes().map(|node| *node.id()).collect();
2018-05-15 04:49:39 -07:00
for id in ids {
if let Some(value) = inputs.get(&id) {
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
let _ = net.send_input(id, value.to_owned(), &mut rng);
2018-05-15 04:49:39 -07:00
}
}
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
// Handle messages until all good nodes have terminated.
while !net.nodes().all(|node| node.algorithm().terminated()) {
let _ = net.crank_expect(&mut rng);
}
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
// Get reference value from the first correct node.
// TODO: Revisit when observers are available in the new net simulator
// or drop this TODO if we decide to abandon that concept.
let expected_value: BTreeSet<_> = net
.correct_nodes()
.next()
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
.unwrap()
.outputs()
.iter()
.cloned()
.collect();
// Verify that all correct nodes output the same value.
for node in net.correct_nodes() {
let outputs = node.outputs();
let mut actual = BTreeMap::default();
let mut has_seen_done = false;
for i in outputs {
assert!(!has_seen_done);
match i {
SubsetOutput::Contribution(k, v) => {
assert!(actual.insert(k, v).is_none());
}
SubsetOutput::Done => has_seen_done = true,
}
2018-05-15 04:49:39 -07:00
}
assert_eq!(outputs.len(), actual.len() + 1);
// The Subset algorithm guarantees that more than two thirds of the proposed elements
// are in the set.
assert!(actual.len() * 3 > inputs.len() * 2);
for (id, value) in actual {
assert_eq!(&inputs[id], value);
}
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
assert_eq!(
outputs.iter().cloned().collect::<BTreeSet<_>>(),
expected_value
);
2018-05-15 04:49:39 -07:00
}
}
fn new_network<A, F>(
good_num: usize,
bad_num: usize,
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
mut rng: &mut TestRng,
adversary: F,
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
) -> VirtualNet<Subset<NodeId, u8>, A>
where
2018-10-24 00:42:59 -07:00
A: Adversary<Subset<NodeId, u8>>,
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
F: Fn() -> A,
{
// This returns an error in all but the first test.
2018-05-15 04:49:39 -07:00
let _ = env_logger::try_init();
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
let size = good_num + bad_num;
let (net, _) = NetBuilder::new(0..size as u16)
.num_faulty(bad_num as usize)
.message_limit(10_000 * size as usize)
.no_time_limit()
.adversary(adversary())
.using(move |node_info: NewNodeInfo<_>| {
Subset::new(Arc::new(node_info.netinfo), 0).expect("new Subset instance")
})
.build(&mut rng)
.expect("Could not construct test network.");
net
}
proptest! {
#![proptest_config(ProptestConfig {
cases: 1, .. ProptestConfig::default()
})]
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_subset_3_out_of_4_nodes_propose(seed in gen_seed()) {
do_test_subset_3_out_of_4_nodes_propose(seed)
}
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_subset_5_nodes_different_proposed_values(seed in gen_seed()) {
do_test_subset_5_nodes_different_proposed_values(seed)
}
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_subset_1_node(seed in gen_seed()) {
do_test_subset_1_node(seed)
}
2018-05-15 04:49:39 -07:00
}
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
fn do_test_subset_3_out_of_4_nodes_propose(seed: TestRngSeed) {
2018-05-15 04:49:39 -07:00
let proposed_value = Vec::from("Fake news");
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
let proposing_ids: BTreeSet<NodeId> = (0..3).collect();
2018-08-29 09:08:35 -07:00
let proposals: BTreeMap<NodeId, ProposedValue> = proposing_ids
.iter()
2018-05-15 14:25:41 -07:00
.map(|id| (*id, proposed_value.clone()))
.collect();
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
let mut rng: TestRng = TestRng::from_seed(seed);
let net = new_network(3, 1, &mut rng, NodeOrderAdversary::new);
test_subset(net, &proposals, &mut rng);
2018-05-15 04:49:39 -07:00
}
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
fn do_test_subset_5_nodes_different_proposed_values(seed: TestRngSeed) {
let proposed_values = vec![
Vec::from("Alpha"),
Vec::from("Bravo"),
Vec::from("Charlie"),
Vec::from("Delta"),
Vec::from("Echo"),
];
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
let proposals: BTreeMap<NodeId, ProposedValue> = (0..5).zip(proposed_values).collect();
let mut rng: TestRng = TestRng::from_seed(seed);
let net = new_network(5, 0, &mut rng, ReorderingAdversary::new);
test_subset(net, &proposals, &mut rng);
}
2018-07-09 02:36:30 -07:00
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
fn do_test_subset_1_node(seed: TestRngSeed) {
2018-08-29 09:08:35 -07:00
let proposals: BTreeMap<NodeId, ProposedValue> =
Ported more integration tests to the new net simulator (#387) * Ported threshold_sign test to the new framework * Ported the first three broadcast tests to the new framework * Extracted messages storting and random swapping to reusable functions Used to compose ProposeAdversary's behavior without having to duplicate code * Implemented ProposeAdversary for the new integration testing framework Added "id()" function to the "NodeMutHandle", required for sending messages to all nodes ProposeAdversary needs access to all faulty node's netinfo. We follow the example of the binary_agreement_mitm integration test of using an reference counted Mutex to make netinfo available on both Consensus Protocol construction and in the Adversary implementation. Unlike binary_agreement_mitm every faulty node needs to use its own netinfo for the broadcast algorithm, so we store all nodeinfo structures in a Map instead of just the nodeinfo of the first node. Ideallly the new network simulation library should provide netinfo similar to the old library to avoid these hideous workarounds. * Migrated test_broadcast_random_delivery_adv_propose to the new network simulator Refactored the implementation of ProposeAdversary to closely resemble the behavior in the old network simulator library. Implemented a pick_random_node function to sort messages for a random node id. Switched from using "inject_message" to joining messages generated by adversaries' temporary Broadcast Consensus Protocols with the Step generated by regular operation. * Ported RandomAdversary to the new network simulator library Ported all broadcast integration tests and replaced the old tests with the new. * Eliminated the old broadcast integration test, replaced with the new * Ported subset test to the new framework Adjusted message queue size as suggested by Andreas * Ported the first three honey_badger tests to the new framework * Re-implemented FaultyShareAdversary for the new framework Eliminated the old honey_badger integration tests, replaced with implementations using the new net simulator framework * Fixed issues reported by clippy * Fixed issues reported on code review * Fixed issues reported by clippy * Implemented a broadcast test dropping messages similar to the tests written in the old framework * Picking the proposer id at random, verifying all possible output cases If the proposer is faulty the message queue may starve, but the outputs of all correct nodes need to be empty, if the broadcast protocol produces output nonetheless all correct nodes need to have the same output. If the proposer was correct all correct nodes need to output its proposed value. * Eliminated duplicated semicolon * Consistently using TestRng and proptest in all newly ported tests * Increased the drop_and_re_add test message limit to 20k per node * Removed unnecessary closure * Increased the tolerance for deviations from the expected value range to eliminate random test failures
2019-03-14 06:41:23 -07:00
once((0, Vec::from("Node 0 is the greatest!"))).collect();
let mut rng: TestRng = TestRng::from_seed(seed);
let net = new_network(1, 0, &mut rng, ReorderingAdversary::new);
test_subset(net, &proposals, &mut rng);
2018-07-09 02:36:30 -07:00
}