Skip to content

Commit d6c1603

Browse files
committed
parametrize ln_transfers: calls to update_witnesses shouldn't disrupt channel operations
1 parent 1163628 commit d6c1603

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/transfers.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,11 @@ fn accept_0conf() {
748748
);
749749
}
750750

751-
#[test]
752-
fn ln_transfers() {
751+
#[rstest]
752+
#[case(false)]
753+
#[ignore = "fix needed"] // https://github.com/RGB-WG/rgb-std/issues/292
754+
#[case(true)]
755+
fn ln_transfers(#[case] update_witnesses_before_htlc: bool) {
753756
initialize();
754757

755758
let mut wlt_1 = get_wallet(&DescriptorType::Wpkh);
@@ -787,6 +790,9 @@ fn ln_transfers() {
787790
let htlc_btc_amt = 4000;
788791
let htlc_derived_addr = wlt_1.get_derived_address();
789792

793+
// no problem: since there's no htlc for this commitment
794+
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
795+
790796
println!("\n2. fake commitment TX (1 HTLC)");
791797
let beneficiaries = vec![
792798
(wlt_2.get_address(), Some(2000)),
@@ -811,6 +817,10 @@ fn ln_transfers() {
811817
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
812818
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);
813819

820+
if update_witnesses_before_htlc {
821+
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
822+
}
823+
814824
println!("\n3. fake HTLC TX");
815825
let witness_id = fascia.witness_id();
816826
let txid = witness_id.as_reduced_unsafe();
@@ -887,6 +897,10 @@ fn ln_transfers() {
887897
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
888898
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);
889899

900+
if update_witnesses_before_htlc {
901+
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
902+
}
903+
890904
println!("\n6. fake HTLC TX");
891905
let witness_id = fascia.witness_id();
892906
let txid = witness_id.as_reduced_unsafe();
@@ -914,6 +928,9 @@ fn ln_transfers() {
914928
wlt_1.consume_fascia(fascia.clone(), psbt.txid());
915929
wlt_1.debug_logs(contract_id, &iface_type_name, AllocationFilter::WalletAll);
916930

931+
// no problem: since the force-close tx will be updated to mined soon
932+
wlt_1.sync_and_update_witnesses(Some(pre_funding_height));
933+
917934
println!("\n7. broadcast old PSBT");
918935
let tx = wlt_1.sign_finalize_extract(&mut old_psbt);
919936
wlt_1.broadcast_tx(&tx);

0 commit comments

Comments
 (0)