-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ArkEcosystem/core/develop' into db-roun…
…ds-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)
- Loading branch information
Showing
42 changed files
with
548 additions
and
497 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
__tests__/integration/core-api/handlers/blockchain.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import "../../../utils"; | ||
|
||
import { setUp, tearDown } from "../__support__/setup"; | ||
import { utils } from "../utils"; | ||
|
||
beforeAll(async () => await setUp()); | ||
afterAll(async () => await tearDown()); | ||
|
||
describe("API 2.0 - Blockchain", () => { | ||
describe("GET /blockchain", () => { | ||
it("should GET the blockchain info", async () => { | ||
const response = await utils.request("GET", "blockchain"); | ||
expect(response).toBeSuccessfulResponse(); | ||
expect(response.data.data).toBeObject(); | ||
|
||
expect(response.data.data.block.height).toBeNumber(); | ||
expect(response.data.data.block.id).toBeString(); | ||
expect(response.data.data.supply).toBeNumber(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": 0, | ||
"totalAmount": "12500000000000000", | ||
"totalFee": "0", | ||
"reward": "0", | ||
"payloadHash": "d9acd04bde4234a81addb8482333b4ac906bed7be5a9970ce8ada428bd083192", | ||
"timestamp": 0, | ||
"numberOfTransactions": 153, | ||
"payloadLength": 35960, | ||
"previousBlock": null, | ||
"generatorPublicKey": "03b47f6b6719c76bad46a302d9cff7be9b1c2b2a20602a0d880f139b5b8901f068", | ||
"height": 1, | ||
"id": "17184958558311101492", | ||
"blockSignature": "304402202fe5de5697fa25d3d3c0cb24617ac02ddfb1c915ee9194a89f8392f948c6076402200d07c5244642fe36afa53fb2d048735f1adfa623e8fa4760487e5f72e17d253b" | ||
} |
16 changes: 16 additions & 0 deletions
16
__tests__/integration/core-api/services/block-transformed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "17184958558311101492", | ||
"version": 0, | ||
"height": 1, | ||
"previous": null, | ||
"forged": { "reward": 0, "fee": 0, "total": 0, "amount": 12500000000000000 }, | ||
"payload": { "hash": "d9acd04bde4234a81addb8482333b4ac906bed7be5a9970ce8ada428bd083192", "length": 35960 }, | ||
"generator": { | ||
"address": "AP6kAVdX1zQ3S8mfDnnHx9GaAohEqQUins", | ||
"publicKey": "03b47f6b6719c76bad46a302d9cff7be9b1c2b2a20602a0d880f139b5b8901f068" | ||
}, | ||
"signature": "304402202fe5de5697fa25d3d3c0cb24617ac02ddfb1c915ee9194a89f8392f948c6076402200d07c5244642fe36afa53fb2d048735f1adfa623e8fa4760487e5f72e17d253b", | ||
"confirmations": 0, | ||
"transactions": 153, | ||
"timestamp": { "epoch": 0, "unix": 1490101200, "human": "2017-03-21T13:00:00.000Z" } | ||
} |
13 changes: 13 additions & 0 deletions
13
__tests__/integration/core-api/services/transaction-raw.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": 1, | ||
"network": 23, | ||
"type": 0, | ||
"timestamp": 0, | ||
"senderPublicKey": "035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788", | ||
"fee": "0", | ||
"amount": "245098000000000", | ||
"expiration": 0, | ||
"recipientId": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri", | ||
"signature": "304402205fcb0677e06bde7aac3dc776665615f4b93ef8c3ed0fddecef9900e74fcb00f302206958a0c9868ea1b1f3d151bdfa92da1ce24de0b1fcd91933e64fb7971e92f48d", | ||
"id": "db1aa687737858cc9199bfa336f9b1c035915c30aaee60b1e0f8afadfdb946bd" | ||
} |
13 changes: 13 additions & 0 deletions
13
__tests__/integration/core-api/services/transaction-transformed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"id": "db1aa687737858cc9199bfa336f9b1c035915c30aaee60b1e0f8afadfdb946bd", | ||
"version": 1, | ||
"type": 0, | ||
"amount": 245098000000000, | ||
"fee": 0, | ||
"sender": "APnhwwyTbMiykJwYbGhYjNgtHiVJDSEhSn", | ||
"senderPublicKey": "035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788", | ||
"recipient": "AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri", | ||
"signature": "304402205fcb0677e06bde7aac3dc776665615f4b93ef8c3ed0fddecef9900e74fcb00f302206958a0c9868ea1b1f3d151bdfa92da1ce24de0b1fcd91933e64fb7971e92f48d", | ||
"confirmations": 0, | ||
"timestamp": { "epoch": 0, "unix": 1490101200, "human": "2017-03-21T13:00:00.000Z" } | ||
} |
58 changes: 58 additions & 0 deletions
58
__tests__/integration/core-api/services/transformer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { transformerService } from "../../../../packages/core-api/src/services/transformer"; | ||
import { Managers, Transactions } from "../../../../packages/crypto/src"; | ||
import { genesisBlock } from "../../../utils/config/testnet/genesisBlock"; | ||
import { setUp, tearDown } from "../__support__/setup"; | ||
import blockRaw from "./block-raw.json"; | ||
import blockTransformed from "./block-transformed.json"; | ||
import transactionRaw from "./transaction-raw.json"; | ||
import transactionTransformed from "./transaction-transformed.json"; | ||
|
||
Managers.configManager.setFromPreset("testnet"); | ||
|
||
const genesisTransaction = Transactions.TransactionFactory.fromData(genesisBlock.transactions[0]); | ||
delete genesisBlock.transactions; | ||
|
||
beforeAll(async () => setUp()); | ||
afterAll(async () => tearDown()); | ||
|
||
describe("Transformer", () => { | ||
describe("toResource", () => { | ||
it("should transform a block", () => { | ||
expect(transformerService.toResource(genesisBlock, "block")).toEqual(blockTransformed); | ||
}); | ||
|
||
it("should not transform a block", () => { | ||
expect(transformerService.toResource(genesisBlock, "block", false)).toEqual(blockRaw); | ||
}); | ||
|
||
it("should transform a transaction", () => { | ||
expect(transformerService.toResource(genesisTransaction, "transaction")).toEqual(transactionTransformed); | ||
}); | ||
|
||
it("should not transform a transaction", () => { | ||
expect(transformerService.toResource(genesisTransaction, "transaction", false)).toEqual(transactionRaw); | ||
}); | ||
}); | ||
|
||
describe("toCollection", () => { | ||
it("should transform a block", () => { | ||
expect(transformerService.toCollection([genesisBlock], "block")).toEqual([blockTransformed]); | ||
}); | ||
|
||
it("should not transform a block", () => { | ||
expect(transformerService.toCollection([genesisBlock], "block", false)).toEqual([blockRaw]); | ||
}); | ||
|
||
it("should transform a transaction", () => { | ||
expect(transformerService.toCollection([genesisTransaction], "transaction")).toEqual([ | ||
transactionTransformed, | ||
]); | ||
}); | ||
|
||
it("should not transform a transaction", () => { | ||
expect(transformerService.toCollection([genesisTransaction], "transaction", false)).toEqual([ | ||
transactionRaw, | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.