Skip to content

Commit 3fba31a

Browse files
committed
Improve pool test documentation.
1 parent 6a8fe4a commit 3fba31a

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

massa-pool/src/operation_pool.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub mod tests {
466466
let mut pool =
467467
OperationPool::new(pool_settings, *thread_count, *operation_validity_periods);
468468

469-
// generate transactions
469+
// generate (id, transactions, range of validity) by threads
470470
let mut thread_tx_lists = vec![Vec::new(); *thread_count as usize];
471471
for i in 0..18 {
472472
let fee = 40 + i;
@@ -494,7 +494,7 @@ pub mod tests {
494494
lst.truncate(*max_pool_size_per_thread as usize);
495495
}
496496

497-
// checks ops for thread 0 and 1 and various periods
497+
// checks ops are the expected ones for thread 0 and 1 and various periods
498498
for thread in 0u8..=1 {
499499
for period in 0u64..70 {
500500
let target_slot = Slot::new(period, thread);
@@ -513,15 +513,16 @@ pub mod tests {
513513
}
514514
}
515515

516-
// op ending before or at period 45 should be discarded
516+
// op ending before or at period 45 won't appear in the block due to incompatible validity range
517+
// we don't keep them as expected ops
517518
let final_period = 45u64;
518519
pool.update_latest_final_periods(vec![final_period; *thread_count as usize])
519520
.unwrap();
520521
for lst in thread_tx_lists.iter_mut() {
521522
lst.retain(|(_, op, _)| op.content.expire_period > final_period);
522523
}
523524

524-
// checks ops for thread 0 and 1 and various periods
525+
// checks ops are the expected ones for thread 0 and 1 and various periods
525526
for thread in 0u8..=1 {
526527
for period in 0u64..70 {
527528
let target_slot = Slot::new(period, thread);

massa-pool/src/tests/scenario.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn test_pool() {
3939
cmd @ ProtocolCommand::PropagateOperations(_) => Some(cmd),
4040
_ => None,
4141
};
42-
// generate transactions
42+
// generate (id, transactions, range of validity) by threads
4343
let mut thread_tx_lists = vec![Vec::new(); *thread_count as usize];
4444
for i in 0..18 {
4545
let fee = 40 + i;
@@ -90,7 +90,7 @@ async fn test_pool() {
9090
lst.truncate(*max_pool_size_per_thread as usize);
9191
}
9292

93-
// checks ops for thread 0 and 1 and various periods
93+
// checks ops are the expected ones for thread 0 and 1 and various periods
9494
for thread in 0u8..=1 {
9595
for period in 0u64..70 {
9696
let target_slot = Slot::new(period, thread);
@@ -114,7 +114,8 @@ async fn test_pool() {
114114
.map(|(id, op, _)| (id, op.to_bytes_compact().unwrap()))));
115115
}
116116
}
117-
// op ending before or at period 45 should be discarded
117+
// op ending before or at period 45 won't appear in the block due to incompatible validity range
118+
// we don't keep them as expected ops
118119
let final_period = 45u64;
119120
pool_command_sender
120121
.update_latest_final_periods(vec![final_period; *thread_count as usize])
@@ -123,7 +124,7 @@ async fn test_pool() {
123124
for lst in thread_tx_lists.iter_mut() {
124125
lst.retain(|(_, op, _)| op.content.expire_period > final_period);
125126
}
126-
// checks ops for thread 0 and 1 and various periods
127+
// checks ops are the expected ones for thread 0 and 1 and various periods
127128
for thread in 0u8..=1 {
128129
for period in 0u64..70 {
129130
let target_slot = Slot::new(period, thread);
@@ -147,7 +148,7 @@ async fn test_pool() {
147148
.map(|(id, op, _)| (id, op.to_bytes_compact().unwrap()))));
148149
}
149150
}
150-
// add transactions from protocol with a high fee but too much in the future: should be ignored
151+
// Add transactions that should be ignored despite their high fees, due to them being too far in the future
151152
{
152153
pool_command_sender
153154
.update_current_slot(Slot::new(10, 0))
@@ -204,7 +205,7 @@ async fn test_pool_with_execute_sc() {
204205
cmd @ ProtocolCommand::PropagateOperations(_) => Some(cmd),
205206
_ => None,
206207
};
207-
// generate transactions
208+
// generate (id, transactions, range of validity) by threads
208209
let mut thread_tx_lists = vec![Vec::new(); *thread_count as usize];
209210
for i in 0..18 {
210211
let fee = 40 + i;
@@ -255,7 +256,7 @@ async fn test_pool_with_execute_sc() {
255256
lst.truncate(*max_pool_size_per_thread as usize);
256257
}
257258

258-
// checks ops for thread 0 and 1 and various periods
259+
// checks ops are the expected ones for thread 0 and 1 and various periods
259260
for thread in 0u8..=1 {
260261
for period in 0u64..70 {
261262
let target_slot = Slot::new(period, thread);
@@ -279,7 +280,8 @@ async fn test_pool_with_execute_sc() {
279280
.map(|(id, op, _)| (id, op.to_bytes_compact().unwrap()))));
280281
}
281282
}
282-
// op ending before or at period 45 should be discarded
283+
// op ending before or at period 45 won't appear in the block due to incompatible validity range
284+
// we don't keep them as expected ops
283285
let final_period = 45u64;
284286
pool_command_sender
285287
.update_latest_final_periods(vec![final_period; *thread_count as usize])
@@ -288,7 +290,7 @@ async fn test_pool_with_execute_sc() {
288290
for lst in thread_tx_lists.iter_mut() {
289291
lst.retain(|(_, op, _)| op.content.expire_period > final_period);
290292
}
291-
// checks ops for thread 0 and 1 and various periods
293+
// checks ops are the expected ones for thread 0 and 1 and various periods
292294
for thread in 0u8..=1 {
293295
for period in 0u64..70 {
294296
let target_slot = Slot::new(period, thread);
@@ -312,7 +314,7 @@ async fn test_pool_with_execute_sc() {
312314
.map(|(id, op, _)| (id, op.to_bytes_compact().unwrap()))));
313315
}
314316
}
315-
// add transactions from protocol with a high fee but too much in the future: should be ignored
317+
// Add transactions that should be ignored despite their high fees, due to them being too far in the future
316318
{
317319
pool_command_sender
318320
.update_current_slot(Slot::new(10, 0))
@@ -366,7 +368,7 @@ async fn test_pool_with_protocol_events() {
366368
_ => None,
367369
};
368370

369-
// generate transactions
371+
// generate (id, transactions, range of validity) by threads
370372
let mut thread_tx_lists = vec![Vec::new(); *thread_count as usize];
371373
for i in 0..18 {
372374
let fee = 40 + i;

0 commit comments

Comments
 (0)