Skip to content

Commit

Permalink
test(cardano-services): fixed flakiness in some chain history integra…
Browse files Browse the repository at this point in the history
…tion tests
  • Loading branch information
AngelCastilloB committed Nov 23, 2022
1 parent 38c0551 commit 0ad1b7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Expand Up @@ -454,7 +454,7 @@ describe('ChainHistoryHttpService', () => {

describe('finds transactions of given addresses', () => {
it('finds transactions with address within inputs', async () => {
const genesisAddresses: Cardano.Address[] = await fixtureBuilder.getGenesisAddresses();
const genesisAddresses: Cardano.Address[] = await fixtureBuilder.getDistinctAddresses(3);
const addresses: Cardano.Address[] = [genesisAddresses[0]];
const response = await provider.transactionsByAddresses({ addresses, pagination: { limit: 5, startAt: 0 } });
expect(response.pageResults.length).toBeGreaterThan(0);
Expand All @@ -468,11 +468,11 @@ describe('ChainHistoryHttpService', () => {
const addresses: Cardano.Address[] = await fixtureBuilder.getGenesisAddresses();
const firstPageResponse = await provider.transactionsByAddresses({
addresses,
pagination: { limit: 5, startAt: 0 }
pagination: { limit: 3, startAt: 0 }
});
const secondPageResponse = await provider.transactionsByAddresses({
addresses,
pagination: { limit: 5, startAt: 5 }
pagination: { limit: 3, startAt: 3 }
});

const firstTx = firstPageResponse.pageResults[0];
Expand Down
Expand Up @@ -163,7 +163,13 @@ describe('ChainHistoryBuilder', () => {
const txHashes = await fixtureBuilder.getTxHashes(2, { with: [TxWith.DelegationCertificate] });
const result = await builder.queryCertificatesByHashes(txHashes);
expect(result.size).toBeGreaterThanOrEqual(2);
expect(result.get(txHashes[0])).toMatchShapeOf(DataMocks.Tx.certificate);
const certificates = result.get(txHashes[0]);
let delegationCertificate;
for (let i = 0; i < certificates!.length; ++i) {
if (certificates![i].__typename === 'StakeDelegationCertificate') delegationCertificate = certificates![i];
}
expect(delegationCertificate).toBeDefined();
expect(delegationCertificate).toMatchShapeOf(DataMocks.Tx.certificate);
});
test('query certificates with empty array', async () => {
const result = await builder.queryCertificatesByHashes([]);
Expand Down
@@ -1,10 +1,8 @@
export const latestDistinctAddresses = `
SELECT
tx_out.address AS address
SELECT address, count(*) as tx_count
FROM tx_out
JOIN tx ON tx_out.tx_id = tx.id
JOIN block ON tx.block_id = block.id
ORDER BY block.id DESC
GROUP BY address
ORDER BY TX_COUNT desc
LIMIT $1`;

export const latestBlockHashes = `
Expand Down

0 comments on commit 0ad1b7d

Please sign in to comment.