Skip to content

Commit 430e665

Browse files
100 around of prop test
1 parent 195f378 commit 430e665

File tree

1 file changed

+91
-91
lines changed

1 file changed

+91
-91
lines changed

tests/property_test.rs

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn reorg<E: ElectrumApi>(
6161
}
6262

6363
proptest! {
64-
#![proptest_config(ProptestConfig::with_cases(1))]
64+
#![proptest_config(ProptestConfig::with_cases(100))]
6565
#[test]
6666
fn prop_handle_reorgs(
6767
reorg_depth in 1..=6usize,
@@ -187,50 +187,50 @@ proptest! {
187187
valid_node_amount_all!();
188188

189189
// // Reorg before channel opening
190-
if reorg_point == 0 || true {
191-
// reorg(bitcoind_client, electrsd_client, 1);
192-
reorg(bitcoind_client, electrsd_client, 6);
193-
sync_wallets!();
194-
let mut is_sync_wallets = false;
195-
196-
macro_rules! check_balance_node {
197-
($node:ident, $addr:ident) => {
198-
loop {
199-
let list_balances = $node.list_balances();
200-
// If there is a balance and it is not ready to spend, it means that the transaction has not been confirmed.
201-
if list_balances.spendable_onchain_balance_sats != premine_amount_sat && list_balances.total_onchain_balance_sats == premine_amount_sat {
202-
generate_blocks_and_wait(bitcoind_client, electrsd_client, 1);
203-
is_sync_wallets = true;
204-
// If there is no balance left, it means the transaction has been removed from the block and mempool.
205-
}else if list_balances.total_onchain_balance_sats == 0 {
206-
distribute_funds(
207-
bitcoind_client,
208-
electrsd_client,
209-
vec![$addr.clone()],
210-
Amount::from_sat(premine_amount_sat),
211-
);
212-
is_sync_wallets = true;
213-
break
214-
} else { break };
215-
$node.sync_wallets().unwrap();
216-
}
217-
};
218-
}
219-
println!("\nChecking balance of node_hub");
220-
check_balance_node!(node_hub, addr_hub);
221-
println!("\nChecking balance of node_bitcoind");
222-
check_balance_node!(node_bitcoind, addr_bitcoind);
223-
println!("\nChecking balance of node_electrsd");
224-
check_balance_node!(node_electrsd, addr_electrsd);
225-
println!("\nChecking balance of node_esplora");
226-
check_balance_node!(node_esplora, addr_esplora);
227-
228-
if is_sync_wallets {
229-
sync_wallets!();
230-
}
231-
println_balances_wallets!();
232-
valid_node_amount_all!();
233-
}
190+
// if reorg_point == 0 || true {
191+
// // reorg(bitcoind_client, electrsd_client, 1);
192+
// reorg(bitcoind_client, electrsd_client, 6);
193+
// sync_wallets!();
194+
// let mut is_sync_wallets = false;
195+
196+
// macro_rules! check_balance_node {
197+
// ($node:ident, $addr:ident) => {
198+
// loop {
199+
// let list_balances = $node.list_balances();
200+
// // If there is a balance and it is not ready to spend, it means that the transaction has not been confirmed.
201+
// if list_balances.spendable_onchain_balance_sats != premine_amount_sat && list_balances.total_onchain_balance_sats == premine_amount_sat {
202+
// generate_blocks_and_wait(bitcoind_client, electrsd_client, 1);
203+
// is_sync_wallets = true;
204+
// // If there is no balance left, it means the transaction has been removed from the block and mempool.
205+
// }else if list_balances.total_onchain_balance_sats == 0 {
206+
// distribute_funds(
207+
// bitcoind_client,
208+
// electrsd_client,
209+
// vec![$addr.clone()],
210+
// Amount::from_sat(premine_amount_sat),
211+
// );
212+
// is_sync_wallets = true;
213+
// break
214+
// } else { break };
215+
// $node.sync_wallets().unwrap();
216+
// }
217+
// };
218+
// }
219+
// println!("\nChecking balance of node_hub");
220+
// check_balance_node!(node_hub, addr_hub);
221+
// println!("\nChecking balance of node_bitcoind");
222+
// check_balance_node!(node_bitcoind, addr_bitcoind);
223+
// println!("\nChecking balance of node_electrsd");
224+
// check_balance_node!(node_electrsd, addr_electrsd);
225+
// println!("\nChecking balance of node_esplora");
226+
// check_balance_node!(node_esplora, addr_esplora);
227+
228+
// if is_sync_wallets {
229+
// sync_wallets!();
230+
// }
231+
// println_balances_wallets!();
232+
// valid_node_amount_all!();
233+
// }
234234

235235
// Open channel between node_hub and node_bitcoind
236236
let funding_amount_sat = 2_080_000;
@@ -286,9 +286,9 @@ proptest! {
286286

287287
let user_channel_id = expect_channel_ready_event!(node_hub, node_bitcoind.node_id());
288288
expect_channel_ready_event!(node_bitcoind, node_hub.node_id());
289-
if reorg_point == 1 {
290-
reorg(bitcoind_client, electrsd_client, reorg_depth);
291-
}
289+
// if reorg_point == 1 {
290+
// reorg(bitcoind_client, electrsd_client, reorg_depth);
291+
// }
292292

293293
println!("\npassed here 2");
294294

@@ -390,22 +390,22 @@ proptest! {
390390

391391
println!("\npassed here 3");
392392

393-
// Reorg after payments
394-
if reorg_point == 2 {
395-
reorg(bitcoind_client, electrsd_client, reorg_depth);
393+
// // Reorg after payments
394+
// if reorg_point == 2 {
395+
// reorg(bitcoind_client, electrsd_client, reorg_depth);
396396

397-
sync_wallets!();
397+
// sync_wallets!();
398398

399-
// Verify that the channel remains active
400-
assert!(
401-
!node_hub.list_channels().is_empty(),
402-
"Channel should remain open after reorg"
403-
);
404-
assert!(
405-
!node_bitcoind.list_channels().is_empty(),
406-
"Channel should remain open after reorg"
407-
);
408-
}
399+
// // Verify that the channel remains active
400+
// assert!(
401+
// !node_hub.list_channels().is_empty(),
402+
// "Channel should remain open after reorg"
403+
// );
404+
// assert!(
405+
// !node_bitcoind.list_channels().is_empty(),
406+
// "Channel should remain open after reorg"
407+
// );
408+
// }
409409

410410
// Close channel
411411
let channel_closed = if !node_hub.list_channels().is_empty() {
@@ -433,35 +433,35 @@ proptest! {
433433
false
434434
};
435435

436-
// Reorg after channel closing
437-
if reorg_point == 3 && channel_closed {
438-
let blockchain_info1 = bitcoind_client.get_blockchain_info().unwrap();
439-
reorg(bitcoind_client, electrsd_client, reorg_depth);
440-
let blockchain_info2 = bitcoind_client.get_blockchain_info().unwrap();
441-
assert_eq!(
442-
blockchain_info2.blocks,
443-
blockchain_info1.blocks,
444-
"Blockchain height should be restored after reorg"
445-
);
446-
sync_wallets!();
447-
448-
// Verify that the channel remains closed
449-
assert!(
450-
node_hub.list_channels().is_empty(),
451-
"Channel should remain closed after reorg"
452-
);
453-
assert!(
454-
node_bitcoind.list_channels().is_empty(),
455-
"Channel should remain closed after reorg"
456-
);
457-
458-
// Verify that payments remain valid
459-
assert_eq!(
460-
node_hub.payment(&payment_id).unwrap().status,
461-
PaymentStatus::Succeeded,
462-
"Bolt11 payment should remain successful after reorg"
463-
);
464-
}
436+
// // Reorg after channel closing
437+
// if reorg_point == 3 && channel_closed {
438+
// let blockchain_info1 = bitcoind_client.get_blockchain_info().unwrap();
439+
// reorg(bitcoind_client, electrsd_client, reorg_depth);
440+
// let blockchain_info2 = bitcoind_client.get_blockchain_info().unwrap();
441+
// assert_eq!(
442+
// blockchain_info2.blocks,
443+
// blockchain_info1.blocks,
444+
// "Blockchain height should be restored after reorg"
445+
// );
446+
// sync_wallets!();
447+
448+
// // Verify that the channel remains closed
449+
// assert!(
450+
// node_hub.list_channels().is_empty(),
451+
// "Channel should remain closed after reorg"
452+
// );
453+
// assert!(
454+
// node_bitcoind.list_channels().is_empty(),
455+
// "Channel should remain closed after reorg"
456+
// );
457+
458+
// // Verify that payments remain valid
459+
// assert_eq!(
460+
// node_hub.payment(&payment_id).unwrap().status,
461+
// PaymentStatus::Succeeded,
462+
// "Bolt11 payment should remain successful after reorg"
463+
// );
464+
// }
465465

466466
// Verify balances after closing
467467
if force_close && channel_closed {

0 commit comments

Comments
 (0)