-
Notifications
You must be signed in to change notification settings - Fork 132
/
fragments.rs
71 lines (60 loc) · 2.27 KB
/
fragments.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::common::{
jcli::{FragmentsCheck, JCli},
jormungandr::ConfigurationBuilder,
startup,
};
use chain_impl_mockchain::{chaintypes::ConsensusType, fee::LinearFee};
use jormungandr_lib::interfaces::{ActiveSlotCoefficient, BlockDate, Mempool};
use jormungandr_testing_utils::testing::{
node::time, FragmentGenerator, FragmentSender, FragmentSenderSetup, FragmentVerifier,
MemPoolCheck,
};
use jortestkit::prelude::Wait;
use std::time::Duration;
#[test]
pub fn send_all_fragments() {
let receiver = startup::create_new_account_address();
let sender = startup::create_new_account_address();
let (jormungandr, _) = startup::start_stake_pool(
&[sender.clone()],
&[receiver.clone()],
ConfigurationBuilder::new()
.with_block0_consensus(ConsensusType::GenesisPraos)
.with_slots_per_epoch(60)
.with_consensus_genesis_praos_active_slot_coeff(ActiveSlotCoefficient::MAXIMUM)
.with_slot_duration(3)
.with_linear_fees(LinearFee::new(1, 1, 1))
.with_explorer()
.with_mempool(Mempool {
pool_max_entries: 1_000_000usize.into(),
log_max_entries: 1_000_000usize.into(),
persistent_log_path: None,
}),
)
.unwrap();
let fragment_sender = FragmentSender::new(
jormungandr.genesis_block_hash(),
jormungandr.fees(),
FragmentSenderSetup::no_verify(),
);
let time_era = jormungandr.time_era();
let mut fragment_generator = FragmentGenerator::new(
sender,
receiver,
jormungandr.to_remote(),
jormungandr.explorer(),
time_era.slots_per_epoch(),
fragment_sender,
);
fragment_generator.prepare(BlockDate::new(1, 0));
let jcli: JCli = Default::default();
let fragment_check = FragmentsCheck::new(jcli, &jormungandr);
let wait = Wait::new(Duration::from_secs(1), 25);
fragment_check.wait_until_all_processed(&wait).unwrap();
time::wait_for_epoch(1, jormungandr.explorer());
let mem_checks: Vec<MemPoolCheck> = fragment_generator.send_all().unwrap();
let verifier = FragmentVerifier;
verifier
.wait_and_verify_all_are_in_block(Duration::from_secs(2), mem_checks, &jormungandr)
.unwrap();
}