diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d67dc76..ad09c2c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,8 @@ "esbenp.prettier-vscode", "mhutchie.git-graph", "Tyriar.sort-lines", - "eamodio.gitlens" + "eamodio.gitlens", + "vespa-dev-works.jestRunIt" ], "postCreateCommand": "yarn install && yarn upgrade --latest" } diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..620672a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.renderWhitespace": "trailing" +} diff --git a/junit.xml b/junit.xml new file mode 100644 index 0000000..d3e00ba --- /dev/null +++ b/junit.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + Error: expect(received).toEqual(expected) // deep equality + +Expected: true +Received: false + at /workspaces/lunesjs/test/blockchain/blocks/blockOne.test.ts:99:34 + at Generator.next (<anonymous>) + at fulfilled (/workspaces/lunesjs/test/blockchain/blocks/blockOne.test.ts:5:58) + at processTicksAndRejections (node:internal/process/task_queues:96:5) + + + + + \ No newline at end of file diff --git a/package.json b/package.json index bf69cdf..55a42ce 100644 --- a/package.json +++ b/package.json @@ -19,22 +19,22 @@ "author": "lunes-platform", "license": "Apache-2.0", "scripts": { - "deploy": "yarn build && yarn publish", "fmt": "prettier -w .", "fmtc": "prettier -c", + "test": "yarn jest", "t": "yarn jest", "build": "tsc" }, "devDependencies": { - "@types/jest": "^27.0.3", - "jest": "^27.4.5", - "jest-junit": "^13.0.0", + "@types/jest": "^27.5.1", + "jest": "^28.1.0", + "jest-junit": "^13.2.0", "prettier": "2.6.2", - "ts-jest": "^27.1.2", - "typescript": "^4.5.4" + "ts-jest": "^28.0.2", + "typescript": "^4.6.4" }, "dependencies": { - "axios": "^0.26.1", + "axios": "^0.27.2", "lunesrs": "^1.9.4" } } diff --git a/src/blockchain/blocks/block.types.ts b/src/blockchain/blocks/block.types.ts new file mode 100644 index 0000000..c95718e --- /dev/null +++ b/src/blockchain/blocks/block.types.ts @@ -0,0 +1,93 @@ +import { AxiosResponse } from "axios" + +interface INxtConsensus { + generationSignature: string + baseTarget: number +} +interface ITransaction { + senderPublicKey: string + timestamp: number + signature: string + recipient: string + feeAsset: string + assetId: string + amount: number + sender: string + type: number + fee: number + id: string +} + +interface IHeader { + nxtConsensus: INxtConsensus + transactionCount: number + features: Array + timestamp: number + reference: string + generator: string + signature: string + blocksize: number + version: number + height: number + fee: number + //delay: number //testando colocar delay não foi +} + +export interface IBlock { + isSuccess: boolean + header: IHeader + body: Array +} + +export interface IBlockError { + isSuccess: boolean + response: { + codeError: number + message: string + } +} + +export function mountBlock( + blockchainResponse: AxiosResponse +): IBlock { + let block: IBlock = { + isSuccess: true, + header: { + nxtConsensus: { + baseTarget: + blockchainResponse.data["nxt-consensus"]["base-target"], + generationSignature: + blockchainResponse.data["nxt-consensus"][ + "generation-signature" + ] + }, + transactionCount: blockchainResponse.data.transactionCount, + features: + blockchainResponse.data.features != undefined + ? blockchainResponse.data.features + : [], + timestamp: blockchainResponse.data.timestamp, + reference: blockchainResponse.data.reference, + generator: blockchainResponse.data.generator, + signature: blockchainResponse.data.signature, + blocksize: blockchainResponse.data.blocksize, + version: blockchainResponse.data.version, + height: blockchainResponse.data.height, + fee: blockchainResponse.data.fee, + //delay: blockchainResponse.data.delay //testando colocar delay não foi + }, + body: blockchainResponse.data.transactions + } + + return block +} + +export function mountErr(blockchainError: string): IBlockError { + return { + isSuccess: false, + response: { + codeError: 1, + message: blockchainError + } + } +} diff --git a/src/blockchain/blocks/service.blocks.ts b/src/blockchain/blocks/service.blocks.ts new file mode 100644 index 0000000..81cd83f --- /dev/null +++ b/src/blockchain/blocks/service.blocks.ts @@ -0,0 +1,482 @@ +/** + * Copyright (c) Lunes Platform * + * Welcome to service.blocs.ts + * @author Lunes Platform + * + * This source code is licensed under the Apache license found in the + * LICENSE file in the root directory of this source tree. + */ + +import { mountBlock, IBlock, IBlockError, mountErr } from "./block.types" +import { lunesNode } from "../service.blockchain" + +/** + * # This function get blockchain `height` e return a full block + * {@link byHeight} + * + * ## Example + * + * ```javascript + * import * as lunesjs from "lunesjs" + * + * const block = lunesjs.blockchain.blocks.byHeight(10) + * ``` + * @param {number} height - number of block in blockchain + * should be greater than 0 and less than 2147483647 + * @returns Promise + */ +async function byHeight(height: number): Promise { + const i32Max = 2147483647 + + if (height <= 0 || height >= i32Max) { + const error: IBlockError = { + isSuccess: false, + response: { + codeError: -1, + message: `the block cannot be less than or equal to zero or greater than or equal 2147483647` + } + } + return error + } else { + lunesNode.interceptors.response.use( + (blockchainResponse) => { + return Promise.resolve(mountBlock(blockchainResponse)) + }, + (blockchainError) => { + console.log(blockchainError) + return Promise.resolve(mountErr(blockchainError)) + } + ) + return lunesNode.get(`/blocks/at/${height}`) + } +} + + +// /** +// * # This function get a blockchain actual height +// * {@link actualHeight} +// * +// * ## Example +// * +// * ```javascript +// * import * as lunesjs from "lunesjs" +// * +// * const block = lunesjs.blockchain.blocks.actualHeight() +// * ``` +// * +// * If server off line, return error +// * @returns Promise . +// */ +// export async function actualHeight(): Promise { + +// lunesNode.interceptors.response.use( +// (r) => { +// return Promise.resolve(r.data.height) +// }, +// (blockchainError) => { +// console.log(blockchainError) +// return Promise.resolve(mountErr(blockchainError)) +// }) +// return lunesNode.get(`/blocks/height`) +// } +// /* return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((r) => { +// resolve(r.data.height) +// }) +// .catch(() => { +// resolve(-1) +// }) +// }) +// */ + + +/** + * # Average delay in milliseconds between last blockNum blocks starting from block with signature + * {@link blockAverageDelay} + * + * ## Example + * + * ```javascript + * import * as lunesjs from "lunesjs" + * + * const block = lunesjs.blockchain.blocks.blockaverageDelay("dsfs112", 1) + * ``` + * @type {signature: string, blockNum: number } + * + * --- signature = signature block - Base58-encoded signature + * + * --- blockNum = 1 to 9 - Number of blocks to count delay + * @returns Promise + */ +export async function blockAverageDelay( + signature: string, + blockNum: number +): Promise { + + if (blockNum <= 0 || blockNum > 9) { + const error: IBlockError = { + isSuccess: false, + response: { + codeError: -1, + message: `the blockNum cannot be less than or equal to zero or greater than nine` + } + } + return error + } else { + lunesNode.interceptors.response.use( + (r) => { + //return r.data.delay + return Promise.resolve(r.data.delay) + //promise não funciona em undefined + }, + (blockchainError) => { + console.log(blockchainError) + return Promise.resolve(mountErr(blockchainError)) + } + ) + return lunesNode.get(`/blocks/delay/${signature}/${blockNum}`) + } +} + + + + + + + +// /** +// * # This function Get block at specified heights +// * {@link blockSeq} +// * +// * ## Example +// * +// * ```javascript +// * import * as lunesjs from "lunesjs" +// * +// * const block = lunesjs.blockchain.blocks.blockaverageDelay("dsfs112", 1) +// * ``` +// * @type {from: number, to: number} +// * +// * validation: max value (from) (to) 1 - 100 (99 difference) +// * +// * from value < to value +// * @returns Promise +// */ +// export async function blockSeq( +// from: number, +// to: number +// ): Promise { +// //const url = `${BASEURL}seq/${from}/${to}` +// //`https://lunesnode.lunes.io/blocks/seq/${from}/${to}` +// const Max: boolean = to - from < 100 + +// if (from > to || Max === false) { +// const error: IBlockError = { +// isSuccess: false, +// response: { +// codeError: -1, +// message: `Too big sequences requested OR {from} cannot be bigger than {to}, change it` +// } +// } +// return error +// } else { + +// lunesNode.interceptors.response.use( +// (blockchainResponse) => { +// return Promise.resolve(mountBlock(blockchainResponse)) +// }, +// (blockchainError) => { +// console.log(blockchainError) +// return Promise.resolve(mountErr(blockchainError)) +// } +// ) +// return lunesNode.get(`/blocks/seq/${from}/${to}`) + +// } +// } + + + + + + + +// /** +// * # This function Get last block data +// * +// * If server off line, return error +// * +// * @returns Promise {@link blockLast} , no params. +// */ +// export async function blockLast(): Promise { +// const url = `${BASEURL}last` + +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # This function Get children of specified block +// * +// * @type {signature: string} +// * validation: string +// * +// * @returns Promise {@link blockChild} containing the parameter signature. +// */ +// export async function blockChild( +// signature: string +// ): Promise { +// const url = `${BASEURL}child/${signature}` + +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # This function Get height of a block by its Base58-encoded signature +// * +// * @type {signature: string} +// * validation: string +// * +// * @returns Promise {@link blockHeightEncoded} containing the parameter signature. +// */ +// export async function blockHeightEncoded( +// signature: string +// ): Promise { +// const url = `${BASEURL}height/${signature}` +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((response) => { +// resolve(response.data) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # This function Get block at specified height without transactions payload +// * +// * @type {height: number} +// * validation: number +// * +// * @returns Promise {@link blockAtHeaderOnly} containing the parameter height. +// */ +// export async function blockAtHeaderOnly( +// height: number +// ): Promise { +// const url = `${BASEURL}headers/at/${height}` + +// if (typeof height === "string") { +// const error: IBlockError = { +// isSuccess: false, +// response: { +// codeError: -1, +// message: `block cannot receive string type ` +// } +// } +// return error +// } else { +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } +// } + +// /** +// * # This function Get block without transactions payload at specified heights +// * +// * @type {from: number, to: number} +// * validation: +// * +// * max value (from) (to) 1 - 100 (99 difference) +// * +// * from value < to value +// * +// * @returns Promise {@link blockSeqHeaderOnly} containing the params from and to. +// */ +// export async function blockSeqHeaderOnly( +// from: number, +// to: number +// ): Promise { +// const url = `${BASEURL}headers/seq/${from}/${to}` + +// const Max: boolean = to - from < 100 + +// if (from > to || Max === false) { +// const error: IBlockError = { +// isSuccess: false, +// response: { +// codeError: -1, +// message: `Too big sequences requested OR {from} cannot be bigger than {to}, change it` +// } +// } +// return error +// } else { +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((r) => { +// resolve(r.data) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// // const response = await axios.get(url) +// // return response.data +// } +// } + +// /** +// * # Get last block data without transactions payload +// * +// * If server off line, return error +// * +// * @returns Promise {@link blockLastHeaderOnly} . +// */ +// export async function blockLastHeaderOnly(): Promise { +// const url = `${BASEURL}headers/last` + +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # Get block by a specified Base58-encoded signature +// * +// * If server off line, return error +// * +// * @returns Promise {@link blockSignature} . +// */ +// export async function blockSignature( +// signature: string +// ): Promise { +// const url = `${BASEURL}signature/${signature}` + +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # Get genesis block data +// * +// * If server off line, return error +// * +// * @returns Promise {@link bblockFirst} . +// */ +// export async function blockFirst(): Promise { +// const url = `${BASEURL}first` + +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((blockchainResponse) => { +// resolve(mountBlock(blockchainResponse)) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } + +// /** +// * # This function Get list of blocks generated by specified address +// * +// * @type {address: string, from: number, to: number} +// * +// * @returns Promise {@link blockAddress} containing the params address, from and to. +// */ +// export async function blockAddress( +// address: string, +// from: number, +// to: number +// ): Promise { +// const url = `${BASEURL}address/${address}/${from}/${to}` + +// const Max: boolean = to - from < 100 + +// if (from > to || Max === false) { +// const error: IBlockError = { +// isSuccess: false, +// response: { +// codeError: -1, +// message: `Too big sequences requested OR {from} cannot be bigger than {to}, change it` +// } +// } +// return error +// } else { +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((response) => { +// resolve(response.data) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } +// } + +//export const blocks = { +// byHeight, actualHeight +// return new Promise(async (resolve) => { +// axios +// .get(url) +// .then((response) => { +// resolve(response.data) +// }) +// .catch((blockchainError) => { +// resolve(mountErr(blockchainError)) +// }) +// }) +// } +// } + +export const blocks = { + byHeight, blockAverageDelay +} diff --git a/src/blockchain/service.blockchain.ts b/src/blockchain/service.blockchain.ts new file mode 100644 index 0000000..1195dc1 --- /dev/null +++ b/src/blockchain/service.blockchain.ts @@ -0,0 +1,11 @@ +import { blocks } from "./blocks/service.blocks" +import axios from "axios" + +export const lunesNode = axios.create({ + baseURL: "https://lunesnode.lunes.io", + timeout: 2000 +}) + +export const blockchain = { + blocks +} diff --git a/src/index.ts b/src/index.ts index 99d12ed..276495f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,11 @@ import { transferTokenFactory } from "./tx/transfer/transfer.service" +import { blockchain } from "./blockchain/service.blockchain" import { walletFactory } from "./wallet/wallet.service" import { crypto } from "./utils/crypto" export default { transferTokenFactory, walletFactory, + blockchain, crypto } diff --git a/test/blockchain/blocks/blockOne.test.ts b/test/blockchain/blocks/blockOne.test.ts new file mode 100644 index 0000000..4b9946f --- /dev/null +++ b/test/blockchain/blocks/blockOne.test.ts @@ -0,0 +1,409 @@ +import lunesjs from "../../../src/index" + + +describe("blockByHeight function- suite test block service", () => { + + it("blockByHeight - block testing error, passing -1 number", async () => { + const result = await lunesjs.blockchain.blocks.byHeight(-1) + + expect(result.isSuccess).toEqual(false) + }) + + it("blockbyHeight - block testing error, passing i32Max ", async () => { + const result = await lunesjs.blockchain.blocks.byHeight(2147483648) + + expect(result.isSuccess).toEqual(false) + }) + + it("blockByHeight- receive number 10 param to get fetch", async () => { + const result = await lunesjs.blockchain.blocks.byHeight(1) + expect(result).toEqual({ + isSuccess: true, + header: { + blocksize: 312, + features: [], + fee: 0, + generator: "37jG983kttnpw4kAAQ6wi1yTyegkLN5LMNb", + height: 1, + nxtConsensus: { + baseTarget: 153722867, + generationSignature: "11111111111111111111111111111111" + }, + reference: + "67rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ", + signature: + "soKTPcsb5cD97jnm64zF3pVuVUqUYx3caaDvuPyM6PXPY7eWCxeHeYvKSE2aJwZwRpXdRFdW1g5BQMFpYkHcf85", + timestamp: 1528077600000, + transactionCount: 2, + version: 1 + }, + body: [ + { + amount: 5072853761500800, + fee: 0, + id: "Er65mP3Mgs5PDZNmj2hmtVeBvF3gFp6SqVbqNrE8dq99bFve4EbCwh4efaQb5U5HT77e6Xhzi6DpL2G16sga8Jn", + recipient: "37oqFHsx1cRtLWtnp6YyQpud5WJk4v79VPu", + signature: + "Er65mP3Mgs5PDZNmj2hmtVeBvF3gFp6SqVbqNrE8dq99bFve4EbCwh4efaQb5U5HT77e6Xhzi6DpL2G16sga8Jn", + timestamp: 1528077600000, + type: 1 + }, + { + amount: 10000000000000000, + fee: 0, + id: "D3rtv9DWiRGmKpiTeknbug4gUuxBY6LMTVquR21ijUgcbTGdPyp4iHFAL4byCwSjnLpsE3nqkJSqkubQ4RmLTGW", + recipient: "3826zwbgHauHXAoppU4we3hsJc9GtRCpSvz", + signature: + "D3rtv9DWiRGmKpiTeknbug4gUuxBY6LMTVquR21ijUgcbTGdPyp4iHFAL4byCwSjnLpsE3nqkJSqkubQ4RmLTGW", + timestamp: 1528077600000, + type: 1 + } + ] + }) + }) +}) + + + + +// describe("actualHeight function - suite test block service", () => { +// it("actualHeight - see height block from node ", async () => { +// const result = await lunesjs.blockchain.blocks.actualHeight() +// //expect(result).toBeGreaterThan(0) +// // somente o teste individual, funciona, quando roda o yarn t blockOne.test.ts quebra os demais testes + +// //expect(result).toEqual(expect.any(Number)); +// // somente o teste individual, funciona, quando roda o yarn t blockOne.test.ts quebra os demais testes + + + +// expect(result).toContain(result) +// //verificar o valor recebido e o valor esperado, somente para entender os testes acima + + +// }) +// }) + + + + +describe("blockAverageDelay function - suite test block service", () => { + + it("blockAverageDelay - see Average delay ", async () => { + + const result = await lunesjs.blockchain.blocks.blockAverageDelay( + "3TzngGgQ2xsC1huRantEWNZzG3FoCPA5rCRdqenCy1jGxyRb16nb6p4Xy9ZM4FnypTdWXE31QsZ5EkTTnzTDrjKi", + 1 + ) + //expect(result).toStrictEqual(1011) + expect(result.isSuccess).toEqual(true) + + }) + + it("blockAverageDelay - blockNum >9 error ", async () => { + + const result = await lunesjs.blockchain.blocks.blockAverageDelay( + "3TzngGgQ2xsC1huRantEWNZzG3FoCPA5rCRdqenCy1jGxyRb16nb6p4Xy9ZM4FnypTdWXE31QsZ5EkTTnzTDrjKi", + 10 + ) + expect(result.isSuccess).toEqual(false) + }) +}) + +// describe("blockSeq function - suite test block service", () => { +// it("blockSeq - Get block at specified heights ", async () => { +// const result = await blocks.blockSeq(1, 2) +// expect(result).toStrictEqual([ +// { +// blocksize: 312, +// fee: 0, +// generator: "37jG983kttnpw4kAAQ6wi1yTyegkLN5LMNb", +// height: 1, +// "nxt-consensus": { +// "base-target": 153722867, +// "generation-signature": "11111111111111111111111111111111" +// }, +// reference: +// "67rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ", +// signature: +// "soKTPcsb5cD97jnm64zF3pVuVUqUYx3caaDvuPyM6PXPY7eWCxeHeYvKSE2aJwZwRpXdRFdW1g5BQMFpYkHcf85", +// timestamp: 1528077600000, +// transactionCount: 2, +// transactions: [ +// { +// amount: 5072853761500800, +// fee: 0, +// id: "Er65mP3Mgs5PDZNmj2hmtVeBvF3gFp6SqVbqNrE8dq99bFve4EbCwh4efaQb5U5HT77e6Xhzi6DpL2G16sga8Jn", +// recipient: "37oqFHsx1cRtLWtnp6YyQpud5WJk4v79VPu", +// signature: +// "Er65mP3Mgs5PDZNmj2hmtVeBvF3gFp6SqVbqNrE8dq99bFve4EbCwh4efaQb5U5HT77e6Xhzi6DpL2G16sga8Jn", +// timestamp: 1528077600000, +// type: 1 +// }, +// { +// amount: 10000000000000000, +// fee: 0, +// id: "D3rtv9DWiRGmKpiTeknbug4gUuxBY6LMTVquR21ijUgcbTGdPyp4iHFAL4byCwSjnLpsE3nqkJSqkubQ4RmLTGW", +// recipient: "3826zwbgHauHXAoppU4we3hsJc9GtRCpSvz", +// signature: +// "D3rtv9DWiRGmKpiTeknbug4gUuxBY6LMTVquR21ijUgcbTGdPyp4iHFAL4byCwSjnLpsE3nqkJSqkubQ4RmLTGW", +// timestamp: 1528077600000, +// type: 1 +// } +// ], +// version: 1 +// }, +// { +// blocksize: 227, +// features: [2], +// fee: 0, +// generator: "37oqFHsx1cRtLWtnp6YyQpud5WJk4v79VPu", +// height: 2, +// "nxt-consensus": { +// "base-target": 153722867, +// "generation-signature": +// "E28JsgAfipFaBZLvYBJZUJh2aAdZcMTKuS9KZ4jRzZ6q" +// }, +// reference: +// "soKTPcsb5cD97jnm64zF3pVuVUqUYx3caaDvuPyM6PXPY7eWCxeHeYvKSE2aJwZwRpXdRFdW1g5BQMFpYkHcf85", +// signature: +// "4qZHFNXz5CM4vTapEHoecqYthEacHje3pvesy2rGzj5yLrd52gN6iVwWuX3mBJTWvqJeHYHnNuWqWmQpFayZAxYX", +// timestamp: 1528116151053, +// transactionCount: 0, +// transactions: [], +// version: 3 +// } +// ]) +// }) + +// it("blockSeq - from > to error ", async () => { +// const result = await blocks.blockSeq(2, 1) +// expect(result.isSuccess).toEqual(false) +// }) + +// it("blockSeq - big sequences ", async () => { +// const result = await blocks.blockSeq(1, 101) +// expect(result.isSuccess).toEqual(false) +// }) + +// it("blockSeq - max === false ", async () => { +// const result = await blocks.blockSeq(1, 200) +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe("blockLast function - suite test block service", () => { +// it("blockLast - Get last block data ", async () => { +// const result = await blocks.blockLast() + +// //ok +// expect(result.isSuccess).toEqual(true) + +// //see received +// //expect(result).toStrictEqual("") +// }) +// }) + +// describe("blockChild function - suite test block service", () => { +// it("blockChild - Get children of specified block ", async () => { +// const result = await blocks.blockChild( +// "3Ho1ZKnxzKAvrwo5RsMAesdiw6EW3f5Mn8etEhPP2t5z6N3iVK385ezvbNkxUen6yRUhwuiXg97P9uGMVeUpHG4f" +// ) +// //ok +// expect(result.isSuccess).toEqual(true) +// }) + +// it("blockChild - error 404 ", async () => { +// // const action = async () => { +// // await blocks.blockChild("124afdsfaf") +// // } + +// // expect(action()).rejects.toThrow() + +// const result = await blocks.blockChild("124afdsfaf") +// //ok +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe("blockHeightEncoded function - suite test block service", () => { +// it("blockHeightEncoded - Get height of a block by its Base58-encoded signature ", async () => { +// const result = await blocks.blockHeightEncoded( +// "3Ho1ZKnxzKAvrwo5RsMAesdiw6EW3f5Mn8etEhPP2t5z6N3iVK385ezvbNkxUen6yRUhwuiXg97P9uGMVeUpHG4f" +// ) +// expect(result).toStrictEqual({ +// height: 1887361 +// }) +// }) + +// it("blockHeightEncoded - error 404 ", async () => { +// // const result = async () => { +// // await blocks.blockHeightEncoded("124afdsfaf") +// // } + +// // expect(result()).rejects.toThrow() + +// const result = await blocks.blockHeightEncoded("124afdsfaf") +// //ok +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe("blockAtHeaderOnly function - suite test block service", () => { +// it("blockAtHeaderOnly - Get block at specified height without transactions payload ", async () => { +// const result = await blocks.blockAtHeaderOnly(1) +// expect(result.isSuccess).toEqual(true) +// }) + +// it("blockAtHeaderOnly - error 404 ", async () => { +// // const result = async () => { +// // await blocks.blockAtHeaderOnly(11111111111) +// // } + +// // expect(result()).rejects.toThrow() + +// const result = await blocks.blockAtHeaderOnly(11111111111) +// //ok +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe("blockSeqHeaderOnly function - suite test block service", () => { +// it(" blockSeqHeaderOnly test ", async () => { +// const result = await blocks.blockSeqHeaderOnly(1, 2) +// expect(result).toStrictEqual([ +// { +// blocksize: 312, +// generator: "37jG983kttnpw4kAAQ6wi1yTyegkLN5LMNb", +// height: 1, +// "nxt-consensus": { +// "base-target": 153722867, +// "generation-signature": "11111111111111111111111111111111" +// }, +// reference: +// "67rpwLCuS5DGA8KGZXKsVQ7dnPb9goRLoKfgGbLfQg9WoLUgNY77E2jT11fem3coV9nAkguBACzrU1iyZM4B8roQ", +// signature: +// "soKTPcsb5cD97jnm64zF3pVuVUqUYx3caaDvuPyM6PXPY7eWCxeHeYvKSE2aJwZwRpXdRFdW1g5BQMFpYkHcf85", +// timestamp: 1528077600000, +// transactionCount: 2, +// version: 1 +// }, +// { +// blocksize: 227, +// features: [2], +// generator: "37oqFHsx1cRtLWtnp6YyQpud5WJk4v79VPu", +// height: 2, +// "nxt-consensus": { +// "base-target": 153722867, +// "generation-signature": +// "E28JsgAfipFaBZLvYBJZUJh2aAdZcMTKuS9KZ4jRzZ6q" +// }, +// reference: +// "soKTPcsb5cD97jnm64zF3pVuVUqUYx3caaDvuPyM6PXPY7eWCxeHeYvKSE2aJwZwRpXdRFdW1g5BQMFpYkHcf85", +// signature: +// "4qZHFNXz5CM4vTapEHoecqYthEacHje3pvesy2rGzj5yLrd52gN6iVwWuX3mBJTWvqJeHYHnNuWqWmQpFayZAxYX", +// timestamp: 1528116151053, +// transactionCount: 0, +// version: 3 +// } +// ]) +// }) + +// it(" blockSeqHeaderOnly - error from > to ", async () => { +// const result = await blocks.blockSeqHeaderOnly(2, 1) +// //ok +// expect(result.isSuccess).toEqual(false) +// }) + +// it(" blockSeqHeaderOnly - Max === false ", async () => { +// const result = await blocks.blockSeqHeaderOnly(1, 199) +// //ok +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe(" blockLastHeaderOnly function - suite test block service", () => { +// it(" blockLastHeaderOnly test ", async () => { +// const result = await blocks.blockLastHeaderOnly() + +// //expect(result).toHaveProperty("height") // true +// expect(result.isSuccess).toEqual(true) +// }) +// }) + +// describe(" blockSignature - suite test block service", () => { +// it("blockSignature test", async () => { +// const result = await blocks.blockSignature( +// "3TzngGgQ2xsC1huRantEWNZzG3FoCPA5rCRdqenCy1jGxyRb16nb6p4Xy9ZM4FnypTdWXE31QsZ5EkTTnzTDrjKi" +// ) +// expect(result.isSuccess).toEqual(true) +// }) + +// it("blockSignature - error 404 ", async () => { +// // const result = async () => { +// // await blocks.blockSignature("124afdsfaf") +// // } + +// // expect(result()).rejects.toThrow() + +// const result = await blocks.blockSignature("124afdsfaf") +// expect(result.isSuccess).toEqual(false) +// }) +// }) + +// describe(" blockFirst - suite test block service", () => { +// it("blockFirst test ", async () => { +// const result = await blocks.blockFirst() +// expect(result.isSuccess).toEqual(true) +// }) +// }) + +// describe(" blockAddress - suite test block service", () => { +// it("blockAddress test ", async () => { +// const result = await blocks.blockAddress( +// "385vc8T7brZYTaNb1QV4BjU4JN9S3MoeKZd", +// 1889863, +// 1889864 +// ) +// expect(result).toStrictEqual([ +// { +// blocksize: 225, +// features: [], +// fee: 0, +// generator: "385vc8T7brZYTaNb1QV4BjU4JN9S3MoeKZd", +// height: 1889864, +// "nxt-consensus": { +// "base-target": 51, +// "generation-signature": +// "9iHAgT78TCbzv5HfhxVzzRnM132n45UGqGbvH59FvBoB" +// }, +// reference: +// "9zvED5KcnvkYsKLFxiCXQDiEsyXrKdtVH23b3qPt2FhAh3BrhUaZbqtndYWCbn4GmPrZvDbwY1vwqrxdgyazGfH", +// signature: +// "353wWZjKZzLiYKkVbgXLrxsK7dzYo9pEgw2pV31rXLnb1EdZbraZThrpg92swhrtQh1J353rPesvcB1mMEAoQtzP", +// timestamp: 1648218628090, +// transactionCount: 0, +// transactions: [], +// version: 3 +// } +// ]) +// }) + +// it(" blockAddress - error from > to ", async () => { +// const result = await blocks.blockAddress( +// "385vc8T7brZYTaNb1QV4BjU4JN9S3MoeKZd", +// 1889864, +// 1889863 +// ) +// expect(result.isSuccess).toEqual(false) +// }) + +// it(" blockAddress - error Max === false ", async () => { +// const result = await blocks.blockAddress( +// "385vc8T7brZYTaNb1QV4BjU4JN9S3MoeKZd", +// 1889863, +// 1889999 +// ) +// expect(result.isSuccess).toEqual(false) +// }) +// })