Skip to content

Commit 347cd2e

Browse files
committed
Apply review comment
1 parent 1c6b38e commit 347cd2e

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

chainstate/test-suite/src/tests/block_invalidation.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn test_stale_chain_invalidation(#[case] seed: Seed, #[case] sb: StorageBuilder)
119119
);
120120

121121
tf.chainstate.wait_for_all_events();
122-
assert_eq!(&events.pop_all(), &[]);
122+
assert_eq!(&events.take(), &[]);
123123
});
124124
}
125125

@@ -155,7 +155,7 @@ fn test_basic_tip_invalidation(#[case] seed: Seed, #[case] sb: StorageBuilder) {
155155

156156
tf.chainstate.wait_for_all_events();
157157
assert_eq!(
158-
&events.pop_all(),
158+
&events.take(),
159159
&[ChainstateEvent::NewTip {
160160
id: m0_id.into(),
161161
height: BlockHeight::new(1),
@@ -169,7 +169,7 @@ fn test_basic_tip_invalidation(#[case] seed: Seed, #[case] sb: StorageBuilder) {
169169

170170
tf.chainstate.wait_for_all_events();
171171
assert_eq!(
172-
&events.pop_all(),
172+
&events.take(),
173173
&[ChainstateEvent::NewTip {
174174
id: m1_id.into(),
175175
height: BlockHeight::new(2),
@@ -211,7 +211,7 @@ fn test_basic_parent_invalidation(#[case] seed: Seed, #[case] sb: StorageBuilder
211211

212212
tf.chainstate.wait_for_all_events();
213213
assert_eq!(
214-
&events.pop_all(),
214+
&events.take(),
215215
&[ChainstateEvent::NewTip {
216216
id: genesis_id.into(),
217217
height: BlockHeight::new(0),
@@ -225,7 +225,7 @@ fn test_basic_parent_invalidation(#[case] seed: Seed, #[case] sb: StorageBuilder
225225

226226
tf.chainstate.wait_for_all_events();
227227
assert_eq!(
228-
&events.pop_all(),
228+
&events.take(),
229229
&[ChainstateEvent::NewTip {
230230
id: m1_id.into(),
231231
height: BlockHeight::new(2),
@@ -405,7 +405,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
405405

406406
tf.chainstate.wait_for_all_events();
407407
assert_eq!(
408-
&events.pop_all(),
408+
&events.take(),
409409
&[ChainstateEvent::NewTip {
410410
id: d[2].into(),
411411
height: BlockHeight::new(5),
@@ -450,7 +450,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
450450
assert_eq!(tf.get_min_height_with_allowed_reorg(), 2.into());
451451

452452
tf.chainstate.wait_for_all_events();
453-
assert_eq!(&events.pop_all(), &[]);
453+
assert_eq!(&events.take(), &[]);
454454
}
455455

456456
{
@@ -492,7 +492,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
492492

493493
tf.chainstate.wait_for_all_events();
494494
assert_eq!(
495-
&events.pop_all(),
495+
&events.take(),
496496
&[ChainstateEvent::NewTip {
497497
id: c[1].into(),
498498
height: BlockHeight::new(4),
@@ -541,7 +541,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
541541

542542
tf.chainstate.wait_for_all_events();
543543
assert_eq!(
544-
&events.pop_all(),
544+
&events.take(),
545545
&[ChainstateEvent::NewTip {
546546
id: b[0].into(),
547547
height: BlockHeight::new(3),
@@ -595,7 +595,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
595595
assert_eq!(tf.get_min_height_with_allowed_reorg(), 2.into());
596596

597597
tf.chainstate.wait_for_all_events();
598-
assert_eq!(&events.pop_all(), &[]);
598+
assert_eq!(&events.take(), &[]);
599599
}
600600

601601
{
@@ -640,7 +640,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
640640
assert_eq!(tf.get_min_height_with_allowed_reorg(), 2.into());
641641

642642
tf.chainstate.wait_for_all_events();
643-
assert_eq!(&events.pop_all(), &[]);
643+
assert_eq!(&events.take(), &[]);
644644
}
645645

646646
{
@@ -691,7 +691,7 @@ fn complex_test_impl(mut tf: TestFramework, block_ids: &TestChainBlockIds) {
691691

692692
tf.chainstate.wait_for_all_events();
693693
assert_eq!(
694-
&events.pop_all(),
694+
&events.take(),
695695
&[ChainstateEvent::NewTip {
696696
id: m[6].into(),
697697
height: BlockHeight::new(7),
@@ -773,7 +773,7 @@ fn test_tip_invalidation_with_no_better_candidates(#[case] seed: Seed, #[case] s
773773

774774
tf.chainstate.wait_for_all_events();
775775
assert_eq!(
776-
&events.pop_all(),
776+
&events.take(),
777777
&[ChainstateEvent::NewTip {
778778
id: m0_id.into(),
779779
height: BlockHeight::new(1),
@@ -789,7 +789,7 @@ fn test_tip_invalidation_with_no_better_candidates(#[case] seed: Seed, #[case] s
789789

790790
tf.chainstate.wait_for_all_events();
791791
assert_eq!(
792-
&events.pop_all(),
792+
&events.take(),
793793
&[ChainstateEvent::NewTip {
794794
id: m1_id.into(),
795795
height: BlockHeight::new(2),
@@ -837,7 +837,7 @@ fn test_invalidation_with_reorg_to_chain_with_bad_tip1(#[case] seed: Seed) {
837837
assert_no_block_indices(&tf, &[a1_id]);
838838

839839
tf.chainstate.wait_for_all_events();
840-
assert_eq!(&events.pop_all(), &[]);
840+
assert_eq!(&events.take(), &[]);
841841

842842
// For completeness, invalidate m0 and check that the chain reorgs to a0.
843843

@@ -852,7 +852,7 @@ fn test_invalidation_with_reorg_to_chain_with_bad_tip1(#[case] seed: Seed) {
852852

853853
tf.chainstate.wait_for_all_events();
854854
assert_eq!(
855-
&events.pop_all(),
855+
&events.take(),
856856
&[ChainstateEvent::NewTip {
857857
id: a0_id.into(),
858858
height: BlockHeight::new(1),
@@ -908,7 +908,7 @@ fn test_invalidation_with_reorg_to_chain_with_bad_tip2(#[case] seed: Seed) {
908908

909909
tf.chainstate.wait_for_all_events();
910910
assert_eq!(
911-
&events.pop_all(),
911+
&events.take(),
912912
&[ChainstateEvent::NewTip {
913913
id: a0_id.into(),
914914
height: BlockHeight::new(1),
@@ -989,7 +989,7 @@ fn test_invalidation_with_reorg_attempt_to_chain_with_lower_chain_trust(#[case]
989989
assert_no_block_indices(&tf, &[a1_id]);
990990

991991
tf.chainstate.wait_for_all_events();
992-
assert_eq!(&events.pop_all(), &[]);
992+
assert_eq!(&events.take(), &[]);
993993
});
994994
}
995995

@@ -1054,7 +1054,7 @@ fn test_invalidation_with_reorg_to_chain_with_tip_far_in_the_future(#[case] seed
10541054

10551055
tf.chainstate.wait_for_all_events();
10561056
assert_eq!(
1057-
&events.pop_all(),
1057+
&events.take(),
10581058
&[ChainstateEvent::NewTip {
10591059
id: a0_id.into(),
10601060
height: BlockHeight::new(1),
@@ -1113,7 +1113,7 @@ fn test_reset_bad_stale_tip_status_and_add_blocks(#[case] seed: Seed, #[case] sb
11131113
assert_ok_blocks_at_stage(&tf, &[a0_id, a1_id], BlockValidationStage::CheckBlockOk);
11141114

11151115
tf.chainstate.wait_for_all_events();
1116-
assert_eq!(&events.pop_all(), &[]);
1116+
assert_eq!(&events.take(), &[]);
11171117

11181118
let (a2_id, result) = process_block_spend_parent_reward(&mut tf, &a1_id.into(), &mut rng);
11191119
assert!(result.is_ok());
@@ -1128,7 +1128,7 @@ fn test_reset_bad_stale_tip_status_and_add_blocks(#[case] seed: Seed, #[case] sb
11281128
);
11291129

11301130
tf.chainstate.wait_for_all_events();
1131-
assert_eq!(&events.pop_all(), &[]);
1131+
assert_eq!(&events.take(), &[]);
11321132

11331133
let (a3_id, result) = process_block(&mut tf, &a2_id.into(), &mut rng);
11341134
assert!(result.is_err());
@@ -1147,6 +1147,6 @@ fn test_reset_bad_stale_tip_status_and_add_blocks(#[case] seed: Seed, #[case] sb
11471147
);
11481148

11491149
tf.chainstate.wait_for_all_events();
1150-
assert_eq!(&events.pop_all(), &[]);
1150+
assert_eq!(&events.take(), &[]);
11511151
});
11521152
}

chainstate/test-suite/src/tests/helpers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl EventList {
108108
self.0.lock().unwrap().push(event)
109109
}
110110

111-
pub fn pop_all(&self) -> Vec<ChainstateEvent> {
111+
pub fn take(&self) -> Vec<ChainstateEvent> {
112112
std::mem::take(self.0.lock().unwrap().deref_mut())
113113
}
114114
}

0 commit comments

Comments
 (0)