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