Skip to content

Commit

Permalink
use rest for current_date too
Browse files Browse the repository at this point in the history
there is a bit of code repetition, though
  • Loading branch information
ecioppettini committed Jun 1, 2021
1 parent c535171 commit bbc4ee0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use super::{FragmentSender, FragmentSenderError, MemPoolCheck};
use crate::testing::SyncNode;
use crate::{
stake_pool::StakePool,
testing::{node::Explorer, RemoteJormungandr, VotePlanBuilder},
testing::{RemoteJormungandr, VotePlanBuilder},
wallet::Wallet,
};
use chain_core::property::FromStr;
use chain_impl_mockchain::{
certificate::{VotePlan, VoteTallyPayload},
vote::Choice,
Expand All @@ -24,7 +25,6 @@ pub struct FragmentGenerator<'a, S: SyncNode + Send> {
vote_plans_for_tally: Vec<VotePlan>,
node: RemoteJormungandr,
rand: OsRng,
explorer: Explorer,
slots_per_epoch: u32,
fragment_sender: FragmentSender<'a, S>,
stake_pools_count: usize,
Expand All @@ -37,7 +37,6 @@ impl<'a, S: SyncNode + Send> FragmentGenerator<'a, S> {
sender: Wallet,
receiver: Wallet,
node: RemoteJormungandr,
explorer: Explorer,
slots_per_epoch: u32,
stake_pools_count: usize,
vote_plans_for_tally_count: usize,
Expand All @@ -54,7 +53,6 @@ impl<'a, S: SyncNode + Send> FragmentGenerator<'a, S> {
vote_plans_for_tally: vec![],
node,
rand: OsRng,
explorer,
slots_per_epoch,
fragment_sender,
stake_pools_count,
Expand Down Expand Up @@ -181,7 +179,18 @@ impl<'a, S: SyncNode + Send> FragmentGenerator<'a, S> {
.send_pool_retire(&mut self.sender, &stake_pool, &self.node)
}
7 => {
let block_date = self.explorer.current_time();
let block_date = BlockDate::from_str(
self.node
.rest()
.stats()
.unwrap()
.stats
.unwrap()
.last_block_date
.unwrap()
.as_ref(),
)
.unwrap();

let time_era = TimeEra::new(
(block_date.slot() as u64).into(),
Expand Down
20 changes: 13 additions & 7 deletions testing/mjolnir/src/mjolnir_app/fragment/standard/all.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::mjolnir_app::MjolnirError;
use jormungandr_integration_tests::common::startup;
use jormungandr_lib::crypto::hash::Hash;
use jormungandr_lib::{crypto::hash::Hash, interfaces::BlockDate};
use jormungandr_testing_utils::{
testing::{
node::{time, Explorer},
FragmentGenerator, FragmentSender, FragmentSenderSetup, FragmentStatusProvider,
node::time, FragmentGenerator, FragmentSender, FragmentSenderSetup, FragmentStatusProvider,
RemoteJormungandrBuilder,
},
wallet::Wallet,
Expand Down Expand Up @@ -83,20 +82,27 @@ impl AllFragments {
let fragment_sender =
FragmentSender::new(block0_hash, fees, FragmentSenderSetup::no_verify());

let explorer = Explorer::new(self.explorer_endpoint.clone());

let mut generator = FragmentGenerator::new(
faucet,
receiver,
remote_jormungandr,
explorer.clone(),
settings.slots_per_epoch,
30,
30,
fragment_sender,
);

let current_date = explorer.current_time();
let current_date = BlockDate::from_str(
rest.stats()
.unwrap()
.stats
.unwrap()
.last_block_date
.unwrap()
.as_ref(),
)
.unwrap();

let target_date = current_date.shift_slot(
self.rump_up,
&current_date.time_era(settings.slots_per_epoch),
Expand Down

0 comments on commit bbc4ee0

Please sign in to comment.