Skip to content

Commit

Permalink
first attempt to fix real->blockchain converter method
Browse files Browse the repository at this point in the history
fix lints
  • Loading branch information
dkijania committed Oct 11, 2021
1 parent 296d55a commit b2b27b8
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 87 deletions.
5 changes: 2 additions & 3 deletions integration-tests/src/backend/features/batch.rs
Expand Up @@ -6,10 +6,10 @@ use jormungandr_lib::interfaces::FragmentStatus;
use jormungandr_testing_utils::testing::node::time;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::config::{InitialEntry, Initials};
use vitup::scenario::network::setup_network;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;
use vitup::config::{InitialEntry, Initials};
use vitup::scenario::network::setup_network;
const PIN: &str = "1234";
const ALICE: &str = "alice";

Expand Down Expand Up @@ -66,7 +66,6 @@ pub fn transactions_are_send_between_nodes_with_correct_order() {

let valid_until = ValidUntil::BySlotShift(5);
let expiry_date = valid_until
.clone()
.into_expiry_date(Some(alice.settings().unwrap()))
.unwrap();
let fragment_ids = alice
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/backend/sanity/private.rs
@@ -1,19 +1,19 @@
use crate::common::iapyx_from_qr;
use crate::common::{vitup_setup, wait_until_folder_contains_all_qrs, Error, Vote};
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use assert_fs::TempDir;
use chain_impl_mockchain::block::BlockDate;
use chain_impl_mockchain::key::Hash;
use vitup::config::VoteBlockchainTime;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use jormungandr_testing_utils::testing::FragmentSender;
use jormungandr_testing_utils::testing::{node::time, FragmentSenderSetup};
use std::path::Path;
use std::str::FromStr;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;
use vitup::config::{InitialEntry, Initials};
use vitup::scenario::network::setup_network;
use vitup::builders::QuickVitBackendSettingsBuilder;

#[test]
pub fn private_vote_e2e_flow() -> std::result::Result<(), Error> {
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/backend/sanity/public.rs
Expand Up @@ -3,18 +3,18 @@ use crate::common::{vitup_setup, wait_until_folder_contains_all_qrs, Error, Vote
use assert_fs::TempDir;
use chain_impl_mockchain::block::BlockDate;
use chain_impl_mockchain::key::Hash;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use jormungandr_testing_utils::testing::node::time;
use jormungandr_testing_utils::testing::FragmentSender;
use jormungandr_testing_utils::testing::FragmentSenderSetup;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use vitup::config::VoteBlockchainTime;
use std::path::Path;
use std::str::FromStr;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;
use vitup::config::{InitialEntry, Initials};
use vitup::scenario::network::setup_network;
use vitup::builders::QuickVitBackendSettingsBuilder;

const PIN: &str = "1234";

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/common/backend/setup.rs
Expand Up @@ -6,9 +6,9 @@ use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use vit_servicing_station_tests::common::data::ValidVotePlanParameters;
use vitup::scenario::controller::VitController;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;
use vitup::scenario::controller::VitController;

pub fn wait_until_folder_contains_all_qrs<P: AsRef<Path>>(qrs_count: usize, folder: P) {
println!("waiting for qr code in: {:?}", folder.as_ref());
Expand All @@ -24,7 +24,7 @@ pub fn wait_until_folder_contains_all_qrs<P: AsRef<Path>>(qrs_count: usize, fold
}
}

pub fn context(testing_directory: &PathBuf) -> Context {
pub fn context(testing_directory: &Path) -> Context {
let jormungandr = prepare_command(PathBuf::from_str("jormungandr").unwrap());
let jcli = prepare_command(PathBuf::from_str("jcli").unwrap());
let seed = Seed::generate(rand::rngs::OsRng);
Expand All @@ -35,7 +35,7 @@ pub fn context(testing_directory: &PathBuf) -> Context {
seed,
jormungandr,
jcli,
Some(testing_directory.clone()),
Some(testing_directory.to_path_buf()),
generate_documentation,
ProgressBarMode::None,
log_level,
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/src/common/load.rs
Expand Up @@ -3,19 +3,19 @@ use assert_fs::TempDir;
use chain_impl_mockchain::key::Hash;
use iapyx::{NodeLoad, NodeLoadConfig};
use jormungandr_lib::interfaces::BlockDate;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use jormungandr_testing_utils::testing::node::time;
use jortestkit::{
load::{Configuration, Monitor},
measurement::Status,
};
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use std::path::PathBuf;
use std::str::FromStr;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VitStartParameters;
use vitup::scenario::network::setup_network;
use vitup::builders::QuickVitBackendSettingsBuilder;

#[allow(dead_code)]
pub fn private_vote_test_scenario(
Expand All @@ -28,7 +28,7 @@ pub fn private_vote_test_scenario(
let parameters = quick_setup.parameters().clone();
let wallet_count = parameters.initials.count();
let vote_timing = quick_setup.blockchain_timing();

let (mut vit_controller, mut controller, vit_parameters, fund_name) =
vitup_setup(quick_setup, testing_directory.path().to_path_buf());

Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn private_vote_test_scenario(
};

let target_date = BlockDate::new(vote_timing.tally_end, vote_timing.slots_per_epoch / 2);
time::wait_for_date(target_date.into(), leader_1.rest());
time::wait_for_date(target_date, leader_1.rest());

let active_vote_plans = leader_1.vote_plans().unwrap();
let vote_plan_status = active_vote_plans
Expand Down
16 changes: 7 additions & 9 deletions integration-tests/src/common/registration.rs
Expand Up @@ -28,16 +28,14 @@ pub fn do_registration(temp_dir: &TempDir) -> RegistrationResult {
let stake_vkey =
std::env::var("STAKE_VKEY").unwrap_or_else(|_| "STAKE_VKEY not defined".to_owned());

let registration_client = RegistrationRestClient::new_with_token(
registration_token.to_string(),
registration_address.to_string(),
);
let registration_client =
RegistrationRestClient::new_with_token(registration_token, registration_address);

let registration_request = Request {
payment_skey: payment_skey.to_string(),
payment_vkey: payment_vkey.to_string(),
stake_skey: stake_skey.to_string(),
stake_vkey: stake_vkey.to_string(),
payment_skey,
payment_vkey,
stake_skey,
stake_vkey,
};

let registration_job_id = registration_client.job_new(registration_request).unwrap();
Expand All @@ -56,7 +54,7 @@ pub fn do_registration(temp_dir: &TempDir) -> RegistrationResult {
.download_qr(registration_job_id.clone(), qr_code_path.path())
.unwrap();
let voting_key_sk = registration_client
.get_catalyst_sk(registration_job_id.clone())
.get_catalyst_sk(registration_job_id)
.unwrap();

RegistrationResult {
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/src/e2e/testnet.rs
Expand Up @@ -5,15 +5,15 @@ use crate::common::snapshot::wait_for_db_sync;
use crate::common::{vitup_setup, Vote};
use assert_fs::TempDir;
use chain_impl_mockchain::header::BlockDate;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use jormungandr_testing_utils::testing::node::time;
use snapshot_trigger_service::config::JobParameters;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use jormungandr_testing_utils::testing::asserts::VotePlanStatusAssert;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::Initials;
use vitup::scenario::network::setup_network;
use vitup::config::VoteBlockchainTime;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::scenario::network::setup_network;
const GRACE_PERIOD_FOR_SNAPSHOT: u64 = 300;

#[test]
Expand Down
21 changes: 9 additions & 12 deletions integration-tests/src/non_functional/local/load.rs
@@ -1,13 +1,12 @@
use crate::common::{
load::build_load_config, load::private_vote_test_scenario, vitup_setup, VoteTiming,
};
use crate::common::{load::build_load_config, load::private_vote_test_scenario, vitup_setup};
use assert_fs::TempDir;
use iapyx::NodeLoad;
use jortestkit::measurement::Status;
use valgrind::Protocol;
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;
use vitup::scenario::network::setup_network;
use vitup::setup::start::quick::QuickVitBackendSettingsBuilder;

#[test]
pub fn load_test_public_100_000_votes() {
Expand All @@ -17,19 +16,17 @@ pub fn load_test_public_100_000_votes() {
let version = "2.0";
let no_of_threads = 10;
let no_of_wallets = 40_000;
let vote_timing = VoteTiming::new(0, 100, 102);

let vote_timing = VoteBlockchainTime {
vote_start: 0,
tally_start: 100,
tally_end: 102,
slots_in_epoch: 60,
slots_per_epoch: 60,
};

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_timing(vote_timing)
.vote_timing(vote_timing.into())
.slot_duration_in_seconds(2)
.proposals_count(300)
.voting_power(31_000)
Expand Down Expand Up @@ -98,12 +95,12 @@ pub fn load_test_private_pesimistic() {
vote_start: 0,
tally_start: 11,
tally_end: 12,
slots_in_epoch: 3,
slots_per_epoch: 3,
};

quick_setup
.initials_count(no_of_wallets, "1234")
.vote_timing(vote_timing)
.vote_timing(vote_timing.into())
.slot_duration_in_seconds(20)
.proposals_count(250)
.voting_power(31_000)
Expand All @@ -121,13 +118,13 @@ pub fn load_test_private_optimistic() {
vote_start: 6,
tally_start: 11,
tally_end: 12,
slots_in_epoch: 180,
slots_per_epoch: 180,
};

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_timing(vote_timing)
.vote_timing(vote_timing.into())
.slot_duration_in_seconds(20)
.proposals_count(500)
.voting_power(31_000)
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/src/non_functional/local/soak.rs
@@ -1,5 +1,6 @@
use crate::common::load::private_vote_test_scenario;
use vitup::setup::start::quick::QuickVitBackendSettingsBuilder;
use vitup::builders::QuickVitBackendSettingsBuilder;
use vitup::config::VoteBlockchainTime;

#[test]
pub fn soak_test_private_super_optimistic() {
Expand All @@ -11,13 +12,13 @@ pub fn soak_test_private_super_optimistic() {
vote_start: 0,
tally_start: 30,
tally_end: 32,
slots_in_epoch: 60,
slots_per_epoch: 60,
};

let mut quick_setup = QuickVitBackendSettingsBuilder::new();
quick_setup
.initials_count(no_of_wallets, "1234")
.vote_timing(vote_timing)
.vote_timing(vote_timing.into())
.slot_duration_in_seconds(2)
.proposals_count(500)
.voting_power(1_500_000)
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/src/snapshot/testnet.rs
@@ -1,8 +1,8 @@
use jormungandr_testing_utils::testing::asserts::InitialsAssert;
use crate::common::registration::do_registration;
use crate::common::snapshot::do_snapshot;
use crate::common::snapshot::wait_for_db_sync;
use assert_fs::TempDir;
use jormungandr_testing_utils::testing::asserts::InitialsAssert;
use snapshot_trigger_service::config::JobParameters;
const GRACE_PERIOD_FOR_SNAPSHOT: u64 = 300;
//SR001
Expand All @@ -29,7 +29,7 @@ pub fn multiple_registration() {

let job_param = JobParameters {
slot_no: Some(second_registartion.slot_no().unwrap() + GRACE_PERIOD_FOR_SNAPSHOT),
threshold: (second_registartion.funds_in_lovelace().unwrap() - 2_000_000).into(),
threshold: second_registartion.funds_in_lovelace().unwrap() - 2_000_000,
};

wait_for_db_sync();
Expand All @@ -53,7 +53,7 @@ pub fn wallet_has_less_than_threshold() {

let job_param = JobParameters {
slot_no: Some(registartion.slot_no().unwrap() + GRACE_PERIOD_FOR_SNAPSHOT),
threshold: (registartion.funds_in_lovelace().unwrap() + 1_000_000).into(),
threshold: registartion.funds_in_lovelace().unwrap() + 1_000_000,
};

wait_for_db_sync();
Expand All @@ -77,7 +77,7 @@ pub fn wallet_with_funds_equals_to_threshold_should_be_elligible_to_vote() {

let job_param = JobParameters {
slot_no: Some(registartion.slot_no().unwrap() + GRACE_PERIOD_FOR_SNAPSHOT),
threshold: (registartion.funds_in_lovelace().unwrap() - 1_000_000).into(),
threshold: registartion.funds_in_lovelace().unwrap() - 1_000_000,
};

wait_for_db_sync();
Expand All @@ -104,6 +104,6 @@ pub fn registration_after_snapshot_is_not_taken_into_account() {
wait_for_db_sync();
let snapshot_result = do_snapshot(job_param).unwrap();
let initials = snapshot_result.initials();

initials.assert_not_contain(too_late_entry);
}

0 comments on commit b2b27b8

Please sign in to comment.