@@ -62,6 +62,43 @@ fn to_bytes_from_bytes() -> crate::Result<()> {
6262 Ok ( ( ) )
6363}
6464
65+ #[ test]
66+ fn signed_to_bytes_from_bytes_preserves_signatures ( ) -> crate :: Result < ( ) > {
67+ let mut tx = TransferTransaction :: new ( ) ;
68+
69+ // Build a minimal, frozen transaction (no network dependency)
70+ let mut tx = tx
71+ . max_transaction_fee ( Hbar :: new ( 10 ) )
72+ . transaction_valid_duration ( time:: Duration :: seconds ( 119 ) )
73+ . transaction_memo ( "signed-preserve-test" )
74+ . hbar_transfer ( 2 . into ( ) , Hbar :: new ( 2 ) )
75+ . hbar_transfer ( 101 . into ( ) , Hbar :: new ( -2 ) )
76+ . transaction_id ( TransactionId {
77+ account_id : 101 . into ( ) ,
78+ valid_start : OffsetDateTime :: now_utc ( ) ,
79+ nonce : None ,
80+ scheduled : false ,
81+ } )
82+ . node_account_ids ( [ 6 . into ( ) , 7 . into ( ) ] )
83+ . freeze ( ) ?;
84+
85+ // Sign with an arbitrary key
86+ let key: PrivateKey = "302e020100300506032b657004220420e40d4241d093b22910c78135e0501b137cd9205bbb9c0153c5adf2c65e7dc95a"
87+ . parse ( )
88+ . unwrap ( ) ;
89+ tx. sign ( key) ;
90+
91+ // Serialize, then deserialize, then serialize again
92+ let bytes_before = tx. to_bytes ( ) ?;
93+ let tx2 = AnyTransaction :: from_bytes ( & bytes_before) ?;
94+ let bytes_after = tx2. to_bytes ( ) ?;
95+
96+ // If signatures are preserved, bytes should match
97+ assert_eq ! ( bytes_before, bytes_after) ;
98+
99+ Ok ( ( ) )
100+ }
101+
65102#[ test]
66103fn from_bytes_sign_to_bytes ( ) -> crate :: Result < ( ) > {
67104 let mut tx = TransferTransaction :: new ( ) ;
0 commit comments