Skip to content

Commit 0d9762e

Browse files
committed
test: cover private same-channel swaps
1 parent ffdcb31 commit 0d9762e

6 files changed

Lines changed: 75 additions & 1 deletion

File tree

src/test/drop_funding_signed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async fn drop_funding_signed() {
4141
None,
4242
None,
4343
true,
44+
true,
4445
)
4546
.await
4647
.unwrap();
@@ -94,6 +95,7 @@ async fn drop_funding_signed() {
9495
None,
9596
None,
9697
true,
98+
true,
9799
)
98100
.await
99101
.unwrap();

src/test/missing_acceptor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async fn missing_acceptor() {
4242
None,
4343
None,
4444
true,
45+
true,
4546
)
4647
.await
4748
.unwrap();

src/test/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ async fn open_channel_with_retry(
12221222
None,
12231223
None,
12241224
true,
1225+
true,
12251226
)
12261227
.await;
12271228

@@ -1259,6 +1260,7 @@ async fn open_channel_funded_raw(
12591260
fee_proportional_millionths: Option<u32>,
12601261
temporary_channel_id: Option<&str>,
12611262
with_anchors: bool,
1263+
public: bool,
12621264
) -> Result<Channel, Response> {
12631265
open_channel_raw(
12641266
node_address,
@@ -1273,6 +1275,7 @@ async fn open_channel_funded_raw(
12731275
fee_proportional_millionths,
12741276
temporary_channel_id,
12751277
with_anchors,
1278+
public,
12761279
)
12771280
.await?;
12781281

@@ -1352,6 +1355,7 @@ async fn open_channel_raw(
13521355
fee_proportional_millionths: Option<u32>,
13531356
temporary_channel_id: Option<&str>,
13541357
with_anchors: bool,
1358+
public: bool,
13551359
) -> Result<OpenChannelResponse, Response> {
13561360
println!(
13571361
"opening channel with {asset_amount:?} of asset {asset_id:?} from node {node_address} \
@@ -1383,7 +1387,7 @@ async fn open_channel_raw(
13831387
asset_amount,
13841388
asset_id: asset_id.map(|a| a.to_string()),
13851389
push_asset_amount,
1386-
public: true,
1390+
public,
13871391
with_anchors,
13881392
fee_base_msat,
13891393
fee_proportional_millionths,
@@ -1432,6 +1436,7 @@ async fn open_channel_with_custom_data(
14321436
fee_proportional_millionths,
14331437
temporary_channel_id,
14341438
with_anchors,
1439+
true,
14351440
)
14361441
.await
14371442
.expect("channel opening should succeed")

src/test/openchannel_fail.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async fn openchannel_fail() {
3535
None,
3636
None,
3737
true,
38+
true,
3839
)
3940
.await;
4041
check_response_is_nok(
@@ -65,6 +66,7 @@ async fn openchannel_fail() {
6566
None,
6667
None,
6768
true,
69+
true,
6870
)
6971
.await;
7072
check_response_is_nok(
@@ -95,6 +97,7 @@ async fn openchannel_fail() {
9597
None,
9698
None,
9799
true,
100+
true,
98101
)
99102
.await;
100103
check_response_is_nok(

src/test/openchannel_no_indexer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async fn openchannel_no_indexer() {
3636
None,
3737
None,
3838
true,
39+
true,
3940
)
4041
.await;
4142

src/test/swap_reverse_same_channel.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,66 @@ async fn swap_reverse_same_channel() {
186186
assert_eq!(swaps_taker.taker.len(), 1);
187187
let swap_taker = swaps_taker.taker.first().unwrap();
188188
assert_eq!(swap_taker.status, SwapStatus::Succeeded);
189+
190+
let private_asset_id = issue_asset_nia(node1_addr).await.asset_id;
191+
open_channel_funded_raw(
192+
node1_addr,
193+
&node2_pubkey,
194+
Some(NODE2_PEER_PORT),
195+
Some(100000),
196+
Some(50000000),
197+
Some(100),
198+
Some(&private_asset_id),
199+
None,
200+
None,
201+
None,
202+
None,
203+
true,
204+
false,
205+
)
206+
.await
207+
.expect("private channel opening should succeed");
208+
209+
println!("\nsetup private channel swap");
210+
let maker_addr = node1_addr;
211+
let taker_addr = node2_addr;
212+
let qty_from = 25000;
213+
let qty_to = 10;
214+
let maker_init_response = maker_init(
215+
maker_addr,
216+
qty_from,
217+
None,
218+
qty_to,
219+
Some(&private_asset_id),
220+
3600,
221+
)
222+
.await;
223+
taker(taker_addr, maker_init_response.swapstring.clone()).await;
224+
225+
println!("\nexecute private channel swap");
226+
maker_execute(
227+
maker_addr,
228+
maker_init_response.swapstring,
229+
maker_init_response.payment_secret,
230+
node2_pubkey,
231+
)
232+
.await;
233+
234+
let swaps_maker = list_swaps(maker_addr).await;
235+
assert_eq!(swaps_maker.maker.len(), 2);
236+
let swap_maker = swaps_maker
237+
.maker
238+
.iter()
239+
.find(|s| s.payment_hash == maker_init_response.payment_hash)
240+
.unwrap();
241+
assert_eq!(swap_maker.status, SwapStatus::Pending);
242+
wait_for_swap_status(
243+
taker_addr,
244+
&maker_init_response.payment_hash,
245+
SwapStatus::Pending,
246+
)
247+
.await;
248+
249+
wait_for_ln_balance(maker_addr, &private_asset_id, 90).await;
250+
wait_for_ln_balance(taker_addr, &private_asset_id, 10).await;
189251
}

0 commit comments

Comments
 (0)