-
Notifications
You must be signed in to change notification settings - Fork 128
Minor follow-ups to #628 #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2466,7 +2466,7 @@ async fn persistence_backwards_compatibility() { | |
| #[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
| async fn onchain_fee_bump_rbf() { | ||
| let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
| let chain_source = TestChainSource::Esplora(&electrsd); | ||
| let chain_source = random_chain_source(&bitcoind, &electrsd); | ||
| let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false); | ||
|
|
||
| // Fund both nodes | ||
|
|
@@ -2490,6 +2490,10 @@ async fn onchain_fee_bump_rbf() { | |
| let txid = | ||
| node_b.onchain_payment().send_to_address(&addr_a, amount_to_send_sats, None).unwrap(); | ||
| wait_for_tx(&electrsd.client, txid).await; | ||
| // Give the chain source time to index the unconfirmed transaction before syncing. | ||
| // Without this, Esplora may not yet have the tx, causing sync to miss it and | ||
| // leaving the BDK wallet graph empty. | ||
| tokio::time::sleep(std::time::Duration::from_secs(5)).await; | ||
| node_a.sync_wallets().unwrap(); | ||
| node_b.sync_wallets().unwrap(); | ||
|
|
||
|
|
@@ -2515,10 +2519,10 @@ async fn onchain_fee_bump_rbf() { | |
| // Successful fee bump | ||
| let new_txid = node_b.onchain_payment().bump_fee_rbf(payment_id, None).unwrap(); | ||
| wait_for_tx(&electrsd.client, new_txid).await; | ||
|
|
||
| // Sleep to allow for transaction propagation | ||
| // Give the chain source time to index the unconfirmed transaction before syncing. | ||
| // Without this, Esplora may not yet have the tx, causing sync to miss it and | ||
| // leaving the BDK wallet graph empty. | ||
| tokio::time::sleep(std::time::Duration::from_secs(5)).await; | ||
|
|
||
| node_a.sync_wallets().unwrap(); | ||
| node_b.sync_wallets().unwrap(); | ||
|
|
||
|
|
@@ -2540,26 +2544,9 @@ async fn onchain_fee_bump_rbf() { | |
| _ => panic!("Unexpected payment kind"), | ||
| } | ||
|
|
||
| // Verify node_a has the inbound payment txid updated to the replacement txid | ||
| let node_a_inbound_payment = node_a.payment(&payment_id).unwrap(); | ||
| assert_eq!(node_a_inbound_payment.direction, PaymentDirection::Inbound); | ||
| match &node_a_inbound_payment.kind { | ||
| PaymentKind::Onchain { txid: inbound_txid, .. } => { | ||
| assert_eq!( | ||
| *inbound_txid, new_txid, | ||
| "node_a inbound payment txid should be updated to the replacement txid" | ||
| ); | ||
| }, | ||
| _ => panic!("Unexpected payment kind"), | ||
| } | ||
|
|
||
| // Multiple consecutive bumps | ||
| let second_bump_txid = node_b.onchain_payment().bump_fee_rbf(payment_id, None).unwrap(); | ||
| wait_for_tx(&electrsd.client, second_bump_txid).await; | ||
|
|
||
| // Sleep to allow for transaction propagation | ||
| tokio::time::sleep(std::time::Duration::from_secs(5)).await; | ||
|
|
||
| node_a.sync_wallets().unwrap(); | ||
| node_b.sync_wallets().unwrap(); | ||
|
|
||
|
|
@@ -2579,19 +2566,6 @@ async fn onchain_fee_bump_rbf() { | |
| _ => panic!("Unexpected payment kind"), | ||
| } | ||
|
|
||
| // Verify node_a has the inbound payment txid updated to the second replacement txid | ||
| let node_a_second_inbound_payment = node_a.payment(&payment_id).unwrap(); | ||
| assert_eq!(node_a_second_inbound_payment.direction, PaymentDirection::Inbound); | ||
| match &node_a_second_inbound_payment.kind { | ||
| PaymentKind::Onchain { txid: inbound_txid, .. } => { | ||
| assert_eq!( | ||
| *inbound_txid, second_bump_txid, | ||
| "node_a inbound payment txid should be updated to the second replacement txid" | ||
| ); | ||
| }, | ||
| _ => panic!("Unexpected payment kind"), | ||
| } | ||
|
|
||
| // Confirm the transaction and try to bump again (should fail) | ||
| generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; | ||
| node_a.sync_wallets().unwrap(); | ||
|
|
@@ -2613,10 +2587,20 @@ async fn onchain_fee_bump_rbf() { | |
| } | ||
|
|
||
| // Verify node A received the funds correctly | ||
| let node_a_received_payment = node_a.list_payments_with_filter( | ||
| |p| matches!(p.kind, PaymentKind::Onchain { txid, .. } if txid == second_bump_txid), | ||
| ); | ||
| let node_a_received_payment = node_a.list_payments_with_filter(|p| { | ||
| p.id == payment_id && matches!(p.kind, PaymentKind::Onchain { .. }) | ||
| }); | ||
|
|
||
| assert_eq!(node_a_received_payment.len(), 1); | ||
| match &node_a_received_payment[0].kind { | ||
| PaymentKind::Onchain { txid: inbound_txid, .. } => { | ||
| assert_eq!( | ||
| *inbound_txid, second_bump_txid, | ||
| "node_a inbound payment txid should be updated to the second replacement txid" | ||
| ); | ||
| }, | ||
| _ => panic!("Unexpected payment kind"), | ||
| } | ||
|
Comment on lines
+2595
to
+2603
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to sync timing, the assertion verifying that node a's inbound payment |
||
| assert_eq!(node_a_received_payment[0].amount_msat, Some(amount_to_send_sats * 1000)); | ||
| assert_eq!(node_a_received_payment[0].status, PaymentStatus::Succeeded); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sleep is needed here because of test-environment-specific reasons,
wait_for_txuses the Electrum API to confirm the tx is in the mempool, but when Esplora is the chain source, Esplora may not have indexed it yet. Ifsync_wallets()runs in that window, BDK misses the tx andbump_fee_rbfcan't find it via tx_details.In practice, the fee of a transaction will not be bumped the instant they send. By the time a user decides to bump, the wallet has gone through multiple sync cycles, and the tx is long indexed. The sleep simulates that gap.