Skip to content

Commit

Permalink
feat: first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
olehbairak committed Aug 22, 2024
1 parent 0c71d0d commit 14214a6
Show file tree
Hide file tree
Showing 2 changed files with 302 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/integration-tests/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ export enum BlockExplorer {
baseUrl = "http://localhost:3010",
localNetwork = "/?network=local",
}

export enum Values {
incorrectAddressFormat = "0xE4ce1da467a7Ca37727eb7e19857e5167DE25966123",
}
300 changes: 298 additions & 2 deletions packages/integration-tests/tests/api/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as request from "supertest";

import { environment } from "../../src/config";
import { localConfig } from "../../src/config";
import { Buffer, Token, Wallets } from "../../src/entities";
import { Buffer, Token, Values, Wallets } from "../../src/entities";
import { Helper } from "../../src/helper";
import { Playbook } from "../../src/playbook/playbook";

Expand Down Expand Up @@ -245,7 +245,7 @@ describe("API module: Account", () => {
});

//@id1807
it("Verify /api?module=account&action=getminedblocks", async () => {
it.only("Verify /api?module=account&action=getminedblocks", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=getminedblocks&page=1&offset=10&address=0x0000000000000000000000000000000000000000`;
response = await helper.performGETrequest(apiRoute);
Expand All @@ -259,5 +259,301 @@ describe("API module: Account", () => {
expect(typeof response.body.result[0].blockReward).toStrictEqual("string");
});
});

//id1968
it("Verify /balance endpoint - Incorrect address format", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=balance&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Invalid Address format" }));
});
});
//id1944
it("Verify /balancemulti endpoint - Incorrect address format", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=balancemulti&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Error! Invalid address format" }));
});
});

it("Verify /balancemulti endpoint - No address in URL parameters", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=balancemulti&address=`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Error! Missing address" }));
});
});

//id1943
it("Verify /tokennfttx endpoint - Incorrect contract address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokennfttx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Values.incorrectAddressFormat}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({ result: "Error! Invalid contract address format" })
);
});
});
it("Verify /tokennfttx endpoint - Incorrect address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokennfttx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Values.incorrectAddressFormat}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({ result: "Error! Invalid contract address format" })
);
});
});

it("Verify /tokennfttx endpoint - Incorrect offset position in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokennfttx&page=1&offset=0&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Wallets.richWalletAddress}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "offset must not be less than 1" }));
});
});

it("Verify /tokennfttx endpoint - Incorrect block number in request", async () => {
await helper.retryTestAction(async () => {
const blockNumber = "-99999999";
apiRoute = `/api?module=account&action=tokennfttx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Wallets.richWalletAddress}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({
result: "Validation failed: specified int is out of defined boundaries: [0;9007199254740991].",
})
);
});
});

//id1940
it("Verify /tokentx endpoint - Incorrect contract address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokentx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Values.incorrectAddressFormat}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({ result: "Error! Invalid contract address format" })
);
});
});
it("Verify /tokentx endpoint - Incorrect address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokentx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Wallets.richWalletAddress}&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Error! Invalid address format" }));
});
});

it("Verify /tokentx endpoint - Incorrect offset position in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=tokentx&page=1&offset=0&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Wallets.richWalletAddress}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "offset must not be less than 1" }));
});
});

it("Verify /tokentx endpoint - Incorrect block number in request", async () => {
await helper.retryTestAction(async () => {
const blockNumber = "-99999999";
apiRoute = `/api?module=account&action=tokentx&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&contractaddress=${Wallets.richWalletAddress}&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({
result: "Validation failed: specified int is out of defined boundaries: [0;9007199254740991].",
})
);
});
});

//id1969
it("Verify /getminedblocks endpoint - Incorrect contract address format", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=getminedblocks&page=1&offset=10&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Invalid Address format" }));
});
});

it("Verify /getminedblocks endpoint - Incorrect offset position in request", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=getminedblocks&page=1&offset=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "offset must not be less than 1" }));
});
});

it("Verify /getminedblocks endpoint - Incorrect page number in request", async () => {
await helper.retryTestAction(async () => {
apiRoute = `/api?module=account&action=getminedblocks&page=-1&offset=10&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "page must not be less than 1" }));
});
});

//id1967
it("Verify /txlist endpoint - Incorrect contract address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlist&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Invalid Address format" }));
});
});

it("Verify /txlist endpoint - Incorrect offset position in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlist&page=1&offset=0&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "offset must not be less than 1" }));
});
});

it("Verify /txlist endpoint - Incorrect block number in request", async () => {
await helper.retryTestAction(async () => {
const blockNumber = "-99999999";
apiRoute = `/api?module=account&action=txlist&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({
result: "Validation failed: specified int is out of defined boundaries: [0;9007199254740991].",
})
);
});
});

it("Verify /txlist endpoint - Incorrect page number in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlist&page=-1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "page must not be less than 1" }));
});
});

//id1935
it("Verify /txlistinternal endpoint - Incorrect contract address format", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Values.incorrectAddressFormat}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "Error! Invalid address format" }));
});
});

it("Verify /txlistinternal endpoint - Incorrect offset position in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=0&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "offset must not be less than 1" }));
});
});

it("Verify /txlistinternal endpoint - Incorrect block number in request", async () => {
await helper.retryTestAction(async () => {
const blockNumber = "-99999999";
apiRoute = `/api?module=account&action=txlistinternal&page=1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(
expect.objectContaining({
result: "Validation failed: specified int is out of defined boundaries: [0;9007199254740991].",
})
);
});
});

it("Verify /txlistinternal endpoint - Incorrect page number in request", async () => {
await helper.retryTestAction(async () => {
const blocks = await request(environment.blockExplorerAPI).get("/blocks");
const blockNumber = blocks.body.items[0].number;
apiRoute = `/api?module=account&action=txlistinternal&page=-1&offset=10&sort=desc&endblock=${blockNumber}&startblock=0&address=${Wallets.richWalletAddress}`;
response = await helper.performGETrequest(apiRoute);

expect(response.body).toStrictEqual(expect.objectContaining({ status: "0" }));
expect(response.body).toStrictEqual(expect.objectContaining({ message: "NOTOK" }));
expect(response.body).toStrictEqual(expect.objectContaining({ result: "page must not be less than 1" }));
});
});
});
});

0 comments on commit 14214a6

Please sign in to comment.