-
Notifications
You must be signed in to change notification settings - Fork 114
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
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 |
|---|---|---|
|
|
@@ -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()); | ||
|
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. These test changes pass on
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. 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?
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.
Sure, feel free to do so. Alternatively, you could also add a
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. added |
||
| 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(); | ||
|
|
||
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.
nit: While this should be fine for now, we generally try to get away from the
UniffiCustomTypeConverterapproach, and instead convert more and more objects to proper interfaces.