Skip to content

Commit

Permalink
unignore topic of interest test
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Jun 17, 2020
1 parent 7a92688 commit 6089bb1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ impl JormungandrLogger {
== count)
}

pub fn print_error_and_invalid_logs(&self) {
pub fn print_error_and_invalid_logs(&self, alias: Option<String>) {
let error_lines: Vec<_> = self.get_lines_with_error_and_invalid().collect();
if !error_lines.is_empty() {
println!("Error lines:");
match alias {
Some(alias) => println!("Error lines ({}):", alias),
None => println!("Error lines:"),
}

for line in error_lines {
println!("{}", line);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ impl Drop for JormungandrProcess {

// FIXME: These should be better done in a test harness
self.child.wait().unwrap();
self.logger.print_error_and_invalid_logs();
self.logger
.print_error_and_invalid_logs(Some(self.alias.clone()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ use crate::common::{
jormungandr::starter::{Starter, StartupError},
jormungandr::JormungandrProcess,
};
use chain_impl_mockchain::header::HeaderId;
use jormungandr_lib::interfaces::{Log, LogEntry, LogOutput, NodeConfig};
use jormungandr_testing_utils::testing::network_builder::NodeSetting;
use jormungandr_testing_utils::testing::network_builder::{
LeadershipMode, PersistenceMode, Settings, SpawnParams, Wallet,
use chain_impl_mockchain::{fee::LinearFee, header::HeaderId};
use jormungandr_lib::{
crypto::hash::Hash,
interfaces::{Log, LogEntry, LogOutput, NodeConfig},
};
use jormungandr_testing_utils::testing::{
network_builder::{LeadershipMode, PersistenceMode, Settings, SpawnParams},
FragmentSender, FragmentSenderSetup, FragmentSenderSetupBuilder,
};
use jormungandr_testing_utils::{testing::network_builder::NodeSetting, wallet::Wallet};

use assert_fs::fixture::FixtureError;
use assert_fs::prelude::*;
Expand Down Expand Up @@ -60,7 +64,7 @@ impl Controller {

pub fn wallet(&mut self, wallet: &str) -> Result<Wallet, ControllerError> {
if let Some(wallet) = self.settings.wallets.remove(wallet) {
Ok(wallet)
Ok(wallet.into())
} else {
Err(ControllerError::WalletNotFound(wallet.to_owned()))
}
Expand All @@ -78,6 +82,29 @@ impl Controller {
}
}

pub fn block0_hash(&self) -> Hash {
Hash::from(self.settings.block0.to_block().header.hash())
}

pub fn fees(&self) -> LinearFee {
self.settings.block0.blockchain_configuration.linear_fees
}

pub fn fragment_sender(&self) -> FragmentSender {
self.fragment_sender_with_setup(Default::default())
}

pub fn fragment_sender_with_setup<'a>(
&self,
setup: FragmentSenderSetup<'a>,
) -> FragmentSender<'a> {
let mut builder = FragmentSenderSetupBuilder::from(setup);
let dump_folder = PathBuf::from(self.working_directory.child("fragments").path());
builder.dump_fragments_into(dump_folder);

FragmentSender::new(self.block0_hash(), self.fees(), builder.build())
}

pub fn spawn_and_wait(&mut self, alias: &str) -> JormungandrProcess {
self.spawn_node(alias, PersistenceMode::InMemory, LeadershipMode::Leader)
.expect(&format!("cannot start {}", alias))
Expand Down
29 changes: 20 additions & 9 deletions testing/jormungandr-integration-tests/src/networking/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ pub fn node_put_itself_in_preffered_layers() {
.is_ok());
}

#[ignore]
#[test]
pub fn topic_of_interest_influences_node_sync_ability() {
pub fn topics_of_interest_influences_node_sync_ability() {
let fast_client_alias = "FAST_CLIENT";
let slow_client_alias = "SLOW_CLIENT";

Expand All @@ -333,11 +332,11 @@ pub fn topic_of_interest_influences_node_sync_ability() {
let mut network_controller = network::builder()
.star_topology(SERVER, vec![fast_client_alias, slow_client_alias])
.initials(vec![
wallet("delegated0").with(1_000_000).delegated_to(SERVER),
wallet("delegated1")
wallet("alice").with(1_000_000).delegated_to(SERVER),
wallet("bob")
.with(1_000_000)
.delegated_to(fast_client_alias),
wallet("delegated2")
wallet("clarice")
.with(1_000_000)
.delegated_to(slow_client_alias),
])
Expand All @@ -348,11 +347,17 @@ pub fn topic_of_interest_influences_node_sync_ability() {
.build()
.unwrap();

let _server = network_controller.spawn_and_wait(SERVER);
let server = network_controller.spawn_and_wait(SERVER);
let fast_client = network_controller.spawn_and_wait(fast_client_alias);
let slow_client = network_controller.spawn_and_wait(fast_client_alias);
let slow_client = network_controller.spawn_and_wait(slow_client_alias);

process_utils::sleep(30);
let mut alice = network_controller.wallet("alice").unwrap();
let mut bob = network_controller.wallet("bob").unwrap();

network_controller
.fragment_sender()
.send_transactions_round_trip(10, &mut alice, &mut bob, &server, 100.into())
.unwrap();

let fast_client_block_recv_cnt = fast_client
.rest()
Expand All @@ -369,8 +374,14 @@ pub fn topic_of_interest_influences_node_sync_ability() {
.unwrap()
.block_recv_cnt;

println!("FAST");
fast_client.logger.print_raw_log();

println!("SLOW");
slow_client.logger.print_raw_log();

assert!(
fast_client_block_recv_cnt > slow_client_block_recv_cnt,
"node with high block topic of interest should have more recieved blocks"
"node with high block topic of interest should have more recieved blocks fast:{} vs slow:{}",fast_client_block_recv_cnt,slow_client_block_recv_cnt
);
}

0 comments on commit 6089bb1

Please sign in to comment.