@@ -557,14 +557,43 @@ mod tests {
557557 use core:: str:: FromStr ;
558558 use std:: collections:: HashMap ;
559559 use crate :: ln:: interactivetxs:: ChannelMode :: { Negotiating , NegotiationAborted } ;
560- use crate :: ln:: interactivetxs:: { ChannelMode , InteractiveTxConstructor , InteractiveTxStateMachine } ;
560+ use crate :: ln:: interactivetxs:: { AbortReason , ChannelMode , InteractiveTxConstructor , InteractiveTxStateMachine } ;
561561 use crate :: ln:: msgs:: TransactionU16LenLimited ;
562562 use bitcoin:: consensus:: encode;
563563 use bitcoin:: { Address , PackedLockTime , Script , Sequence , Transaction , Txid , TxIn , TxOut , Witness } ;
564564 use bitcoin:: hashes:: hex:: FromHex ;
565565 use crate :: chain:: transaction:: OutPoint ;
566+ use crate :: ln:: interactivetxs:: AbortReason :: IncorrectSerialIdParity ;
566567 use crate :: ln:: msgs:: TxAddInput ;
567568
569+ #[ test]
570+ fn test_invalid_counterparty_serial_id_should_abort_negotiation ( ) {
571+ let tx: Transaction = encode:: deserialize ( & hex:: decode ( "020000000001010e0ade\
572+ f48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a107000\
573+ 0000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54\
574+ a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a8\
575+ 72e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69\
576+ dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453\
577+ b76bd00000000") . unwrap ( ) [ ..] ) . unwrap ( ) ;
578+
579+ let mut constructor = InteractiveTxConstructor :: new (
580+ [ 0 ; 32 ] ,
581+ true ,
582+ true ,
583+ tx,
584+ false ,
585+ ) ;
586+
587+ constructor. receive_tx_add_input (
588+ 2 ,
589+ get_sample_tx_add_input ( ) ,
590+ false
591+ ) ;
592+
593+ assert ! ( matches!( constructor. mode, ChannelMode :: NegotiationAborted { .. } ) )
594+ }
595+
596+
568597 struct DummyChannel {
569598 tx_constructor : InteractiveTxConstructor
570599 }
0 commit comments