Skip to content

Commit

Permalink
Fix integration test and use 10 validators
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Feb 26, 2024
1 parent 862d140 commit d2a1881
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
20 changes: 2 additions & 18 deletions code/node/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
use std::net::{Ipv4Addr, SocketAddr};

use malachite_node::config::{Config, PeerConfig};
use malachite_node::network::PeerId;
use malachite_node::util::make_config;
use malachite_node::util::make_node;
use malachite_test::utils::make_validators;

use malachite_test::{Validator, ValidatorSet};
use malachite_test::ValidatorSet;
use tracing::info;

mod cli;
use cli::Cli;

const VOTING_PWERS: [u64; 3] = [5, 20, 10];

fn make_config<'a>(vs: impl Iterator<Item = &'a Validator>) -> Config {
let peers = vs
.enumerate()
.map(|(i, v)| PeerConfig {
id: PeerId::new(format!("node{}", i + 1)),
addr: SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1200 + i as u16 + 1),
public_key: v.public_key,
})
.collect();

Config { peers }
}

#[tokio::main(flavor = "current_thread")]
pub async fn main() {
tracing_subscriber::fmt::init();
Expand Down
19 changes: 19 additions & 0 deletions code/node/src/util/make_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::net::{Ipv4Addr, SocketAddr};

use malachite_test::Validator;

use crate::config::{Config, PeerConfig};
use crate::network::PeerId;

pub fn make_config<'a>(vs: impl Iterator<Item = &'a Validator>) -> Config {
let peers = vs
.enumerate()
.map(|(i, v)| PeerConfig {
id: PeerId::new(format!("node{}", i + 1)),
addr: SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1200 + i as u16 + 1),
public_key: v.public_key,
})
.collect();

Config { peers }
}
3 changes: 3 additions & 0 deletions code/node/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
mod make_node;
pub use make_node::make_node;

mod make_config;
pub use make_config::make_config;
11 changes: 5 additions & 6 deletions code/node/tests/broadcast_n3f0.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use malachite_common::Round;
use malachite_node::config::Config;
use malachite_node::util::make_node;
use malachite_node::util::{make_config, make_node};
use malachite_test::utils::make_validators;
use malachite_test::{Height, ValidatorSet, Value};

#[tokio::test]
pub async fn decide_on_value() {
tracing_subscriber::fmt::init();

// Validators keys are deterministic and match the ones in the config file
let vs = make_validators([2, 3, 2]);
let voting_powers = [5, 20, 10, 30, 15, 1, 5, 25, 10, 15];

let config = include_str!("../peers.toml");
let config = toml::from_str::<Config>(config).expect("Error: invalid peers.toml");
// Validators keys are deterministic and match the ones in the config file
let vs = make_validators(voting_powers);
let config = make_config(vs.iter().map(|(v, _)| v));

let mut handles = Vec::with_capacity(config.peers.len());

Expand Down

0 comments on commit d2a1881

Please sign in to comment.