hbbft/tests/honey_badger.rs

296 lines
11 KiB
Rust
Raw Normal View History

#![deny(unused_must_use)]
//! Network tests for Honey Badger.
use std::collections::BTreeMap;
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 std::sync::{Arc, Mutex};
use hbbft::honey_badger::{Batch, EncryptionSchedule, HoneyBadger, MessageContent};
2018-10-25 08:07:52 -07:00
use hbbft::sender_queue::{self, SenderQueue, Step};
use hbbft::transaction_queue::TransactionQueue;
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::{threshold_decrypt, util, CpStep, NetworkInfo, Target};
use hbbft_testing::adversary::{
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
sort_by_random_node, Adversary, NetMutHandle, NodeOrderAdversary, RandomAdversary,
ReorderingAdversary,
};
use hbbft_testing::proptest::{gen_seed, TestRng, TestRngSeed};
use hbbft_testing::{CrankError, NetBuilder, NetMessage, NewNodeInfo, Node, VirtualNet};
use itertools::Itertools;
use log::info;
use proptest::{prelude::ProptestConfig, proptest};
use rand::{seq::SliceRandom, Rng, SeedableRng};
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 NetworkInfoMap = BTreeMap<NodeId, Arc<NetworkInfo<NodeId>>>;
2018-10-25 08:07:52 -07:00
type UsizeHoneyBadger = SenderQueue<HoneyBadger<Vec<usize>, NodeId>>;
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 HoneyBadgerMessage = NetMessage<UsizeHoneyBadger>;
/// An adversary whose nodes only send messages with incorrect decryption shares.
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
#[derive(Clone, Debug, Default)]
pub struct FaultyShareAdversary {
share_triggers: BTreeMap<u64, bool>,
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
// TODO this is really hacky but there's no better way to get this value
// Solution taken from binary_agreement_mitm test - ideally the new network simulator
// should be altered to store the netinfo structure alongside nodes similar to
// the way the old network simulator did it.
netinfo_mutex: Arc<Mutex<NetworkInfoMap>>,
}
impl FaultyShareAdversary {
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
/// Creates a new adversary with the necessary network info instances
pub fn new(netinfo_mutex: Arc<Mutex<NetworkInfoMap>>) -> Self {
FaultyShareAdversary {
share_triggers: BTreeMap::new(),
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
netinfo_mutex,
}
}
}
impl Adversary<UsizeHoneyBadger> for FaultyShareAdversary {
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
#[inline]
fn pre_crank<R: Rng>(
&mut self,
mut net: NetMutHandle<'_, UsizeHoneyBadger, Self>,
rng: &mut R,
) {
sort_by_random_node(&mut net, 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
#[inline]
fn tamper<R: Rng>(
&mut self,
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 net: NetMutHandle<'_, UsizeHoneyBadger, Self>,
msg: HoneyBadgerMessage,
rng: &mut R,
) -> Result<CpStep<UsizeHoneyBadger>, CrankError<UsizeHoneyBadger>> {
if let sender_queue::Message::Algo(hb_msg) = msg.payload() {
let epoch = hb_msg.epoch();
// Set the trigger to simulate decryption share messages
// if epoch has not been encountered yet.
self.share_triggers.entry(epoch).or_insert(true);
}
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 step = net.dispatch_message(msg, 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
let fake_proposal = &Vec::from("X marks the spot");
// For each untriggered epoch, send fake shares
for (epoch, trigger_set) in &mut self.share_triggers {
if *trigger_set {
// Unset the trigger.
*trigger_set = false;
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 node id vectors up-front to avoid borrow issues
let faulty_node_ids: Vec<NodeId> =
net.faulty_nodes_mut().map(|node| *node.id()).collect();
let all_node_ids: Vec<NodeId> = net.nodes_mut().map(|node| node.id()).collect();
// Broadcast fake decryption shares from all adversarial nodes.
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
for faulty_node_id in faulty_node_ids {
// get the adversarial's net info
let netinfo = self
.netinfo_mutex
.lock()
.unwrap()
.get(&faulty_node_id)
.cloned()
.expect("Adversary netinfo mutex not populated");
// encrypt false share
let fake_ciphertext = (*netinfo)
.public_key_set()
.public_key()
.encrypt(fake_proposal);
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 share = netinfo
2018-07-17 06:54:12 -07:00
.secret_key_share()
.expect("missing adversary key share")
.decrypt_share(&fake_ciphertext)
.expect("decryption share");
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
// Send the share to remote nodes.
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
for proposer_id in &all_node_ids {
step.messages.push(
Target::all().message(sender_queue::Message::Algo(
MessageContent::DecryptionShare {
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
proposer_id: *proposer_id,
share: threshold_decrypt::Message(share.clone()),
}
.with_epoch(*epoch),
2018-10-25 08:07:52 -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
);
}
}
}
}
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
Ok(step)
}
}
/// Proposes `num_txs` values and expects nodes to output and order them.
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_honey_badger<A>(
mut net: VirtualNet<UsizeHoneyBadger, A>,
num_txs: usize,
mut rng: &mut TestRng,
) where
A: Adversary<UsizeHoneyBadger>,
{
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 queues: BTreeMap<_, _> = net
.correct_nodes()
.map(|node| (*node.id(), (0..num_txs).collect::<Vec<usize>>()))
.collect();
// Returns `true` if the node has not output all transactions yet.
// If it has, and has advanced another epoch, it clears all messages for later epochs.
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 node_busy = |node: &Node<UsizeHoneyBadger>| {
node.outputs().iter().flat_map(Batch::iter).unique().count() < num_txs
};
// Handle messages in random order until all nodes have output all transactions.
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
while net.correct_nodes().any(node_busy) {
// If a node is expecting input, take it from the queue. Otherwise handle a message.
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 input_ids: Vec<_> = net
.correct_nodes()
.filter(|node| !node.algorithm().algo().has_input())
.map(|node| *node.id())
.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
if let Some(id) = input_ids[..].choose(&mut rng) {
let queue = queues.get_mut(id).unwrap();
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
queue.remove_multiple(net.get(*id).unwrap().outputs().iter().flat_map(Batch::iter));
let _ = net.send_input(*id, queue.choose(&mut rng, 3, 10), &mut rng);
} else {
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.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
verify_output_sequence(&net);
}
/// Verifies that all instances output the same sequence of batches.
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 verify_output_sequence<A>(network: &VirtualNet<UsizeHoneyBadger, A>)
where
A: Adversary<UsizeHoneyBadger>,
{
2018-11-22 03:32:51 -08:00
let mut expected: Option<BTreeMap<u64, &_>> = None;
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
for node in network.correct_nodes() {
assert!(!node.outputs().is_empty());
2018-11-22 03:32:51 -08:00
let outputs: BTreeMap<u64, &BTreeMap<NodeId, Vec<usize>>> = node
.outputs()
.iter()
2018-11-22 03:32:51 -08:00
.map(|batch| (batch.epoch, &batch.contributions))
.collect();
if expected.is_none() {
expected = Some(outputs);
} else if let Some(expected) = &expected {
assert_eq!(expected, &outputs);
}
}
}
2018-10-25 08:07:52 -07:00
fn new_honey_badger(
netinfo: Arc<NetworkInfo<NodeId>>,
) -> (UsizeHoneyBadger, Step<HoneyBadger<Vec<usize>, NodeId>>) {
let nc = netinfo.clone();
2019-07-23 02:23:42 -07:00
let peer_ids = nc.other_ids().cloned();
let hb = HoneyBadger::builder(netinfo)
.encryption_schedule(EncryptionSchedule::EveryNthEpoch(2))
.build();
2019-07-23 02:23:42 -07:00
let our_id = *nc.our_id();
SenderQueue::builder(hb, peer_ids).build(our_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
fn test_honey_badger_different_sizes<A, F>(
new_adversary: F,
num_txs: usize,
seed: TestRngSeed,
adversary_netinfo: &Arc<Mutex<NetworkInfoMap>>,
) where
A: Adversary<UsizeHoneyBadger>,
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.
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 mut rng: TestRng = TestRng::from_seed(seed);
let sizes = vec![1, 2, 3, 5, rng.gen_range(6, 10)];
for size in sizes {
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
// cloning since it gets moved into a closure
let cloned_netinfo_map = adversary_netinfo.clone();
let num_adv_nodes = util::max_faulty(size);
let num_good_nodes = size - num_adv_nodes;
info!(
"Network size: {} good nodes, {} faulty nodes",
num_good_nodes, num_adv_nodes
);
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, _) = NetBuilder::new(0..size as u16)
.num_faulty(num_adv_nodes as usize)
.message_limit(10_000 * size as usize)
.no_time_limit()
.adversary(new_adversary())
.using_step(move |info: NewNodeInfo<_>| {
let netinfo = Arc::new(info.netinfo);
cloned_netinfo_map
.lock()
.unwrap()
.insert(info.id, netinfo.clone());
new_honey_badger(netinfo)
})
.build(&mut rng)
.expect("Could not construct test network.");
test_honey_badger(net, num_txs, &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
proptest! {
#![proptest_config(ProptestConfig {
cases: 1, .. ProptestConfig::default()
})]
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_honey_badger_random_delivery_silent(seed in gen_seed()) {
do_test_honey_badger_random_delivery_silent(seed)
}
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_honey_badger_first_delivery_silent(seed in gen_seed()) {
do_test_honey_badger_first_delivery_silent(seed)
}
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_honey_badger_faulty_share(seed in gen_seed()) {
do_test_honey_badger_faulty_share(seed)
}
#[test]
#[allow(clippy::unnecessary_operation)]
fn test_honey_badger_random_adversary(seed in gen_seed()) {
do_test_honey_badger_random_adversary(seed)
}
}
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_honey_badger_random_delivery_silent(seed: TestRngSeed) {
test_honey_badger_different_sizes(ReorderingAdversary::new, 30, seed, &Default::default());
}
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_honey_badger_first_delivery_silent(seed: TestRngSeed) {
test_honey_badger_different_sizes(NodeOrderAdversary::new, 30, seed, &Default::default());
}
fn do_test_honey_badger_faulty_share(seed: TestRngSeed) {
let adversary_netinfo: Arc<Mutex<NetworkInfoMap>> = Default::default();
let new_adversary = || FaultyShareAdversary::new(adversary_netinfo.clone());
test_honey_badger_different_sizes(new_adversary, 8, seed, &adversary_netinfo);
}
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_honey_badger_random_adversary(seed: TestRngSeed) {
let new_adversary = || {
// A 10% injection chance is roughly ~13k extra messages added.
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
RandomAdversary::new(0.1, 0.1)
};
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
test_honey_badger_different_sizes(new_adversary, 8, seed, &Default::default());
}