Skip to content

Commit

Permalink
refactor CommitteeData in thor in order to allow to specify external …
Browse files Browse the repository at this point in the history
…CommitteKeys
  • Loading branch information
dkijania committed Sep 23, 2022
1 parent 983a37c commit 57ec715
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 260 deletions.
Expand Up @@ -2,7 +2,6 @@ use crate::{
args::parse_shift,
build_monitor,
generators::{AdversaryFragmentGenerator, FragmentStatusProvider},
mjolnir_lib::DiscriminationExtensions,
MjolnirError,
};
use chain_addr::Discrimination;
Expand All @@ -16,7 +15,9 @@ use jortestkit::{
use loki::{AdversaryFragmentSender, AdversaryFragmentSenderSetup};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSender, FragmentSenderSetup, Wallet};
use thor::{
BlockDateGenerator, DiscriminationExtension, FragmentSender, FragmentSenderSetup, Wallet,
};
#[derive(StructOpt, Debug)]
pub struct AdversaryAll {
/// Number of threads
Expand Down
@@ -1,6 +1,6 @@
use crate::{
generators::{AdversaryVoteCastsGenerator, FragmentStatusProvider},
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -15,7 +15,9 @@ use jortestkit::{
};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSender, FragmentSenderSetup, Wallet};
use thor::{
BlockDateGenerator, DiscriminationExtension, FragmentSender, FragmentSenderSetup, Wallet,
};

#[derive(StructOpt, Debug)]
pub struct VotesOnly {
Expand Down
4 changes: 2 additions & 2 deletions testing/mjolnir/src/mjolnir_lib/fragment/batch/tx_only.rs
@@ -1,6 +1,6 @@
use crate::{
generators::{BatchFragmentGenerator, FragmentStatusProvider},
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -12,7 +12,7 @@ use jortestkit::{
};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSenderSetup, Wallet};
use thor::{BlockDateGenerator, DiscriminationExtension, FragmentSenderSetup, Wallet};
#[derive(StructOpt, Debug)]
pub struct TxOnly {
/// Number of threads
Expand Down
@@ -1,6 +1,6 @@
use crate::{
generators::{AdversaryFragmentGenerator, FragmentStatusProvider},
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -13,7 +13,9 @@ use jortestkit::{
use loki::{AdversaryFragmentSender, AdversaryFragmentSenderSetup};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSender, FragmentSenderSetup, Wallet};
use thor::{
BlockDateGenerator, DiscriminationExtension, FragmentSender, FragmentSenderSetup, Wallet,
};
#[derive(StructOpt, Debug)]
pub struct AllAdversary {
/// Number of threads
Expand Down
@@ -1,6 +1,6 @@
use crate::{
generators::{AdversaryVoteCastsGenerator, FragmentStatusProvider},
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -15,7 +15,9 @@ use jortestkit::{
};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSender, FragmentSenderSetup, Wallet};
use thor::{
BlockDateGenerator, DiscriminationExtension, FragmentSender, FragmentSenderSetup, Wallet,
};

#[derive(StructOpt, Debug)]
pub struct VotesOnly {
Expand Down
6 changes: 4 additions & 2 deletions testing/mjolnir/src/mjolnir_lib/fragment/standard/all.rs
@@ -1,6 +1,6 @@
use crate::{
generators::{FragmentGenerator, FragmentStatusProvider},
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -12,7 +12,9 @@ use jortestkit::{
};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSender, FragmentSenderSetup, Wallet};
use thor::{
BlockDateGenerator, DiscriminationExtension, FragmentSender, FragmentSenderSetup, Wallet,
};

#[derive(StructOpt, Debug)]
pub struct AllFragments {
Expand Down
4 changes: 2 additions & 2 deletions testing/mjolnir/src/mjolnir_lib/fragment/standard/tx_only.rs
@@ -1,6 +1,6 @@
use crate::{
generators::TransactionGenerator,
mjolnir_lib::{args::parse_shift, build_monitor, DiscriminationExtensions, MjolnirError},
mjolnir_lib::{args::parse_shift, build_monitor, MjolnirError},
};
use chain_addr::Discrimination;
use chain_impl_mockchain::block::BlockDate;
Expand All @@ -12,7 +12,7 @@ use jortestkit::{
};
use std::{path::PathBuf, str::FromStr, time::Duration};
use structopt::StructOpt;
use thor::{BlockDateGenerator, FragmentSenderSetup, Wallet};
use thor::{BlockDateGenerator, DiscriminationExtension, FragmentSenderSetup, Wallet};
#[derive(StructOpt, Debug)]
pub struct TxOnly {
/// Number of threads
Expand Down
15 changes: 0 additions & 15 deletions testing/mjolnir/src/mjolnir_lib/mod.rs
Expand Up @@ -6,7 +6,6 @@ pub mod fragment;
pub mod generators;
pub mod rest;

use chain_addr::Discrimination;
pub use error::MjolnirError;
use jortestkit::{load::Monitor, prelude::ProgressBarMode};
use std::error::Error;
Expand Down Expand Up @@ -79,17 +78,3 @@ pub fn build_monitor(progress_bar_mode: &ProgressBarMode) -> Monitor {
ProgressBarMode::None => Monitor::Disabled(10),
}
}

pub trait DiscriminationExtensions {
fn from_testing_bool(testing: bool) -> Self;
}

impl DiscriminationExtensions for Discrimination {
fn from_testing_bool(testing: bool) -> Discrimination {
if testing {
Discrimination::Test
} else {
Discrimination::Production
}
}
}
8 changes: 4 additions & 4 deletions testing/thor/src/lib.rs
@@ -1,7 +1,7 @@
pub mod cli;
mod fragment;
mod stake_pool;
mod wallet;
pub mod wallet;

pub use fragment::{
signed_delegation_cert, signed_stake_pool_cert, vote_plan_cert, write_into_persistent_log,
Expand All @@ -12,7 +12,7 @@ pub use fragment::{
};
pub use stake_pool::StakePool;
pub use wallet::{
account::Wallet as AccountWallet, delegation::Wallet as DelegationWallet,
discrimination::DiscriminationExtension, utxo::Wallet as UTxOWallet,
PrivateVoteCommitteeDataManager, Wallet, WalletAlias, WalletError,
account::Wallet as AccountWallet, committee::CommitteeDataManager,
delegation::Wallet as DelegationWallet, discrimination::DiscriminationExtension,
utxo::Wallet as UTxOWallet, Wallet, WalletAlias, WalletError,
};

0 comments on commit 57ec715

Please sign in to comment.