mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 16:53:19 +08:00
fix: remove duplicate txs in microblock responses (#1167)
* test: added test for duplicate txs in microblocks * fix: rebased with develop * test: updated txs with microblock * test: removed unnecessary comments
This commit is contained in:
@@ -431,7 +431,7 @@ export class PgStore {
|
||||
const txQuery = await sql<{ tx_id: string }[]>`
|
||||
SELECT tx_id
|
||||
FROM txs
|
||||
WHERE microblock_hash = ${args.microblockHash}
|
||||
WHERE microblock_hash = ${args.microblockHash} AND canonical = true AND microblock_canonical = true
|
||||
ORDER BY tx_index DESC
|
||||
`;
|
||||
const microblock = parseMicroblockQueryResult(result[0]);
|
||||
|
||||
@@ -10813,6 +10813,34 @@ describe('api tests', () => {
|
||||
expect(addressEvents.status).toBe(400);
|
||||
});
|
||||
|
||||
test('/microblock/:hash duplicate txs', async () => {
|
||||
const microblock_hash = '0x0fff',
|
||||
tx_id = '0x1234';
|
||||
const block = new TestBlockBuilder({ block_hash: '0x1234', block_height: 1 }).build();
|
||||
await db.update(block);
|
||||
|
||||
const microblock = new TestMicroblockStreamBuilder()
|
||||
.addMicroblock({ microblock_hash, parent_index_block_hash: block.block.index_block_hash })
|
||||
.addTx({
|
||||
tx_id,
|
||||
microblock_canonical: true,
|
||||
canonical: true,
|
||||
index_block_hash: '0x1234',
|
||||
})
|
||||
.addTx({
|
||||
tx_id,
|
||||
microblock_canonical: false,
|
||||
canonical: false,
|
||||
index_block_hash: '0x123456',
|
||||
})
|
||||
.build();
|
||||
await db.updateMicroblocks(microblock);
|
||||
|
||||
const result = await supertest(api.server).get(`/extended/v1/microblock/${microblock_hash}`);
|
||||
expect(result.body.txs).toHaveLength(1);
|
||||
expect(result.body.txs[0]).toEqual(tx_id);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await api.terminate();
|
||||
await db?.close();
|
||||
|
||||
Reference in New Issue
Block a user