@@ -185,6 +185,55 @@ def test_standard_tx(self):
185185 self .assertFalse (tx3 .is_standard ())
186186 self .assertTrue (tx3 .is_standard (only_standard_script_type = False ))
187187
188+ def test_tx_with_nano_and_fee_headers (self ):
189+ """Test Transaction with NanoHeader and FeeHeader"""
190+ from hathorlib .headers import FeeHeader , NanoHeader
191+
192+ data = bytes .fromhex (
193+ '0001010102a63cd61c1265d2ddcaf9e59072e999be92f1e8b3a9f80d3059667ebd07acff8200000b55'
194+ '0310ce5d2405848b90497875979809205758c3be336d58fa4b358e7400006946304402201ce9d15038'
195+ '2e74fb123fdb9b418372ab02f5e342eef77302711ba25bbad6fc2a022079552147f44d01fe5339e3e1'
196+ '1748b5fb7bce1f45389daf8314d60a50c87b3a2e21036acf7120c9c95d917ab44ebf223f9c9fe202c3'
197+ 'f61a963469ac99dadbb7f066450000006401001976a914ce852b6869b2e6a78341beaf68e301784696'
198+ '605e88ac0000225f00001976a914cc62dd4e0d45b3c92768eb8d31d32ee203aa968088ac4034451999'
199+ '38bb1f694ac1350000000000100000096571b0cae543f7b16d395b19b655a1266210de1892fd127c3'
200+ '15aa04ff105046e6f6f700001000102010000006449ce852b6869b2e6a78341beaf68e30178469660'
201+ '5e819040746946304402201ce9d150382e74fb123fdb9b418372ab02f5e342eef77302711ba25bbad6'
202+ 'fc2a022079552147f44d01fe5339e3e11748b5fb7bce1f45389daf8314d60a50c87b3a2e21036acf71'
203+ '20c9c95d917ab44ebf223f9c9fe202c3f61a963469ac99dadbb7f0664511010000000001'
204+ )
205+
206+ tx = Transaction .create_from_struct (data )
207+
208+ # Verify the transaction can be serialized and deserialized correctly
209+ self .assertEqual (data , bytes (tx ))
210+
211+ # Verify basic transaction properties
212+ self .assertTrue (tx .is_transaction )
213+ self .assertFalse (tx .is_block )
214+ self .assertTrue (tx .has_fees ())
215+ self .assertTrue (tx .is_nano_contract ())
216+
217+ # Verify transaction structure
218+ self .assertEqual (len (tx .inputs ), 1 )
219+ self .assertEqual (len (tx .outputs ), 2 )
220+ self .assertEqual (len (tx .tokens ), 1 )
221+ self .assertEqual (len (tx .headers ), 2 )
222+
223+ # Verify the headers are of correct types
224+ nano_header = tx .get_nano_header ()
225+ fee_header = tx .get_fee_header ()
226+ self .assertIsInstance (nano_header , NanoHeader )
227+ self .assertIsInstance (fee_header , FeeHeader )
228+
229+ # Verify the fee header contains the expected fee entry
230+ self .assertEqual (len (fee_header .fees ), 1 )
231+ self .assertEqual (fee_header .fees [0 ].token_index , 0 )
232+ self .assertEqual (fee_header .fees [0 ].amount , 1 )
233+
234+ # Verify the nano header has expected method
235+ self .assertEqual (nano_header .nc_method , 'noop' )
236+
188237 def test_tx_version_and_signal_bits (self ):
189238 from hathorlib .base_transaction import TxVersion
190239
0 commit comments