@@ -2720,6 +2720,149 @@ describe('tx tests', () => {
27202720 ) ;
27212721 } ) ;
27222722
2723+ test ( 'tx list - filter by status' , async ( ) => {
2724+ const testSenderAddr = 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y' ;
2725+ const block1 = new TestBlockBuilder ( {
2726+ block_height : 1 ,
2727+ index_block_hash : '0x01' ,
2728+ burn_block_time : 1710000000 ,
2729+ } )
2730+ . addTx ( {
2731+ tx_id : '0x1234' ,
2732+ fee_rate : 1n ,
2733+ sender_address : testSenderAddr ,
2734+ status : DbTxStatus . Success ,
2735+ type_id : DbTxTypeId . TokenTransfer ,
2736+ token_transfer_amount : 123456n ,
2737+ token_transfer_memo : '0x1234' ,
2738+ token_transfer_recipient_address : 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y' ,
2739+ } )
2740+ . build ( ) ;
2741+
2742+ await db . update ( block1 ) ;
2743+
2744+ const block2 = new TestBlockBuilder ( {
2745+ block_height : 2 ,
2746+ index_block_hash : '0x02' ,
2747+ parent_block_hash : block1 . block . block_hash ,
2748+ parent_index_block_hash : block1 . block . index_block_hash ,
2749+ burn_block_time : 1720000000 ,
2750+ } )
2751+ . addTx ( {
2752+ tx_id : '0x2234' ,
2753+ fee_rate : 3n ,
2754+ sender_address : testSenderAddr ,
2755+ status : DbTxStatus . AbortByResponse ,
2756+ type_id : DbTxTypeId . ContractCall ,
2757+ contract_call_contract_id : 'SP000000000000000000002Q6VF78.pox-4' ,
2758+ contract_call_function_name : 'delegate-stx' ,
2759+ contract_call_function_args : bufferToHex (
2760+ createClarityValueArray ( uintCV ( 123456 ) , stringAsciiCV ( 'hello' ) )
2761+ ) ,
2762+ } )
2763+ . build ( ) ;
2764+ await db . update ( block2 ) ;
2765+
2766+ const block3 = new TestBlockBuilder ( {
2767+ block_height : 3 ,
2768+ index_block_hash : '0x03' ,
2769+ parent_block_hash : block2 . block . block_hash ,
2770+ parent_index_block_hash : block2 . block . index_block_hash ,
2771+ burn_block_time : 1730000000 ,
2772+ } )
2773+ . addTx ( {
2774+ tx_id : '0x3234' ,
2775+ fee_rate : 2n ,
2776+ sender_address : testSenderAddr ,
2777+ status : DbTxStatus . AbortByPostCondition ,
2778+ type_id : DbTxTypeId . TokenTransfer ,
2779+ token_transfer_amount : 123456n ,
2780+ token_transfer_memo : '0x1234' ,
2781+ token_transfer_recipient_address : 'ST27W5M8BRKA7C5MZE2R1S1F4XTPHFWFRNHA9M04Y' ,
2782+ } )
2783+ . build ( ) ;
2784+ await db . update ( block3 ) ;
2785+
2786+ const txsReq1 = await supertest ( api . server ) . get ( `/extended/v1/tx?status=success` ) ;
2787+ expect ( txsReq1 . status ) . toBe ( 200 ) ;
2788+ expect ( txsReq1 . body ) . toEqual (
2789+ expect . objectContaining ( {
2790+ results : [
2791+ expect . objectContaining ( {
2792+ tx_id : block1 . txs [ 0 ] . tx . tx_id ,
2793+ tx_status : 'success' ,
2794+ } ) ,
2795+ ] ,
2796+ } )
2797+ ) ;
2798+
2799+ const txsReq2 = await supertest ( api . server ) . get ( `/extended/v1/tx?status=abort_by_response` ) ;
2800+ expect ( txsReq2 . status ) . toBe ( 200 ) ;
2801+ expect ( txsReq2 . body ) . toEqual (
2802+ expect . objectContaining ( {
2803+ results : [
2804+ expect . objectContaining ( {
2805+ tx_id : block2 . txs [ 0 ] . tx . tx_id ,
2806+ tx_status : 'abort_by_response' ,
2807+ } ) ,
2808+ ] ,
2809+ } )
2810+ ) ;
2811+
2812+ const txsReq3 = await supertest ( api . server ) . get (
2813+ `/extended/v1/tx?status=abort_by_response,abort_by_post_condition`
2814+ ) ;
2815+ expect ( txsReq3 . status ) . toBe ( 200 ) ;
2816+ expect ( txsReq3 . body ) . toEqual (
2817+ expect . objectContaining ( {
2818+ results : [
2819+ expect . objectContaining ( {
2820+ tx_id : block3 . txs [ 0 ] . tx . tx_id ,
2821+ tx_status : 'abort_by_post_condition' ,
2822+ } ) ,
2823+ expect . objectContaining ( {
2824+ tx_id : block2 . txs [ 0 ] . tx . tx_id ,
2825+ tx_status : 'abort_by_response' ,
2826+ } ) ,
2827+ ] ,
2828+ } )
2829+ ) ;
2830+
2831+ const txsReq4 = await supertest ( api . server ) . get (
2832+ `/extended/v1/tx?status=success&type=token_transfer`
2833+ ) ;
2834+ expect ( txsReq4 . status ) . toBe ( 200 ) ;
2835+ expect ( txsReq4 . body ) . toEqual (
2836+ expect . objectContaining ( {
2837+ results : [
2838+ expect . objectContaining ( {
2839+ tx_id : block1 . txs [ 0 ] . tx . tx_id ,
2840+ tx_status : 'success' ,
2841+ tx_type : 'token_transfer' ,
2842+ } ) ,
2843+ ] ,
2844+ } )
2845+ ) ;
2846+
2847+ const txsReq5 = await supertest ( api . server ) . get (
2848+ `/extended/v1/tx?status=abort_by_post_condition&type=coinbase`
2849+ ) ;
2850+ expect ( txsReq5 . status ) . toBe ( 200 ) ;
2851+ expect ( txsReq5 . body ) . toEqual (
2852+ expect . objectContaining ( {
2853+ results : [ ] ,
2854+ } )
2855+ ) ;
2856+ } ) ;
2857+
2858+ test ( 'tx list - invalid status filter' , async ( ) => {
2859+ const txsReq1 = await supertest ( api . server ) . get ( `/extended/v1/tx?status=invalid_status` ) ;
2860+ expect ( txsReq1 . status ) . toBe ( 400 ) ;
2861+
2862+ const txsReq2 = await supertest ( api . server ) . get ( `/extended/v1/tx?status=pending` ) ;
2863+ expect ( txsReq2 . status ) . toBe ( 400 ) ;
2864+ } ) ;
2865+
27232866 test ( 'fetch raw tx' , async ( ) => {
27242867 const block : DbBlock = {
27252868 block_hash : '0x1234' ,
0 commit comments