File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -431,7 +431,7 @@ export class PgStore {
431
431
const txQuery = await sql < { tx_id : string } [ ] > `
432
432
SELECT tx_id
433
433
FROM txs
434
- WHERE microblock_hash = ${ args . microblockHash }
434
+ WHERE microblock_hash = ${ args . microblockHash } AND canonical = true AND microblock_canonical = true
435
435
ORDER BY tx_index DESC
436
436
` ;
437
437
const microblock = parseMicroblockQueryResult ( result [ 0 ] ) ;
Original file line number Diff line number Diff line change @@ -10813,6 +10813,34 @@ describe('api tests', () => {
10813
10813
expect ( addressEvents . status ) . toBe ( 400 ) ;
10814
10814
} ) ;
10815
10815
10816
+ test ( '/microblock/:hash duplicate txs' , async ( ) => {
10817
+ const microblock_hash = '0x0fff' ,
10818
+ tx_id = '0x1234' ;
10819
+ const block = new TestBlockBuilder ( { block_hash : '0x1234' , block_height : 1 } ) . build ( ) ;
10820
+ await db . update ( block ) ;
10821
+
10822
+ const microblock = new TestMicroblockStreamBuilder ( )
10823
+ . addMicroblock ( { microblock_hash, parent_index_block_hash : block . block . index_block_hash } )
10824
+ . addTx ( {
10825
+ tx_id,
10826
+ microblock_canonical : true ,
10827
+ canonical : true ,
10828
+ index_block_hash : '0x1234' ,
10829
+ } )
10830
+ . addTx ( {
10831
+ tx_id,
10832
+ microblock_canonical : false ,
10833
+ canonical : false ,
10834
+ index_block_hash : '0x123456' ,
10835
+ } )
10836
+ . build ( ) ;
10837
+ await db . updateMicroblocks ( microblock ) ;
10838
+
10839
+ const result = await supertest ( api . server ) . get ( `/extended/v1/microblock/${ microblock_hash } ` ) ;
10840
+ expect ( result . body . txs ) . toHaveLength ( 1 ) ;
10841
+ expect ( result . body . txs [ 0 ] ) . toEqual ( tx_id ) ;
10842
+ } ) ;
10843
+
10816
10844
afterEach ( async ( ) => {
10817
10845
await api . terminate ( ) ;
10818
10846
await db ?. close ( ) ;
You can’t perform that action at this time.
0 commit comments