@@ -730,6 +730,133 @@ describe('Rosetta API', () => {
730
730
} ) ;
731
731
} ) ;
732
732
733
+ test ( 'epoch3 tenure-change block/transaction' , async ( ) => {
734
+ const parentData = new TestBlockBuilder ( ) . addTx ( ) . build ( ) ;
735
+ const block1 : TestBlockArgs = {
736
+ block_height : 2 ,
737
+ block_hash : '0xd0dd05e3d0a1bd60640c9d9d30d57012ffe47b52fe643140c39199c757d37e3f' ,
738
+ index_block_hash : '0x6a36c14514047074c2877065809bbb70d81d52507747f4616da997deb7228fad' ,
739
+ parent_index_block_hash : parentData . block . index_block_hash ,
740
+ parent_block_hash : parentData . block . block_hash ,
741
+ parent_microblock_hash : '0x0000000000000000000000000000000000000000000000000000000000000000' ,
742
+ burn_block_hash : '0xfe15c0d3ebe314fad720a08b839a004c2e6386f5aecc19ec74807d1920cb6aeb' ,
743
+ miner_txid : '0x0000000000000000000000000000000000000000000000000000000000000000' ,
744
+ } ;
745
+ const txTenureChange1 : TestTxArgs = {
746
+ tx_id : '0xc152de9376bab4fc27291c9cd088643698290a12bb511d768f873cb3d280eb48' ,
747
+ tx_index : 1 ,
748
+ type_id : DbTxTypeId . TenureChange ,
749
+ status : DbTxStatus . Success ,
750
+ raw_result : '0x0703' ,
751
+ canonical : true ,
752
+ microblock_canonical : true ,
753
+ microblock_sequence : 2147483647 ,
754
+ microblock_hash : '0x00' ,
755
+ fee_rate : 0n ,
756
+ sender_address : 'ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR' ,
757
+ tenure_change_tenure_consensus_hash : '0x2fedd90a5f318ed8cec419fd1c6656b5af452497' ,
758
+ tenure_change_prev_tenure_consensus_hash : '0x5104aae6d442b49c8e8d2031df7f40b67528e654' ,
759
+ tenure_change_burn_view_consensus_hash : '0x2fedd90a5f318ed8cec419fd1c6656b5af452497' ,
760
+ tenure_change_previous_tenure_end :
761
+ '0xb77b061202b1e6dce889ba1633efa969d3c24679d32a7542d29015ee94e8a860' ,
762
+ tenure_change_previous_tenure_blocks : 9 ,
763
+ tenure_change_cause : 0 ,
764
+ tenure_change_pubkey_hash : '0x62b4273562dfa3825496094507564bf2b30c8b11' ,
765
+ } ;
766
+ const blockData1 = new TestBlockBuilder ( block1 ) . addTx ( txTenureChange1 ) . build ( ) ;
767
+
768
+ await db . update ( parentData ) ;
769
+ await db . update ( blockData1 ) ;
770
+
771
+ const query1 = await supertest ( api . server )
772
+ . post ( `/rosetta/v1/block/transaction` )
773
+ . send ( {
774
+ network_identifier : { blockchain : 'stacks' , network : 'testnet' } ,
775
+ block_identifier : {
776
+ index : blockData1 . block . block_height ,
777
+ hash : blockData1 . block . block_hash ,
778
+ } ,
779
+ transaction_identifier : { hash : txTenureChange1 . tx_id } ,
780
+ } ) ;
781
+ expect ( query1 . status ) . toBe ( 200 ) ;
782
+ expect ( query1 . type ) . toBe ( 'application/json' ) ;
783
+ expect ( query1 . body ) . toEqual ( {
784
+ transaction_identifier : {
785
+ hash : txTenureChange1 . tx_id ,
786
+ } ,
787
+ operations : [
788
+ {
789
+ operation_identifier : {
790
+ index : 0 ,
791
+ } ,
792
+ type : 'tenure_change' ,
793
+ status : 'success' ,
794
+ metadata : {
795
+ tenure_consensus_hash : txTenureChange1 . tenure_change_tenure_consensus_hash ,
796
+ prev_tenure_consensus_hash : txTenureChange1 . tenure_change_prev_tenure_consensus_hash ,
797
+ burn_view_consensus_hash : txTenureChange1 . tenure_change_burn_view_consensus_hash ,
798
+ previous_tenure_end : txTenureChange1 . tenure_change_previous_tenure_end ,
799
+ previous_tenure_blocks : txTenureChange1 . tenure_change_previous_tenure_blocks ,
800
+ cause : 'block_found' ,
801
+ pubkey_hash : txTenureChange1 . tenure_change_pubkey_hash ,
802
+ } ,
803
+ } ,
804
+ ] ,
805
+ } ) ;
806
+
807
+ const query2 = await supertest ( api . address )
808
+ . post ( `/rosetta/v1/block` )
809
+ . send ( {
810
+ network_identifier : { blockchain : 'stacks' , network : 'testnet' } ,
811
+ block_identifier : { index : blockData1 . block . block_height } ,
812
+ } ) ;
813
+ expect ( query1 . status ) . toBe ( 200 ) ;
814
+ expect ( query1 . type ) . toBe ( 'application/json' ) ;
815
+ const expected : RosettaBlockResponse = {
816
+ block : {
817
+ block_identifier : {
818
+ index : blockData1 . block . block_height ,
819
+ hash : blockData1 . block . block_hash ,
820
+ } ,
821
+ parent_block_identifier : {
822
+ index : blockData1 . block . block_height - 1 ,
823
+ hash : blockData1 . block . parent_block_hash ,
824
+ } ,
825
+ timestamp : blockData1 . block . burn_block_time * 1000 ,
826
+ transactions : [
827
+ {
828
+ transaction_identifier : {
829
+ hash : txTenureChange1 . tx_id as string ,
830
+ } ,
831
+ operations : [
832
+ {
833
+ operation_identifier : {
834
+ index : 0 ,
835
+ } ,
836
+ type : 'tenure_change' ,
837
+ status : 'success' ,
838
+ metadata : {
839
+ tenure_consensus_hash : txTenureChange1 . tenure_change_tenure_consensus_hash ,
840
+ prev_tenure_consensus_hash :
841
+ txTenureChange1 . tenure_change_prev_tenure_consensus_hash ,
842
+ burn_view_consensus_hash : txTenureChange1 . tenure_change_burn_view_consensus_hash ,
843
+ previous_tenure_end : txTenureChange1 . tenure_change_previous_tenure_end ,
844
+ previous_tenure_blocks : txTenureChange1 . tenure_change_previous_tenure_blocks ,
845
+ cause : 'block_found' ,
846
+ pubkey_hash : txTenureChange1 . tenure_change_pubkey_hash ,
847
+ } ,
848
+ } ,
849
+ ] ,
850
+ } ,
851
+ ] ,
852
+ metadata : {
853
+ burn_block_height : blockData1 . block . burn_block_height ,
854
+ } ,
855
+ } ,
856
+ } ;
857
+ expect ( query2 . body ) . toEqual ( expected ) ;
858
+ } ) ;
859
+
733
860
test ( 'block/transaction - invalid transaction hash' , async ( ) => {
734
861
const query1 = await supertest ( api . server )
735
862
. post ( `/rosetta/v1/block/transaction` )
0 commit comments