Skip to content

Commit e58cfbc

Browse files
committed
Check change value in test_splice_in
1 parent 76e73a4 commit e58cfbc

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
@@ -29,8 +29,9 @@ use crate::util::errors::APIError;
2929
use crate::util::ser::Writeable;
3030
use crate::util::test_channel_signer::SignerOp;
3131

32+
use bitcoin::hashes::Hash;
3233
use bitcoin::secp256k1::PublicKey;
33-
use bitcoin::{Amount, OutPoint as BitcoinOutPoint, ScriptBuf, Transaction, TxOut};
34+
use bitcoin::{Amount, OutPoint as BitcoinOutPoint, ScriptBuf, Transaction, TxOut, WPubkeyHash};
3435

3536
#[test]
3637
fn test_splicing_not_supported_api_error() {
@@ -800,16 +801,27 @@ fn test_splice_in() {
800801

801802
let coinbase_tx1 = provide_anchor_reserves(&nodes);
802803
let coinbase_tx2 = provide_anchor_reserves(&nodes);
804+
805+
let added_value = Amount::from_sat(initial_channel_value_sat * 2);
806+
let change_script = ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros());
807+
let fees = Amount::from_sat(321);
808+
803809
let initiator_contribution = SpliceContribution::splice_in(
804-
Amount::from_sat(initial_channel_value_sat * 2),
810+
added_value,
805811
vec![
806812
FundingTxInput::new_p2wpkh(coinbase_tx1, 0).unwrap(),
807813
FundingTxInput::new_p2wpkh(coinbase_tx2, 0).unwrap(),
808814
],
809-
Some(nodes[0].wallet_source.get_change_script().unwrap()),
815+
Some(change_script.clone()),
810816
);
811817

812818
let splice_tx = splice_channel(&nodes[0], &nodes[1], channel_id, initiator_contribution);
819+
let expected_change = Amount::ONE_BTC * 2 - added_value - fees;
820+
assert_eq!(
821+
splice_tx.output.iter().find(|txout| txout.script_pubkey == change_script).unwrap().value,
822+
expected_change,
823+
);
824+
813825
mine_transaction(&nodes[0], &splice_tx);
814826
mine_transaction(&nodes[1], &splice_tx);
815827

0 commit comments

Comments
 (0)