Skip to content

Commit c788a3e

Browse files
committed
Check change value in test_splice_in
1 parent 569d753 commit c788a3e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lightning/src/ln/splicing_tests.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ use crate::util::errors::APIError;
2727
use crate::util::ser::Writeable;
2828
use crate::util::test_channel_signer::SignerOp;
2929

30+
use bitcoin::hashes::Hash;
3031
use bitcoin::secp256k1::PublicKey;
31-
use bitcoin::{Amount, OutPoint as BitcoinOutPoint, ScriptBuf, Transaction, TxOut};
32+
use bitcoin::{Amount, OutPoint as BitcoinOutPoint, ScriptBuf, Transaction, TxOut, WPubkeyHash};
3233

3334
#[test]
3435
fn test_v1_splice_in_negative_insufficient_inputs() {
@@ -739,16 +740,27 @@ fn test_splice_in() {
739740

740741
let coinbase_tx1 = provide_anchor_reserves(&nodes);
741742
let coinbase_tx2 = provide_anchor_reserves(&nodes);
743+
744+
let added_value = Amount::from_sat(initial_channel_value_sat * 2);
745+
let change_script = ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros());
746+
let fees = Amount::from_sat(321);
747+
742748
let initiator_contribution = SpliceContribution::splice_in(
743-
Amount::from_sat(initial_channel_value_sat * 2),
749+
added_value,
744750
vec![
745751
FundingTxInput::new_p2wpkh(coinbase_tx1, 0).unwrap(),
746752
FundingTxInput::new_p2wpkh(coinbase_tx2, 0).unwrap(),
747753
],
748-
Some(nodes[0].wallet_source.get_change_script().unwrap()),
754+
Some(change_script.clone()),
749755
);
750756

751757
let splice_tx = splice_channel(&nodes[0], &nodes[1], channel_id, initiator_contribution);
758+
let expected_change = Amount::ONE_BTC * 2 - added_value - fees;
759+
assert_eq!(
760+
splice_tx.output.iter().find(|txout| txout.script_pubkey == change_script).unwrap().value,
761+
expected_change,
762+
);
763+
752764
mine_transaction(&nodes[0], &splice_tx);
753765
mine_transaction(&nodes[1], &splice_tx);
754766

0 commit comments

Comments
 (0)