Skip to content

Commit

Permalink
fix: new one
Browse files Browse the repository at this point in the history
  • Loading branch information
olehbairak committed Feb 14, 2024
1 parent d8daa3d commit 8523fac
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/integration-tests/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const localConfig = {

export const environment = {
blockExplorerAPI: "http://localhost:3020",
blockExplorerSepoliaAPI: "https://block-explorer-api.sepolia.zksync.dev",
};
1 change: 1 addition & 0 deletions packages/integration-tests/src/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum Buffer {
greeterL2 = "./buffer/greeterL2.txt",
greeterL2VerifiedSepolia = "./buffer/sepoliaGreeterVerified.txt",
executeGreeterTx = "./buffer/executeGreeterTx.txt",
NFTtoL1 = "./buffer/NFTtoL1.txt",
NFTtoL2 = "./buffer/NFTtoL2.txt",
Expand Down
8 changes: 6 additions & 2 deletions packages/integration-tests/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ export class Helper {
return new Promise((resolve) => setTimeout(resolve, ms));
}

async performGETrequest(apiRoute: string) {
return request(environment.blockExplorerAPI).get(apiRoute);
async performGETrequest(apiRoute: string, network = "local") {
if (network === `local`) {
return request(environment.blockExplorerAPI).get(apiRoute);
} else if (network === `sepolia`) {
return request(environment.blockExplorerSepoliaAPI).get(apiRoute);
}
}

/**
Expand Down
56 changes: 56 additions & 0 deletions packages/integration-tests/tests/api/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,62 @@ describe("API module: Contract", () => {
beforeAll(async () => {
await playbook.deployViaPaymaster();
await playbook.deployMultiCallContracts();
await playbook.deployGreeterToL2();
});

//id1851
it("Verify /api?module=contract&action=checkverifystatus response", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=contract&action=checkverifystatus&guid=3177`;
response = await helper.performGETrequest(apiRoute, "sepolia");
console.log(response.body);

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Pass - Verified" }));
});
});

//id1695
it("Verify /api?module=contract&action=getabi response", async () => {
await helper.retryTestAction(async () => {
const greeterContract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2VerifiedSepolia);
apiRoute = `/api?module=contract&action=getabi&address=${greeterContract}`;
response = await helper.performGETrequest(apiRoute, "sepolia");

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result).toStrictEqual("string");
});
});

//id1802
it("Verify /api?module=contract&action=getsourcecode response", async () => {
await helper.retryTestAction(async () => {
const greeterContract = await helper.getStringFromFile(bufferFile + Buffer.greeterL2VerifiedSepolia);
apiRoute = `/api?module=contract&action=getsourcecode&address=${greeterContract}`;
response = await helper.performGETrequest(apiRoute, "sepolia");

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result[0].ABI).toStrictEqual("string");
expect(typeof response.body.result[0].SourceCode).toStrictEqual("string");
expect(typeof response.body.result[0].ConstructorArguments).toStrictEqual("string");
expect(typeof response.body.result[0].ContractName).toStrictEqual("string");
expect(typeof response.body.result[0].EVMVersion).toStrictEqual("string");
expect(typeof response.body.result[0].OptimizationUsed).toStrictEqual("string");
expect(typeof response.body.result[0].Library).toStrictEqual("string");
expect(typeof response.body.result[0].LicenseType).toStrictEqual("string");
expect(typeof response.body.result[0].CompilerVersion).toStrictEqual("string");
expect(typeof response.body.result[0].Runs).toStrictEqual("string");
expect(typeof response.body.result[0].SwarmSource).toStrictEqual("string");
expect(typeof response.body.result[0].Proxy).toStrictEqual("string");
expect(typeof response.body.result[0].Implementation).toStrictEqual("string");
expect(typeof response.body.result[0].ZkCompilerVersion).toStrictEqual("string");
});
});

//@id1696
Expand Down
20 changes: 20 additions & 0 deletions packages/integration-tests/tests/api/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ describe("Tokens", () => {
});
});

//id1907
it("Verify /api?module=token&action=tokeninfo response", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=token&action=tokeninfo&contractaddress=${Token.ETHER_ERC20_Address}`;
response = await helper.performGETrequest(apiRoute);

expect(response.status).toBe(200);
expect(response.body).toStrictEqual(expect.objectContaining({ status: "1" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "OK" }));
expect(typeof response.body.result[0].contractAddress).toStrictEqual("string");
expect(typeof response.body.result[0].tokenName).toStrictEqual("string");
expect(typeof response.body.result[0].symbol).toStrictEqual("string");
expect(typeof response.body.result[0].tokenDecimal).toStrictEqual("string");
expect(typeof response.body.result[0].tokenPriceUSD).toStrictEqual("string");
expect(typeof response.body.result[0].liquidity).toStrictEqual("string");
expect(typeof response.body.result[0].l1Address).toStrictEqual("string");
expect(typeof response.body.result[0].iconURL).toStrictEqual("string");
});
});

//id1803
it("Verify the response via /tokens/{address}/transfers", async () => {
await helper.retryTestAction(async () => {
Expand Down

0 comments on commit 8523fac

Please sign in to comment.