Skip to content

Commit

Permalink
Merge remote-tracking branch 'ArkEcosystem/core/develop' into blockid
Browse files Browse the repository at this point in the history
* ArkEcosystem/core/develop:
  fix(core-tester-cli): Fix the description of debug:serialize
  test: remove integration setup & tests from unit tests (#2194)
  • Loading branch information
vasild committed Mar 8, 2019
2 parents 2466311 + 183eab1 commit fee99c3
Show file tree
Hide file tree
Showing 98 changed files with 1,192 additions and 1,381 deletions.
174 changes: 90 additions & 84 deletions .circleci/config.yml

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions __tests__/integration/core-api/v2/handlers/delegates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const delegate = {

const delegate2 = {
username: "genesis_11",
}
};

beforeAll(async () => {
await setUp();
Expand Down Expand Up @@ -217,7 +217,7 @@ describe("API 2.0 - Delegates", () => {
(header, request) => {
it("should POST a search for delegates with an address that matches the given string", async () => {
const response = await utils[request]("POST", "delegates/search", {
address: delegate.address
address: delegate.address,
});

expect(response).toBeSuccessfulResponse();
Expand All @@ -232,7 +232,7 @@ describe("API 2.0 - Delegates", () => {

it("should POST a search for delegates with a public key that matches the given string", async () => {
const response = await utils[request]("POST", "delegates/search", {
publicKey: delegate.publicKey
publicKey: delegate.publicKey,
});

expect(response).toBeSuccessfulResponse();
Expand All @@ -247,7 +247,7 @@ describe("API 2.0 - Delegates", () => {

it("should POST a search for delegates with a username that matches the given string", async () => {
const response = await utils[request]("POST", "delegates/search", {
username: delegate.username
username: delegate.username,
});

expect(response).toBeSuccessfulResponse();
Expand All @@ -261,10 +261,10 @@ describe("API 2.0 - Delegates", () => {
});

it("should POST a search for delegates with any of the specified usernames", async () => {
const usernames = [delegate.username, delegate2.username]
const usernames = [delegate.username, delegate2.username];

const response = await utils[request]("POST", "delegates/search", {
usernames
usernames,
});

expect(response).toBeSuccessfulResponse();
Expand Down Expand Up @@ -310,7 +310,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.production.approval).toBeGreaterThanOrEqual(1);
expect(elem.production.approval).toBeLessThanOrEqual(100)
expect(elem.production.approval).toBeLessThanOrEqual(100);
}
});

Expand All @@ -328,7 +328,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.fees).toEqual(delegate.forgedFees)
expect(elem.forged.fees).toEqual(delegate.forgedFees);
}
});

Expand All @@ -347,7 +347,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.fees).toBeGreaterThanOrEqual(0);
expect(elem.forged.fees).toBeLessThanOrEqual(delegate.forgedFees)
expect(elem.forged.fees).toBeLessThanOrEqual(delegate.forgedFees);
}
});

Expand All @@ -365,7 +365,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.rewards).toEqual(delegate.forgedRewards)
expect(elem.forged.rewards).toEqual(delegate.forgedRewards);
}
});

Expand All @@ -384,7 +384,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.rewards).toBeGreaterThanOrEqual(0);
expect(elem.forged.rewards).toBeLessThanOrEqual(delegate.forgedRewards)
expect(elem.forged.rewards).toBeLessThanOrEqual(delegate.forgedRewards);
}
});

Expand All @@ -402,7 +402,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.total).toEqual(delegate.forgedTotal)
expect(elem.forged.total).toEqual(delegate.forgedTotal);
}
});

Expand All @@ -421,7 +421,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.forged.total).toBeGreaterThanOrEqual(0);
expect(elem.forged.total).toBeLessThanOrEqual(delegate.forgedTotal)
expect(elem.forged.total).toBeLessThanOrEqual(delegate.forgedTotal);
}
});

Expand All @@ -439,7 +439,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.blocks.produced).toEqual(delegate.producedBlocks)
expect(elem.blocks.produced).toEqual(delegate.producedBlocks);
}
});

Expand All @@ -458,7 +458,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.blocks.produced).toBeGreaterThanOrEqual(0);
expect(elem.blocks.produced).toBeLessThanOrEqual(delegate.producedBlocks)
expect(elem.blocks.produced).toBeLessThanOrEqual(delegate.producedBlocks);
}
});

Expand All @@ -476,7 +476,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.blocks.missed).toEqual(delegate.missedBlocks)
expect(elem.blocks.missed).toEqual(delegate.missedBlocks);
}
});

Expand All @@ -495,7 +495,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.blocks.missed).toBeGreaterThanOrEqual(0);
expect(elem.blocks.missed).toBeLessThanOrEqual(delegate.missedBlocks)
expect(elem.blocks.missed).toBeLessThanOrEqual(delegate.missedBlocks);
}
});

Expand All @@ -513,7 +513,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.production.productivity).toEqual(delegate.productivity)
expect(elem.production.productivity).toEqual(delegate.productivity);
}
});

Expand All @@ -532,7 +532,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.production.productivity).toBeGreaterThanOrEqual(0);
expect(elem.production.productivity).toBeLessThanOrEqual(delegate.productivity)
expect(elem.production.productivity).toBeLessThanOrEqual(delegate.productivity);
}
});

Expand All @@ -550,7 +550,7 @@ describe("API 2.0 - Delegates", () => {

for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.votes).toEqual(delegate.voteBalance)
expect(elem.votes).toEqual(delegate.voteBalance);
}
});

Expand All @@ -569,7 +569,7 @@ describe("API 2.0 - Delegates", () => {
for (const elem of response.data.data) {
utils.expectDelegate(elem);
expect(elem.votes).toBeGreaterThanOrEqual(0);
expect(elem.votes).toBeLessThanOrEqual(delegate.voteBalance)
expect(elem.votes).toBeLessThanOrEqual(delegate.voteBalance);
}
});
},
Expand Down
19 changes: 19 additions & 0 deletions __tests__/integration/core-forger/__fixtures__/block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { models } from "@arkecosystem/crypto";

export const sampleBlock = new models.Block({
id: "4398082439836560423",
version: 0,
timestamp: 35751416,
height: 3342573,
previousBlock: "14909996519459393858",
numberOfTransactions: 0,
totalAmount: 0,
totalFee: 0,
reward: 200000000,
payloadLength: 0,
payloadHash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
generatorPublicKey: "03806036bc1bb470144184b10f815431c580ae2b806d5fd0ba2118dca823c5c4a6",
blockSignature:
// tslint:disable-next-line:max-line-length
"3045022100d0ad616575b1039b89ae22bb8efbce80dd14f52d193ef7a1d0a76fab0253aa4f02206a347bb5d4dc372e5a7ad3f16ae44409d9190fbd8138e9b4e99f83ca3236f91d",
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "./mocks/core-container";

import "jest-extended";

import { NetworkState, NetworkStateStatus } from "@arkecosystem/core-p2p";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import { Client } from "../../../packages/core-forger/src/client";
import { sampleBlock } from "./__fixtures__/block";
import { setUp, tearDown } from "./__support__/setup";

const mockAxios = new MockAdapter(axios);

Expand All @@ -15,12 +16,7 @@ const host = `http://127.0.0.1:4000`;

let client: Client;

beforeAll(async () => {
await setUp();
});

afterAll(async () => {
await tearDown();
mockAxios.restore();
});

Expand Down
24 changes: 24 additions & 0 deletions __tests__/integration/core-forger/mocks/core-container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
jest.mock("@arkecosystem/core-container", () => {
return {
app: {
getConfig: () => {
return {
get: () => ({}),
};
},
getVersion: () => "2.3.0",
resolvePlugin: name => {
if (name === "logger") {
return {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
debug: jest.fn(),
};
}

return {};
},
},
};
});
File renamed without changes.
File renamed without changes.
66 changes: 0 additions & 66 deletions __tests__/unit/core-api/__support__/setup.ts

This file was deleted.

9 changes: 0 additions & 9 deletions __tests__/unit/core-api/__support__/utils/generate-round.ts

This file was deleted.

33 changes: 0 additions & 33 deletions __tests__/unit/core-blockchain/__support__/setup.ts

This file was deleted.

Loading

0 comments on commit fee99c3

Please sign in to comment.