@@ -715,3 +715,68 @@ impl_writeable_tlv_based_enum!(ChannelShutdownState,
715715	( 6 ,  NegotiatingClosingFee )  => { } , 
716716	( 8 ,  ShutdownComplete )  => { } , 
717717) ; 
718+ 
719+ #[ cfg( test) ]  
720+ mod  tests { 
721+ 	use  bitcoin:: { hashes:: Hash  as  _,  secp256k1:: PublicKey } ; 
722+ 	use  lightning_types:: features:: Features ; 
723+ 
724+ 	use  crate :: { 
725+ 		chain:: transaction:: OutPoint , 
726+ 		ln:: types:: ChannelId , 
727+ 		util:: ser:: { Readable ,  Writeable } , 
728+ 	} ; 
729+ 
730+ 	use  super :: { ChannelCounterparty ,  ChannelDetails ,  ChannelShutdownState } ; 
731+ 
732+ 	#[ test]  
733+ 	fn  test_channel_details_serialization ( )  { 
734+ 		#[ allow( deprecated) ]  
735+ 		let  channel_details = ChannelDetails  { 
736+ 			channel_id :  ChannelId :: new_zero ( ) , 
737+ 			counterparty :  ChannelCounterparty  { 
738+ 				features :  Features :: empty ( ) , 
739+ 				node_id :  PublicKey :: from_slice ( & [ 2 ;  33 ] ) . unwrap ( ) , 
740+ 				unspendable_punishment_reserve :  0 , 
741+ 				forwarding_info :  None , 
742+ 				outbound_htlc_minimum_msat :  None , 
743+ 				outbound_htlc_maximum_msat :  None , 
744+ 			} , 
745+ 			funding_txo :  Some ( OutPoint  { 
746+ 				txid :  bitcoin:: Txid :: from_slice ( & [ 0 ;  32 ] ) . unwrap ( ) , 
747+ 				index :  0 , 
748+ 			} ) , 
749+ 			channel_type :  None , 
750+ 			short_channel_id :  None , 
751+ 			outbound_scid_alias :  None , 
752+ 			inbound_scid_alias :  None , 
753+ 			channel_value_satoshis :  0 , 
754+ 			user_channel_id :  ( u64:: MAX  as  u128 )  + 1 ,  // Gets us into the high bytes 
755+ 			balance_msat :  0 , 
756+ 			outbound_capacity_msat :  0 , 
757+ 			next_outbound_htlc_limit_msat :  0 , 
758+ 			next_outbound_htlc_minimum_msat :  0 , 
759+ 			inbound_capacity_msat :  42 , 
760+ 			unspendable_punishment_reserve :  None , 
761+ 			confirmations_required :  None , 
762+ 			confirmations :  None , 
763+ 			force_close_spend_delay :  None , 
764+ 			is_outbound :  true , 
765+ 			is_channel_ready :  true , 
766+ 			is_usable :  true , 
767+ 			is_public :  true , 
768+ 			inbound_htlc_minimum_msat :  None , 
769+ 			inbound_htlc_maximum_msat :  None , 
770+ 			config :  None , 
771+ 			feerate_sat_per_1000_weight :  None , 
772+ 			channel_shutdown_state :  Some ( ChannelShutdownState :: NotShuttingDown ) , 
773+ 			pending_inbound_htlcs :  Vec :: new ( ) , 
774+ 			pending_outbound_htlcs :  Vec :: new ( ) , 
775+ 		} ; 
776+ 		let  mut  buffer = Vec :: new ( ) ; 
777+ 		channel_details. write ( & mut  buffer) . unwrap ( ) ; 
778+ 		let  deser_channel_details = ChannelDetails :: read ( & mut  buffer. as_slice ( ) ) . unwrap ( ) ; 
779+ 
780+ 		assert_eq ! ( deser_channel_details,  channel_details) ; 
781+ 	} 
782+ } 
0 commit comments