Skip to content

Commit

Permalink
Merge pull request #263 from Chia-Network/explorer-test-fix
Browse files Browse the repository at this point in the history
fix: explorer test
  • Loading branch information
wwills2 authored Feb 5, 2025
2 parents 308f4f5 + f56adda commit 4ee4b4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/retirement-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ const maybeAppendRetirementExplorerApiKey = (headers = {}) => {
*/
const getHomeOrgRetirementActivities = async (page, limit, minHeight) => {
try {
const homeOrgUid = await registry.getHomeOrgUid();

logger.debug(`GET ${retirementExplorerUri}/v1/activities`);
const response = await superagent
.get(`${retirementExplorerUri}/v1/activities`)
.query({
page,
limit,
org_uid: await registry.getHomeOrgUid(),
org_uid: homeOrgUid,
minHeight: Number(minHeight) + 1,
sort: "asc",
})
Expand Down
12 changes: 11 additions & 1 deletion tests/retirement-explorer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ const nock = require("nock");
const { getHomeOrgRetirementActivities } = require("../src/api/retirement-explorer");
const { CONFIG } = require("../src/config");
const { generateUriForHostAndPort } = require("../src/utils");
const HomeOrgMock = require("./data/HomeOrgMock");
const OrganizationsMock = require("./data/OrganizationsMock");

const retirementExplorerUri = generateUriForHostAndPort(
CONFIG().RETIREMENT_EXPLORER.PROTOCOL,
CONFIG().RETIREMENT_EXPLORER.HOST,
CONFIG().RETIREMENT_EXPLORER.PORT
);

const registryUri = generateUriForHostAndPort(
CONFIG().CADT.PROTOCOL,
CONFIG().CADT.HOST,
CONFIG().CADT.PORT
);

describe("getHomeOrgRetirementActivities", () => {
const apiEndpoint = retirementExplorerUri;
const mockResponse = {
Expand All @@ -21,8 +29,10 @@ describe("getHomeOrgRetirementActivities", () => {
beforeEach(() => {
nock(apiEndpoint)
.get("/v1/activities")
.query({ page: 1, limit: 10, org_uid: "a9d374baa8ced8b7a4add2a23f35f430fd7a3c99d1480d762e0b40572db4b024", minHeight: 1, sort: "asc" })
.query({ page: 1, limit: 10, org_uid: HomeOrgMock.orgUid, minHeight: 1, sort: "asc" })
.reply(200, mockResponse);

nock(registryUri).get("/v1/organizations").reply(200, OrganizationsMock);
});

it('should filter out activities that do not have a mode of "PERMISSIONLESS_RETIREMENT"', async () => {
Expand Down

0 comments on commit 4ee4b4e

Please sign in to comment.