Skip to content

Commit 0f2e21f

Browse files
committed
switch the block production function
1 parent 57c43f9 commit 0f2e21f

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

src/models/peer/tests/automaton.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ impl proptest_state_machine::StateMachineTest for TheSut {
140140
let g_cloned = g.clone();
141141

142142
rt.block_on(async {
143-
dbg!(&transition);
143+
dbg!(format!("{:?}", transition.0)
144+
.lines()
145+
.next()
146+
.unwrap_or_default());
147+
dbg!(&transition.1.is_some());
144148
match transition {
145149
Transition(_, Some(AssosiatedData::MakeNewBlocks(..))) => {
146150
// blocks_stuff(ref_state.blocks[ref_state.blocks.len()-1 - BLOCKS_NEW_LEN..].into()).await;

src/models/peer/tests/automaton/reference/strategy_the.rs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::config_models::network::Network;
55
use crate::models::blockchain::block::{block_height::BlockHeight, Block};
66
use crate::models::peer::peer_block_notifications::PeerBlockNotification;
77
use crate::models::peer::tests::automaton::reference::AssosiatedData;
8+
use crate::models::peer::tests::automaton::BLOCKS_NEW_LEN;
89
use crate::models::peer::{BlockProposalRequest, SyncChallenge};
10+
use crate::models::state::wallet::wallet_entropy::WalletEntropy;
911
use proptest::prelude::*;
1012
use proptest::strategy::{Just, Strategy};
1113
use proptest_arbitrary_interop::arb;
@@ -216,16 +218,35 @@ impl proptest_state_machine::strategy::ReferenceStateMachine for Automaton {
216218

217219
fn apply(mut state: Self::State, transition: &Self::Transition) -> Self::State {
218220
match transition {
219-
Transition(variant, Some(AssosiatedData::MakeNewBlocks(ts, seed_the))) => {
221+
Transition(variant, Some(AssosiatedData::MakeNewBlocks(_ts, seed_the))) => {
220222
let tip_at_request = state.blocks.last().unwrap().clone();
221-
state.blocks.append(&mut Runtime::new().unwrap().block_on(
222-
crate::tests::shared::fake_valid_sequence_of_blocks_for_tests_dyn(
223-
&tip_at_request,
224-
*ts,
225-
*seed_the,
226-
super::super::BLOCKS_NEW_LEN,
227-
),
228-
));
223+
// state.blocks.append(&mut Runtime::new().unwrap().block_on(
224+
// crate::tests::shared::fake_valid_sequence_of_blocks_for_tests_dyn(
225+
// &tip_at_request,
226+
// *ts,
227+
// *seed_the,
228+
// super::super::BLOCKS_NEW_LEN,
229+
// ),
230+
// ));
231+
let rt = Runtime::new().unwrap();
232+
for i in 0..BLOCKS_NEW_LEN as u8 {
233+
let mut seed = *seed_the;
234+
seed[0] = seed[0].wrapping_add(i);
235+
state.blocks.push(
236+
rt.block_on(crate::tests::shared::make_mock_block(
237+
// previous_block: &Block,
238+
state.blocks.last().unwrap(),
239+
// block_timestamp: Option<Timestamp>,
240+
None,
241+
// composer_key: generation_address::GenerationSpendingKey,
242+
WalletEntropy::new_pseudorandom(seed)
243+
.nth_generation_spending_key_for_tests(0),
244+
// seed: [u8; 32], // #seedReuse
245+
seed,
246+
))
247+
.0,
248+
);
249+
}
229250
if &PeerMessage::BlockNotificationRequest == variant {
230251
state.sync_stage = Some(SyncStage::WaitingForChallenge(
231252
// a possible problem is a testing system will be responding with another block

0 commit comments

Comments
 (0)