Skip to content

Commit af10936

Browse files
committed
Merge remote-tracking branch 'ArkEcosystem/core/develop' into db-rounds-id
* ArkEcosystem/core/develop: test(core-api): /node/fees endpoint (#2738) test(core-api): /node/configuration/crypto endpoint (#2737) test(core-api): test /transactions/fees and /blockchain endpoints (#2736) refactor(core-wallet-api): respect the whitelist of the public API (#2718) test(core-api): transformer service and 404 assertions (#2735) fix(core): check for user confirmation in snapshot commands (#2734) fix(core-p2p): off-by-one error when fetching blocks from peer (#2733)
2 parents 632425b + fd2d056 commit af10936

File tree

42 files changed

+548
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+548
-497
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "../../../utils";
2+
3+
import { setUp, tearDown } from "../__support__/setup";
4+
import { utils } from "../utils";
5+
6+
beforeAll(async () => await setUp());
7+
afterAll(async () => await tearDown());
8+
9+
describe("API 2.0 - Blockchain", () => {
10+
describe("GET /blockchain", () => {
11+
it("should GET the blockchain info", async () => {
12+
const response = await utils.request("GET", "blockchain");
13+
expect(response).toBeSuccessfulResponse();
14+
expect(response.data.data).toBeObject();
15+
16+
expect(response.data.data.block.height).toBeNumber();
17+
expect(response.data.data.block.id).toBeString();
18+
expect(response.data.data.supply).toBeNumber();
19+
});
20+
});
21+
});

__tests__/integration/core-api/handlers/blocks.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ describe("API 2.0 - Blocks", () => {
117117
"304402202fe5de5697fa25d3d3c0cb24617ac02ddfb1c915ee9194a89f8392f948c6076402200d07c5244642fe36afa53fb2d048735f1adfa623e8fa4760487e5f72e17d253b",
118118
});
119119
});
120+
121+
it("should fail to GET a block by the given identifier if it doesn't exist", async () => {
122+
utils.expectError(await utils.request("GET", "blocks/27184958558311101492"), 404);
123+
});
120124
});
121125

122126
describe("GET /blocks/:height", () => {
@@ -133,6 +137,10 @@ describe("API 2.0 - Blocks", () => {
133137
transactions: genesisBlock.numberOfTransactions,
134138
});
135139
});
140+
141+
it("should fail to GET a block by the given identifier if it doesn't exist", async () => {
142+
utils.expectError(await utils.request("GET", "blocks/111111"), 404);
143+
});
136144
});
137145

138146
describe("GET /blocks/:id/transactions", () => {
@@ -145,10 +153,14 @@ describe("API 2.0 - Blocks", () => {
145153
utils.expectTransaction(transaction);
146154
expect(transaction.blockId).toBe(genesisBlock.id);
147155
});
156+
157+
it("should fail to GET all the transactions for the given block by id if it doesn't exist", async () => {
158+
utils.expectError(await utils.request("GET", "blocks/27184958558311101492/transactions"), 404);
159+
});
148160
});
149161

150162
describe("GET /blocks/:height/transactions", () => {
151-
it("should GET all the transactions for the given block by id", async () => {
163+
it("should GET all the transactions for the given block by height", async () => {
152164
const response = await utils.request("GET", `blocks/${genesisBlock.height}/transactions`);
153165
expect(response).toBeSuccessfulResponse();
154166
expect(response.data.data).toBeArray();
@@ -157,6 +169,10 @@ describe("API 2.0 - Blocks", () => {
157169
utils.expectTransaction(transaction);
158170
expect(transaction.blockId).toBe(genesisBlock.id);
159171
});
172+
173+
it("should fail to GET all the transactions for the given block by height if it doesn't exist", async () => {
174+
utils.expectError(await utils.request("GET", "blocks/111111/transactions"), 404);
175+
});
160176
});
161177

162178
describe("POST /blocks/search", () => {

__tests__/integration/core-api/handlers/delegates.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ describe("API 2.0 - Delegates", () => {
139139
utils.expectDelegate(response.data.data);
140140
expect(response.data.data.publicKey).toEqual(delegate.publicKey);
141141
});
142+
143+
it("should fail to GET a delegate by the given identifier if it doesn't exist", async () => {
144+
utils.expectError(await utils.request("GET", "delegates/fake_username"), 404);
145+
});
142146
});
143147

144148
describe("POST /delegates/search", () => {
@@ -444,6 +448,10 @@ describe("API 2.0 - Delegates", () => {
444448

445449
await databaseService.deleteBlocks([block2.data]); // reset to genesis block
446450
});
451+
452+
it("should fail to GET a delegate by the given identifier if it doesn't exist", async () => {
453+
utils.expectError(await utils.request("GET", "delegates/fake_username/blocks"), 404);
454+
});
447455
});
448456

449457
describe("GET /delegates/:id/voters", () => {
@@ -470,5 +478,9 @@ describe("API 2.0 - Delegates", () => {
470478

471479
expect(response.data.data.sort((a, b) => a.balance < b.balance)).toEqual(response.data.data);
472480
});
481+
482+
it("should fail to GET a delegate by the given identifier if it doesn't exist", async () => {
483+
utils.expectError(await utils.request("GET", "delegates/fake_username/voters"), 404);
484+
});
473485
});
474486
});

__tests__/integration/core-api/handlers/node.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "../../../utils";
22

33
import { app } from "@arkecosystem/core-container";
4+
import { Managers } from "@arkecosystem/crypto";
45
import { setUp, tearDown } from "../__support__/setup";
56
import { utils } from "../utils";
67

@@ -58,4 +59,22 @@ describe("API 2.0 - Loader", () => {
5859
app.resolveOptions("transaction-pool").dynamicFees.enabled = true;
5960
});
6061
});
62+
63+
describe("GET /node/configuration/crypto", () => {
64+
it("should GET the node crypto configuration", async () => {
65+
const response = await utils.request("GET", "node/configuration/crypto");
66+
expect(response).toBeSuccessfulResponse();
67+
expect(response.data.data).toBeObject();
68+
expect(response.data.data).toEqual(Managers.configManager.getPreset("testnet"));
69+
});
70+
});
71+
72+
describe("GET /node/fees", () => {
73+
it("should GET the node fees", async () => {
74+
const response = await utils.request("GET", "node/fees", { days: 14 });
75+
expect(response).toBeSuccessfulResponse();
76+
expect(response.data.meta.days).toBe(14);
77+
expect(response.data.data).toBeArray();
78+
});
79+
});
6180
});

__tests__/integration/core-api/handlers/peers.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,9 @@ describe("API 2.0 - Peers", () => {
7575
expect(response.data.data.ip).toBe(peers[0].ip);
7676
expect(response.data.data.port).toBe(peers[0].port);
7777
});
78+
79+
it("should fail to GET a peer by the given ip if it doesn't exist", async () => {
80+
utils.expectError(await utils.request("GET", "peers/127.0.0.1"), 404);
81+
});
7882
});
7983
});

__tests__/integration/core-api/handlers/transactions.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ describe("API 2.0 - Transactions", () => {
107107
id: "8816f8d8c257ea0c951deba911266394b0f2614df023f8b4ffd9da43d36efd9d",
108108
});
109109
});
110+
111+
it("should fail to GET a transaction by the given identifier if it doesn't exist", async () => {
112+
utils.expectError(
113+
await utils.request(
114+
"GET",
115+
"transactions/9816f8d8c257ea0c951deba911266394b0f2614df023f8b4ffd9da43d36efd9d",
116+
),
117+
404,
118+
);
119+
});
110120
});
111121

112122
describe("GET /transactions/unconfirmed", () => {
@@ -129,6 +139,16 @@ describe("API 2.0 - Transactions", () => {
129139
expect(response.data.data).toBeObject();
130140
expect(response.data.data).toHaveProperty("id", transaction.id);
131141
});
142+
143+
it("should fail to GET a transaction by the given identifier if it doesn't exist", async () => {
144+
utils.expectError(
145+
await utils.request(
146+
"GET",
147+
"transactions/unconfirmed/9816f8d8c257ea0c951deba911266394b0f2614df023f8b4ffd9da43d36efd9d",
148+
),
149+
404,
150+
);
151+
});
132152
});
133153

134154
describe("GET /transactions/types", () => {
@@ -572,4 +592,23 @@ describe("API 2.0 - Transactions", () => {
572592
},
573593
);
574594
});
595+
596+
describe("GET /transactions/fees", () => {
597+
it("should GET all the transaction fees", async () => {
598+
const response = await utils.request("GET", "transactions/fees");
599+
600+
expect(response).toBeSuccessfulResponse();
601+
expect(response.data.data).toEqual({
602+
delegateRegistration: 2500000000,
603+
delegateResignation: 2500000000,
604+
ipfs: 500000000,
605+
multiPayment: 0,
606+
multiSignature: 500000000,
607+
secondSignature: 500000000,
608+
timelockTransfer: 0,
609+
transfer: 10000000,
610+
vote: 100000000,
611+
});
612+
});
613+
});
575614
});

__tests__/integration/core-api/handlers/votes.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ describe("API 2.0 - Votes", () => {
2929
expect(response.data.data).toBeObject();
3030
expect(response.data.data.id).toBe(voteId);
3131
});
32+
33+
it("should fail to GET a vote by the given identifier if it doesn't exist", async () => {
34+
utils.expectError(
35+
await utils.request("GET", "votes/9816f8d8c257ea0c951deba911266394b0f2614df023f8b4ffd9da43d36efd9d"),
36+
404,
37+
);
38+
});
3239
});
3340
});

__tests__/integration/core-api/handlers/wallets.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ describe("API 2.0 - Wallets", () => {
8181

8282
utils.expectTransaction(response.data.data[0]);
8383
});
84+
85+
it("should fail to GET all the transactions for the given wallet if it doesn't exist", async () => {
86+
utils.expectError(await utils.request("GET", "wallets/fake-address/transactions"), 404);
87+
});
8488
});
8589

8690
describe("GET /wallets/:id/transactions/sent", () => {
87-
it("should GET all the send transactions for the given wallet by id", async () => {
91+
it("should GET all the sent transactions for the given wallet by id", async () => {
8892
const response = await utils.request("GET", `wallets/${address}/transactions/sent`);
8993
expect(response).toBeSuccessfulResponse();
9094
expect(response.data.data).toBeArray();
@@ -93,6 +97,10 @@ describe("API 2.0 - Wallets", () => {
9397
utils.expectTransaction(transaction);
9498
expect(transaction.sender).toBe(address);
9599
});
100+
101+
it("should fail to GET all the sent transactions for the given wallet if it doesn't exist", async () => {
102+
utils.expectError(await utils.request("GET", "wallets/fake-address/transactions/sent"), 404);
103+
});
96104
});
97105

98106
describe("GET /wallets/:id/transactions/received", () => {
@@ -103,6 +111,10 @@ describe("API 2.0 - Wallets", () => {
103111

104112
utils.expectTransaction(response.data.data[0]);
105113
});
114+
115+
it("should fail to GET all the received transactions for the given wallet if it doesn't exist", async () => {
116+
utils.expectError(await utils.request("GET", "wallets/fake-address/transactions/received"), 404);
117+
});
106118
});
107119

108120
describe("GET /wallets/:id/votes", () => {
@@ -113,6 +125,10 @@ describe("API 2.0 - Wallets", () => {
113125

114126
expect(response.data.data[0]).toBeObject();
115127
});
128+
129+
it("should fail to GET all the votes for the given wallet if it doesn't exist", async () => {
130+
utils.expectError(await utils.request("GET", "wallets/fake-address/votes"), 404);
131+
});
116132
});
117133

118134
describe("POST /wallets/search", () => {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": 0,
3+
"totalAmount": "12500000000000000",
4+
"totalFee": "0",
5+
"reward": "0",
6+
"payloadHash": "d9acd04bde4234a81addb8482333b4ac906bed7be5a9970ce8ada428bd083192",
7+
"timestamp": 0,
8+
"numberOfTransactions": 153,
9+
"payloadLength": 35960,
10+
"previousBlock": null,
11+
"generatorPublicKey": "03b47f6b6719c76bad46a302d9cff7be9b1c2b2a20602a0d880f139b5b8901f068",
12+
"height": 1,
13+
"id": "17184958558311101492",
14+
"blockSignature": "304402202fe5de5697fa25d3d3c0cb24617ac02ddfb1c915ee9194a89f8392f948c6076402200d07c5244642fe36afa53fb2d048735f1adfa623e8fa4760487e5f72e17d253b"
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "17184958558311101492",
3+
"version": 0,
4+
"height": 1,
5+
"previous": null,
6+
"forged": { "reward": 0, "fee": 0, "total": 0, "amount": 12500000000000000 },
7+
"payload": { "hash": "d9acd04bde4234a81addb8482333b4ac906bed7be5a9970ce8ada428bd083192", "length": 35960 },
8+
"generator": {
9+
"address": "AP6kAVdX1zQ3S8mfDnnHx9GaAohEqQUins",
10+
"publicKey": "03b47f6b6719c76bad46a302d9cff7be9b1c2b2a20602a0d880f139b5b8901f068"
11+
},
12+
"signature": "304402202fe5de5697fa25d3d3c0cb24617ac02ddfb1c915ee9194a89f8392f948c6076402200d07c5244642fe36afa53fb2d048735f1adfa623e8fa4760487e5f72e17d253b",
13+
"confirmations": 0,
14+
"transactions": 153,
15+
"timestamp": { "epoch": 0, "unix": 1490101200, "human": "2017-03-21T13:00:00.000Z" }
16+
}

0 commit comments

Comments
 (0)