Skip to content

Commit 0c94379

Browse files
committed
fix: fix integration test against some non-determinism
1 parent 6718f08 commit 0c94379

File tree

1 file changed

+32
-49
lines changed

1 file changed

+32
-49
lines changed

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ fn size_overflow_unconfirmed_microblocks_integration_test() {
25792579
if tsc.name.to_string().find("large-").is_some() {
25802580
num_big_anchored_txs += 1;
25812581
total_big_txs_per_block += 1;
2582-
} else if tsc.name.to_string().find("small-").is_some() {
2582+
} else if tsc.name.to_string().find("small").is_some() {
25832583
num_big_microblock_txs += 1;
25842584
total_big_txs_per_microblock += 1;
25852585
}
@@ -2635,26 +2635,20 @@ fn size_overflow_unconfirmed_stream_microblocks_integration_test() {
26352635
.collect();
26362636
let spender_addrs: Vec<PrincipalData> = spender_sks.iter().map(|x| to_addr(x).into()).collect();
26372637

2638-
let txs: Vec<Vec<_>> = spender_sks
2638+
let txs: Vec<_> = spender_sks
26392639
.iter()
26402640
.map(|spender_sk| {
2641-
let mut ret = vec![];
2642-
for i in 0..1 {
2643-
let tx = make_contract_publish_microblock_only(
2644-
spender_sk,
2645-
i as u64,
2646-
600000,
2647-
&format!("small-{}", i),
2648-
&small_contract,
2649-
);
2650-
ret.push(tx);
2651-
}
2652-
ret
2641+
let tx = make_contract_publish_microblock_only(
2642+
spender_sk,
2643+
0,
2644+
600000,
2645+
"small",
2646+
&small_contract,
2647+
);
2648+
tx
26532649
})
26542650
.collect();
26552651

2656-
let flat_txs: Vec<_> = txs.iter().flat_map(|a| a.clone()).collect();
2657-
26582652
let (mut conf, miner_account) = neon_integration_test_conf();
26592653

26602654
for spender_addr in spender_addrs.iter() {
@@ -2725,9 +2719,10 @@ fn size_overflow_unconfirmed_stream_microblocks_integration_test() {
27252719
}
27262720

27272721
let mut ctr = 0;
2728-
while ctr < flat_txs.len() {
2729-
submit_tx(&http_origin, &flat_txs[ctr]);
2722+
while ctr < txs.len() {
2723+
submit_tx(&http_origin, &txs[ctr]);
27302724
if !wait_for_microblocks(&microblocks_processed, 60) {
2725+
// we time out if we *can't* mine any more microblocks
27312726
break;
27322727
}
27332728
ctr += 1;
@@ -2743,27 +2738,24 @@ fn size_overflow_unconfirmed_stream_microblocks_integration_test() {
27432738

27442739
microblocks_processed.store(0, Ordering::SeqCst);
27452740

2746-
while ctr < flat_txs.len() {
2747-
submit_tx(&http_origin, &flat_txs[ctr]);
2748-
if !wait_for_microblocks(&microblocks_processed, 60) {
2749-
break;
2750-
}
2741+
while ctr < txs.len() {
2742+
submit_tx(&http_origin, &txs[ctr]);
27512743
ctr += 1;
27522744
}
2753-
2754-
// should be able to fit 5 more transactions in, in 5 microblocks
2755-
assert_eq!(ctr, 10);
2756-
sleep_ms(5_000);
2745+
wait_for_microblocks(&microblocks_processed, 60);
27572746

27582747
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
27592748

27602749
eprintln!("Second confirmed microblock stream!");
27612750

2751+
wait_for_microblocks(&microblocks_processed, 60);
2752+
27622753
// confirm it
27632754
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
2755+
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
27642756

27652757
let blocks = test_observer::get_blocks();
2766-
assert_eq!(blocks.len(), 4);
2758+
assert_eq!(blocks.len(), 5);
27672759

27682760
let mut max_big_txs_per_microblock = 0;
27692761
let mut total_big_txs_per_microblock = 0;
@@ -2783,7 +2775,7 @@ fn size_overflow_unconfirmed_stream_microblocks_integration_test() {
27832775
let tx_bytes = hex_bytes(&raw_tx[2..]).unwrap();
27842776
let parsed = StacksTransaction::consensus_deserialize(&mut &tx_bytes[..]).unwrap();
27852777
if let TransactionPayload::SmartContract(tsc) = parsed.payload {
2786-
if tsc.name.to_string().find("small-").is_some() {
2778+
if tsc.name.to_string().find("small").is_some() {
27872779
num_big_microblock_txs += 1;
27882780
total_big_txs_per_microblock += 1;
27892781
}
@@ -2833,26 +2825,17 @@ fn size_overflow_unconfirmed_invalid_stream_microblocks_integration_test() {
28332825
let txs: Vec<Vec<_>> = spender_sks
28342826
.iter()
28352827
.map(|spender_sk| {
2836-
let mut ret = vec![];
2837-
for i in 0..1 {
2838-
let tx = make_contract_publish_microblock_only(
2839-
spender_sk,
2840-
i as u64,
2841-
1149230,
2842-
&format!("small-{}", i),
2843-
&small_contract,
2844-
);
2845-
ret.push(tx);
2846-
}
2847-
ret
2828+
let tx = make_contract_publish_microblock_only(
2829+
spender_sk,
2830+
0,
2831+
1149230,
2832+
"small",
2833+
&small_contract,
2834+
);
2835+
tx
28482836
})
28492837
.collect();
28502838

2851-
let flat_txs: Vec<_> = txs.iter().fold(vec![], |mut acc, a| {
2852-
acc.append(&mut a.clone());
2853-
acc
2854-
});
2855-
28562839
let (mut conf, miner_account) = neon_integration_test_conf();
28572840

28582841
for spender_addr in spender_addrs.iter() {
@@ -2925,7 +2908,7 @@ fn size_overflow_unconfirmed_invalid_stream_microblocks_integration_test() {
29252908

29262909
let mut ctr = 0;
29272910
for _i in 0..6 {
2928-
submit_tx(&http_origin, &flat_txs[ctr]);
2911+
submit_tx(&http_origin, &txs[ctr]);
29292912
if !wait_for_microblocks(&microblocks_processed, 60) {
29302913
break;
29312914
}
@@ -2964,7 +2947,7 @@ fn size_overflow_unconfirmed_invalid_stream_microblocks_integration_test() {
29642947
let tx_bytes = hex_bytes(&raw_tx[2..]).unwrap();
29652948
let parsed = StacksTransaction::consensus_deserialize(&mut &tx_bytes[..]).unwrap();
29662949
if let TransactionPayload::SmartContract(tsc) = parsed.payload {
2967-
if tsc.name.to_string().find("small-").is_some() {
2950+
if tsc.name.to_string().find("small").is_some() {
29682951
num_big_microblock_txs += 1;
29692952
total_big_txs_per_microblock += 1;
29702953
}
@@ -3244,7 +3227,7 @@ fn runtime_overflow_unconfirmed_microblocks_integration_test() {
32443227
if tsc.name.to_string().find("large-").is_some() {
32453228
num_big_anchored_txs += 1;
32463229
total_big_txs_per_block += 1;
3247-
} else if tsc.name.to_string().find("small-").is_some() {
3230+
} else if tsc.name.to_string().find("small").is_some() {
32483231
num_big_microblock_txs += 1;
32493232
total_big_txs_per_microblock += 1;
32503233
}

0 commit comments

Comments
 (0)