From a284d6c6afa6ad6f3a67f55c57da4b7fcd0bc6f6 Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Mon, 2 Oct 2023 15:57:26 +0300 Subject: [PATCH] fix: bring back getabi endpoint e2e tests --- packages/api/test/contract-api.e2e-spec.ts | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/packages/api/test/contract-api.e2e-spec.ts b/packages/api/test/contract-api.e2e-spec.ts index 4a9fc59e90..1e1bc988eb 100644 --- a/packages/api/test/contract-api.e2e-spec.ts +++ b/packages/api/test/contract-api.e2e-spec.ts @@ -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";