-
Notifications
You must be signed in to change notification settings - Fork 130
Insert channel funding outputs into Wallet #726
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -927,10 +927,13 @@ async fn concurrent_connections_succeed() { | |
| } | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
| async fn splice_channel() { | ||
| async fn run_splice_channel_test(bitcoind_chain_source: bool) { | ||
| let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
| let chain_source = TestChainSource::Esplora(&electrsd); | ||
| let chain_source = if bitcoind_chain_source { | ||
| TestChainSource::BitcoindRpcSync(&bitcoind) | ||
| } else { | ||
| TestChainSource::Esplora(&electrsd) | ||
| }; | ||
| let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false); | ||
|
|
||
| let address_a = node_a.onchain_payment().new_address().unwrap(); | ||
|
|
@@ -995,7 +998,7 @@ async fn splice_channel() { | |
| // Splice-in funds for Node B so that it has outbound liquidity to make a payment | ||
| node_b.splice_in(&user_channel_id_b, node_a.node_id(), 4_000_000).unwrap(); | ||
|
|
||
| expect_splice_pending_event!(node_a, node_b.node_id()); | ||
| let txo = expect_splice_pending_event!(node_a, node_b.node_id()); | ||
| expect_splice_pending_event!(node_b, node_a.node_id()); | ||
|
|
||
| generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; | ||
|
|
@@ -1006,11 +1009,16 @@ async fn splice_channel() { | |
| expect_channel_ready_event!(node_a, node_b.node_id()); | ||
| expect_channel_ready_event!(node_b, node_a.node_id()); | ||
|
|
||
| let splice_in_fee_sat = 252; | ||
| let expected_splice_in_fee_sat = 252; | ||
|
|
||
| let payments = node_b.list_payments(); | ||
| let payment = | ||
| payments.into_iter().find(|p| p.id == PaymentId(txo.txid.to_byte_array())).unwrap(); | ||
| assert_eq!(payment.fee_paid_msat, Some(expected_splice_in_fee_sat * 1_000)); | ||
|
|
||
| assert_eq!( | ||
| node_b.list_balances().total_onchain_balance_sats, | ||
| premine_amount_sat - 4_000_000 - splice_in_fee_sat | ||
| premine_amount_sat - 4_000_000 - expected_splice_in_fee_sat | ||
| ); | ||
| assert_eq!(node_b.list_balances().total_lightning_balance_sats, 4_000_000); | ||
|
|
||
|
|
@@ -1033,7 +1041,7 @@ async fn splice_channel() { | |
| let address = node_a.onchain_payment().new_address().unwrap(); | ||
| node_a.splice_out(&user_channel_id_a, node_b.node_id(), &address, amount_msat / 1000).unwrap(); | ||
|
|
||
| expect_splice_pending_event!(node_a, node_b.node_id()); | ||
| let txo = expect_splice_pending_event!(node_a, node_b.node_id()); | ||
| expect_splice_pending_event!(node_b, node_a.node_id()); | ||
|
|
||
| generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await; | ||
|
|
@@ -1044,18 +1052,29 @@ async fn splice_channel() { | |
| expect_channel_ready_event!(node_a, node_b.node_id()); | ||
| expect_channel_ready_event!(node_b, node_a.node_id()); | ||
|
|
||
| let splice_out_fee_sat = 183; | ||
| let expected_splice_out_fee_sat = 183; | ||
|
|
||
| let payments = node_a.list_payments(); | ||
| let payment = | ||
| payments.into_iter().find(|p| p.id == PaymentId(txo.txid.to_byte_array())).unwrap(); | ||
| assert_eq!(payment.fee_paid_msat, Some(expected_splice_out_fee_sat * 1_000)); | ||
|
|
||
| assert_eq!( | ||
| node_a.list_balances().total_onchain_balance_sats, | ||
| premine_amount_sat - 4_000_000 - opening_transaction_fee_sat + amount_msat / 1000 | ||
| ); | ||
| assert_eq!( | ||
| node_a.list_balances().total_lightning_balance_sats, | ||
| 4_000_000 - closing_transaction_fee_sat - anchor_output_sat - splice_out_fee_sat | ||
| 4_000_000 - closing_transaction_fee_sat - anchor_output_sat - expected_splice_out_fee_sat | ||
| ); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
| async fn splice_channel() { | ||
| run_splice_channel_test(false).await; | ||
|
Collaborator
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. nit: Not that it matters much, but elsewhere in LDK Node / LDK tests the usual pattern would be to name the 'inner' test methods |
||
| run_splice_channel_test(true).await; | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
| async fn simple_bolt12_send_receive() { | ||
| let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These test changes pass on
main. Can you add coverage for the cases where the previous approach would lead to inaccurate fee estimations?Uh oh!
There was an error while loading. Please reload this page.
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 bug/issue only exists with bitcoind syncing so to do so, we'd have to change the test to sync with bitcoind rpc. Is that wanted?
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.
Sure, feel free to do so. Alternatively, you could also add a
_bitcoindvariant test case (ofc reusing the logic) so we have two test cases for bitcoind and esplora - that's if we think there would be more chain source specific edge cases.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.
added