Skip to content

Commit

Permalink
fix: bring back getabi endpoint e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Oct 2, 2023
1 parent 8e7e9d5 commit a284d6c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/api/test/contract-api.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,50 @@ describe("Contract API (e2e)", () => {
await app.close();
});

describe("/api?module=contract&action=getabi GET", () => {
it("returns HTTP 200 and contract ABI when verification API returns the contract ABI", () => {
const address = "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

nock(CONTRACT_VERIFICATION_API_URL)
.get(`/contract_verification/info/0xffffffffffffffffffffffffffffffffffffffff`)
.reply(200, {
artifacts: {
abi: [],
},
});

return request(app.getHttpServer())
.get(`/api?module=contract&action=getabi&address=${address}`)
.expect(200)
.expect((res) =>
expect(res.body).toStrictEqual({
status: "1",
message: "OK",
result: "[]",
})
);
});

it("returns HTTP 200 and error result when verification API does not return the contract ABI", () => {
const address = "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

nock(CONTRACT_VERIFICATION_API_URL)
.get(`/contract_verification/info/0xffffffffffffffffffffffffffffffffffffffff`)
.reply(200, {});

return request(app.getHttpServer())
.get(`/api?module=contract&action=getabi&address=${address}`)
.expect(200)
.expect((res) =>
expect(res.body).toStrictEqual({
status: "0",
message: "NOTOK",
result: "Contract source code not verified",
})
);
});
});

describe("/api?module=contract&action=getsourcecode GET", () => {
it("returns HTTP 200 and contract source code for verified single file Solidity contract", () => {
const address = "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
Expand Down

0 comments on commit a284d6c

Please sign in to comment.