Skip to content

Commit

Permalink
test(cardano-services): rebuild fixtues and adapt the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iccicci committed May 30, 2024
1 parent c6d0d7b commit cd351b0
Show file tree
Hide file tree
Showing 7 changed files with 8,200 additions and 14,658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -962,9 +962,10 @@ describe('StakePoolHttpService', () => {
expect(response.pageResults).toEqual(responseCached.pageResults);
expect(response.pageResults[0].status).toEqual(Cardano.StakePoolStatus.Activating);
});
it('pledgeMet false, status activating, and condition', async () => {

it('pledgeMet false, status active, and condition', async () => {
const activating = await fixtureBuilder.getPools(1, {
with: [PoolWith.ActivatingState, PoolWith.PledgeNotMet]
with: [PoolWith.ActiveState, PoolWith.PledgeNotMet]
});
const filter: QueryStakePoolsArgs = {
filters: {
Expand All @@ -975,13 +976,14 @@ describe('StakePoolHttpService', () => {
pagination
};

const options = addPledgeMetFilter(addStatusFilter(filter, Cardano.StakePoolStatus.Activating), false);
const options = addPledgeMetFilter(addStatusFilter(filter, Cardano.StakePoolStatus.Active), false);
const response = await provider.queryStakePools(options);
const responseCached = await provider.queryStakePools(options);
expect(response.pageResults.length).toBeGreaterThan(0);
expect(response.pageResults).toEqual(responseCached.pageResults);
expect(response.pageResults[0].status).toEqual(Cardano.StakePoolStatus.Activating);
expect(response.pageResults[0].status).toEqual(Cardano.StakePoolStatus.Active);
});

it('pledgeMet true, status retired, or condition', async () => {
const options = addPledgeMetFilter(
addStatusFilter(setFilterCondition(filterArgs, 'or'), Cardano.StakePoolStatus.Retired),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('TypeormStakePoolProvider', () => {
let filterArgs: QueryStakePoolsArgs;
let poolsInfo: PoolInfo[];
let poolsInfoWithMeta: PoolInfo[];
let poolsInfoWithUniqueMeta: PoolInfo[];
let poolsInfoWithMetaFiltered: PoolInfo[];
let poolsInfoWithMetrics: PoolInfo[];
let poolsInfoWithMetricsFiltered: PoolInfo[];
Expand Down Expand Up @@ -108,15 +109,18 @@ describe('TypeormStakePoolProvider', () => {
poolsInfo = await fixtureBuilder.getPools(1000, ['active', 'activating', 'retired', 'retiring']);
poolsInfoWithMeta = poolsInfo.filter((pool) => isNotNil(pool.metadataUrl));
poolsInfoWithMetrics = poolsInfo.filter((pool) => isNotNil(pool.saturation));
poolsInfoWithUniqueMeta = poolsInfoWithMeta
.filter(({ name, ticker }) => name !== 'Same Name' && ticker !== 'SP6a7')
.sort((a, b) => (a.name < b.name ? -1 : 1));

filterArgs = {
filters: {
identifier: {
_condition: 'or',
values: [
{ ticker: poolsInfoWithMeta[0].ticker },
{ name: poolsInfoWithMeta[1].name },
{ id: poolsInfoWithMeta[2].id }
{ ticker: poolsInfoWithUniqueMeta[0].ticker },
{ name: poolsInfoWithUniqueMeta[1].name },
{ id: poolsInfoWithUniqueMeta[2].id }
]
}
},
Expand Down Expand Up @@ -625,7 +629,7 @@ describe('TypeormStakePoolProvider', () => {
describe('by default, result is sorted by relevance', () => {
it('with stringent search', async () => {
const response = await provider.queryStakePools({ filters: { text: 'sp11' }, pagination });
expect(response.pageResults.map(({ metadata }) => metadata?.ticker)).toEqual(['SP11', 'SP1', 'SP10']);
expect(response.pageResults.map(({ metadata }) => metadata?.ticker)).toEqual(['SP11', 'SP10', 'SP1']);
});

it('with mild search', async () => {
Expand Down Expand Up @@ -739,7 +743,7 @@ describe('TypeormStakePoolProvider', () => {
const response = await provider.queryStakePools(
setSortCondition(setFilterCondition(filterArgs, 'or'), 'asc', 'ticker')
);
const expected = [...poolsInfoWithMeta].sort((a, b) => (a.ticker < b.ticker ? -1 : 1));
const expected = [...poolsInfoWithMetricsFiltered].sort((a, b) => (a.ticker < b.ticker ? -1 : 1));
expect(response.pageResults[0].metadata?.ticker).toEqual(expected[0].ticker);
expect(response.pageResults[1].metadata?.ticker).toEqual(expected[1].ticker);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ yarn test:build:verify

yarn workspace @cardano-sdk/e2e local-network:down
yarn workspace @cardano-sdk/e2e local-network:up -d --build
yarn workspace @cardano-sdk/e2e wait-for-network

yarn workspace @cardano-sdk/e2e test:wallet
yarn workspace @cardano-sdk/e2e test:long-running simple-delegation-rewards.test.ts
Expand Down
Loading

0 comments on commit cd351b0

Please sign in to comment.