From cbc450140169c98e0794397903c714e13aa2d1d2 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Wed, 20 Nov 2019 19:19:06 +0300 Subject: [PATCH 01/11] fixed tests with lint --- .eslintignore | 1 - .eslintrc.js | 14 +- test/_test-data.js | 2 +- test/_test-utils.js | 8 +- test/api.test.js | 108 +-- test/api/database/check-erc20-token.test.js | 16 +- test/api/database/get-contract-logs2.test.js | 31 +- test/api/network.api.test.js | 51 +- test/api/register.account.test.js | 8 +- test/cache.test.js | 629 +++++++++--------- test/contract/Method.test.js | 10 +- test/contract/decoders/_bitsCount.test.js | 2 +- test/contract/decoders/dynamic-array.test.js | 4 +- .../decoders/dynamic-bytes-decoder.test.js | 2 +- .../decoders/signed-integer-decoder.test.js | 4 +- .../decoders/static-array-decoder.test.js | 2 +- .../decoders/static-bytes-decoder.test.js | 2 +- test/contract/decoders/string-decoder.test.js | 2 +- .../decoders/unsigned-integer-decoder.test.js | 2 +- test/contract/deploying.test.js | 14 +- .../contract/encoders/default-encoder.test.js | 38 +- .../encoders/integers-encoders.test.js | 10 +- .../utils/number-representations.test.js | 8 +- test/crypto/private-key.test.js | 12 +- test/crypto/utils.test.js | 9 +- test/deserializer.test.js | 2 +- .../chain/id/object-id.deserializer.test.js | 8 +- .../chain/public-key.deserializer.test.js | 11 +- .../static-variant.deserializer.test.js | 8 +- .../collections/struct.deserializer.test.js | 6 +- .../operation.deserializer.test.js | 6 +- .../deserializer/vote-id-deserializer.test.js | 8 +- test/main.test.js | 21 +- test/operations/_contract.test.js | 17 +- test/operations/_testExtensionsField.js | 12 +- .../account-create.operation.test.js | 14 +- .../account-update.operations.test.js | 8 +- test/operations/asset-issue.test.js | 8 +- .../balance-freeze.operation.test.js | 12 +- .../call-contract.operation.test.js | 2 +- .../operations/create-asset.operation.test.js | 7 +- .../create-contract.operation.test.js | 16 +- .../create-proposal.operation.test.js | 12 +- ...nnect-and-cache-renewing.operation.test.js | 40 +- test/operations/non-default-fee-asset.test.js | 47 +- .../sidechain.btc.operations.test.js | 33 +- test/operations/transfer.operation.test.js | 12 +- .../update-asset-feed-producers.test.js | 12 +- ...member-global-parameters.operation.test.js | 12 +- test/preparation/preparation.js | 4 +- test/redux.test.js | 280 ++++---- test/subscriber.test.js | 38 +- test/transaction.test.js | 14 +- test/wallet-api.test.js | 578 ++++++++-------- 54 files changed, 1122 insertions(+), 1115 deletions(-) diff --git a/.eslintignore b/.eslintignore index ca146357..1e38d277 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ node_modules/* dist/* -test/* scripts/* diff --git a/.eslintrc.js b/.eslintrc.js index 9c517d45..54181285 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,12 +2,14 @@ module.exports = { "extends": "airbnb", "env": { "browser": false, - "jest": true + "jest": true, + "mocha": true, }, "plugins": [ "import" ], "rules": { + "global-require": 0, "arrow-parens": [ "error", "always" @@ -44,5 +46,13 @@ module.exports = { ] } ] - } + }, + "overrides": [ + { + "files": ["*api.test.js", "*cache.test.js", "*subscriber.test.js"], + "rules": { + "no-unused-expressions": "off" + } + } + ] }; diff --git a/test/_test-data.js b/test/_test-data.js index 32fb1b6c..308c7778 100644 --- a/test/_test-data.js +++ b/test/_test-data.js @@ -1,4 +1,4 @@ -import { PrivateKey, constants } from "../"; +import { PrivateKey, constants } from '../'; export const privateKey = PrivateKey.fromWif('5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2'); export const accountName = 'nathan'; diff --git a/test/_test-utils.js b/test/_test-utils.js index 8c92bf29..dde5ea5a 100644 --- a/test/_test-utils.js +++ b/test/_test-utils.js @@ -1,5 +1,5 @@ -import { strictEqual, ok, fail } from "assert"; -import { inspect } from "util"; +import { strictEqual, ok, fail } from 'assert'; +import { inspect } from 'util'; /** * @param {() => Promise | any} f @@ -20,11 +20,11 @@ export function shouldReject(f, expectedErrorMessage, testErrorMessage) { console.log('got result:', inspect(res, false, null, true)); fail('should rejects'); }); - it('instance of Error', function () { + it('instance of Error', () => { if (!actualError) this.skip(); ok(actualError instanceof Error); }); - it(testErrorMessage || `with message "${expectedErrorMessage}"`, function () { + it(testErrorMessage || `with message "${expectedErrorMessage}"`, () => { if (!actualError || !(actualError instanceof Error)) this.skip(); strictEqual(actualError.message, expectedErrorMessage); }); diff --git a/test/api.test.js b/test/api.test.js index 212cba2d..fa109e6f 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { deepStrictEqual } from 'assert'; import WS from '../src/echo/ws'; import WSAPI from '../src/echo/ws-api'; import Cache from '../src/echo/cache'; @@ -8,18 +9,17 @@ import echo, { constants } from '../src'; import { DEFAULT_CHAIN_APIS, CHAIN_API } from '../src/constants/ws-constants'; import { url, accountId } from './_test-data'; -import { deepStrictEqual } from 'assert'; import { shouldReject } from './_test-utils'; describe('API', () => { describe('API CONNECTION', () => { describe('when apis are provided', () => { const apis = [CHAIN_API.DATABASE_API, CHAIN_API.ASSET_API]; - before(async () => await echo.connect(url, { apis })); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url, { apis })); + after(async () => echo.disconnect()); it('only provided apis should be connected', () => deepStrictEqual(echo.apis, new Set(apis))); describe('when provided api used', () => { - it('should succeed', async () => await echo.api.getBlock(1)); + it('should succeed', async () => echo.api.getBlock(1)); }); describe('when not provided api used', () => { const expectedErrorMessage = [ @@ -33,11 +33,11 @@ describe('API', () => { }); describe('when apis options is not provided', () => { - before(async () => await echo.connect(url, {})); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url, {})); + after(async () => echo.disconnect()); it('only default apis should be connected', () => deepStrictEqual(echo.apis, new Set(DEFAULT_CHAIN_APIS))); describe('when deafult api used', () => { - it('should succed', async () => await echo.api.getBlock(1)); + it('should succed', async () => echo.api.getBlock(1)); }); describe('when not default api used', () => { const expectedErrorMessage = [ @@ -63,13 +63,13 @@ describe('API', () => { await echo.connect(url, { apis }); await echo.reconnect(); }); - after(async () => await echo.disconnect()); + after(async () => echo.disconnect()); it('only provided apis should be connected', () => deepStrictEqual(echo.apis, new Set(apis))); describe('when provided api used', () => { - it('should succeed', async () => await echo.api.getAllAssetHolders()); + it('should succeed', async () => echo.api.getAllAssetHolders()); }); describe('when provided api used', () => { - it('should succeed', async () => await echo.api.getAccountHistory(accountId)); + it('should succeed', async () => echo.api.getAccountHistory(accountId)); }); describe('when not nonprovided api used', () => { const expectedErrorMessage = [ @@ -77,7 +77,7 @@ describe('API', () => { 'try to specify this in connection option called "apis"', ].join(', '); shouldReject(async () => { - await echo.api.getBlock(1) + await echo.api.getBlock(1); }, expectedErrorMessage, 'with expected message'); }); }); @@ -168,12 +168,10 @@ describe('API', () => { beforeEach(async () => { await ws.connect(url, { debug: false, - apis: constants.WS_CONSTANTS.CHAIN_APIS + apis: constants.WS_CONSTANTS.CHAIN_APIS, }); }); - afterEach(async () => { - await ws.close(); - }); + afterEach(async () => ws.close()); describe('configs', () => { describe('#getChainProperties()', () => { @@ -514,11 +512,11 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; const assetId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ASSET}.0`; const assetSymbol = 'ECHO'; - const objects = await api.getObjects([accountId, assetId]); + const objects = await api.getObjects([newAccountId, assetId]); const accountName = objects[0].name; @@ -530,14 +528,14 @@ describe('API', () => { expect(objects[0]) .to .deep - .equal(cache.accountsById.get(accountId) + .equal(cache.accountsById.get(newAccountId) .toJS()); expect(objects[0]) .to .deep - .equal(cache.objectsById.get(accountId) + .equal(cache.objectsById.get(newAccountId) .toJS()); - expect(accountId) + expect(newAccountId) .to .equal(cache.accountsByName.get(accountName)); expect(objects[1]) @@ -568,11 +566,11 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; const assetId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ASSET}.0`; const assetSymbol = 'ECHO'; - const objects = await api.getObjects([accountId, assetId]); + const objects = await api.getObjects([newAccountId, assetId]); const accountName = objects[0].name; @@ -584,14 +582,14 @@ describe('API', () => { expect(objects[0]) .to .deep - .equal(cache.accountsById.get(accountId) + .equal(cache.accountsById.get(newAccountId) .toJS()); expect(objects[0]) .to .deep - .equal(cache.objectsById.get(accountId) + .equal(cache.objectsById.get(newAccountId) .toJS()); - expect(accountId) + expect(newAccountId) .to .equal(cache.accountsByName.get(accountName)); expect(objects[1]) @@ -783,7 +781,7 @@ describe('API', () => { .timeout(5000); }); describe('#requestRegistrationTask', () => { - it('should get registration task', async() => { + it('should get registration task', async () => { try { const wsApi = new WSAPI(ws); const cache = new Cache(); @@ -817,7 +815,7 @@ describe('API', () => { .be .an('array'); - const accountId = objects[0].committee_member_account; + const committeeMemberAccountId = objects[0].committee_member_account; const voteId = objects[0].vote_id; expect(objects[0]) @@ -833,7 +831,7 @@ describe('API', () => { expect(objects[0]) .to .deep - .equal(cache.committeeMembersByAccountId.get(accountId) + .equal(cache.committeeMembersByAccountId.get(committeeMemberAccountId) .toJS()); expect(objects[0]) .to @@ -853,16 +851,15 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.6`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.6`; - const object = await api.getCommitteeMemberByAccount(accountId); + const object = await api.getCommitteeMemberByAccount(newAccountId); expect(object) .to .be .an('object'); - - const id = object.id; + const { id } = object; const voteId = object.vote_id; expect(object) @@ -878,7 +875,7 @@ describe('API', () => { expect(object) .to .deep - .equal(cache.committeeMembersByAccountId.get(accountId) + .equal(cache.committeeMembersByAccountId.get(newAccountId) .toJS()); expect(object) .to @@ -891,7 +888,7 @@ describe('API', () => { }) .timeout(5000); }); - describe('#getCommitteeFrozenBalance()', () =>{ + describe('#getCommitteeFrozenBalance()', () => { it('should get committee frozen balance by committee member id', async () => { try { const wsApi = new WSAPI(ws); @@ -907,9 +904,10 @@ describe('API', () => { .be .an('object'); - const { asset_id, amount } = object; + const { amount } = object; + const assetId = object.asset_id; - expect(asset_id) + expect(assetId) .to .be .an('string').that.is.not.empty; @@ -930,14 +928,14 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.6`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.6`; - const btcAddress = await api.getBtcAddress(accountId); + const btcAddress = await api.getBtcAddress(newAccountId); expect(btcAddress) .to .be - .an('null');; + .an('null'); } catch (e) { throw e; } @@ -945,10 +943,13 @@ describe('API', () => { .timeout(5000); }); + /*eslint-disable */ // TODO:: return 76a9148768abc89249471f990fdf33029ac6c733603a258763ac6775532102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e74 // 2ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e4 // 96e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efe // b07e496e742ac84512e21026b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b56ae68 + /* eslint-enable */ + describe.skip('#getBtcDepositScript()', () => { it('should get null because script with this deposit id does not exist', async () => { try { @@ -963,7 +964,7 @@ describe('API', () => { expect(script) .to .be - .an('null');; + .an('null'); } catch (e) { throw e; } @@ -975,11 +976,12 @@ describe('API', () => { describe('history', () => { const ws = new WS(); beforeEach(async () => { - await ws.connect(url, { apis: ['database', 'network_broadcast', 'history', 'registration', 'asset', 'login'] }); - }); - afterEach(async () => { - await ws.close(); + await ws.connect( + url, + { apis: ['database', 'network_broadcast', 'history', 'registration', 'asset', 'login'] }, + ); }); + afterEach(async () => ws.close()); describe('#getAccountHistory()', () => { it('should get account history', async () => { try { @@ -987,9 +989,9 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.2`; - const history = await api.getAccountHistory(accountId); + const history = await api.getAccountHistory(newAccountId); expect(history) .to .be @@ -1007,12 +1009,12 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.0`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.0`; const start = 0; const stop = 0; const limit = 10; - const history = await api.getRelativeAccountHistory(accountId, stop, limit, start); + const history = await api.getRelativeAccountHistory(newAccountId, stop, limit, start); expect(history) .to .be @@ -1030,13 +1032,19 @@ describe('API', () => { const cache = new Cache(); const api = new API(cache, wsApi); - const accountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.0`; + const newAccountId = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.ACCOUNT}.0`; const operationId = 0; const start = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.OPERATION_HISTORY}.0`; const stop = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.OPERATION_HISTORY}.0`; const limit = 10; - const history = await api.getAccountHistoryOperations(accountId, operationId, start, stop, limit); + const history = await api.getAccountHistoryOperations( + newAccountId, + operationId, + start, + stop, + limit, + ); expect(history) .to .be diff --git a/test/api/database/check-erc20-token.test.js b/test/api/database/check-erc20-token.test.js index 78305c2e..64610b3a 100644 --- a/test/api/database/check-erc20-token.test.js +++ b/test/api/database/check-erc20-token.test.js @@ -6,7 +6,7 @@ import { Echo, OPERATIONS_IDS, constants } from '../../../'; describe('checkERC20Token', () => { /** @type {import("../../../types").Echo} */ const echo = new Echo(); - before(async () => await echo.connect(url, { apis: constants.WS_CONSTANTS.CHAIN_APIS, })); + before(async () => echo.connect(url, { apis: constants.WS_CONSTANTS.CHAIN_APIS })); describe('when contract id with invalid format provided', () => { shouldReject(async () => { await echo.api.checkERC20Token('invalid contract id format'); @@ -16,7 +16,7 @@ describe('checkERC20Token', () => { describe.skip('when contract with provided id is not a ERC20 token.', () => { /** @type {string} */ let contractId; - before(async function () { + before(async () => { this.timeout(25e3); const tx = echo.createTransaction().addOperation(OPERATIONS_IDS.CONTRACT_CREATE, { registrar: accountId, @@ -31,16 +31,16 @@ describe('checkERC20Token', () => { const opResId = broadcastingRes[0].trx.operation_results[0][1]; const opRes = await echo.api.getObject(opResId); - contractId = opRes.contracts_id[0]; + [contractId] = opRes.contracts_id; }); /** @type {boolean} */ let res; it('should not rejects', async () => { res = await echo.api.checkERC20Token(contractId); }); - it('should returns boolean', function () { + it('should returns boolean', () => { if (res === undefined) this.skip(); else ok(typeof res === 'boolean'); }); - it('should equals to "false"', function () { + it('should equals to "false"', () => { if (typeof res !== 'boolean') this.skip(); else strictEqual(res, false); }); @@ -49,7 +49,7 @@ describe('checkERC20Token', () => { describe.skip('when nonexistent contract id provided', () => { /** @type {string} */ let nonexistentContractId; - before(async function () { + before(async () => { this.timeout(7e3); const broadcastingRes = await echo.createTransaction().addOperation(OPERATIONS_IDS.CONTRACT_CREATE, { registrar: accountId, @@ -63,10 +63,10 @@ describe('checkERC20Token', () => { nonexistentContractId = [ constants.CHAIN_TYPES.RESERVED_SPACE_ID.PROTOCOL, constants.PROTOCOL_OBJECT_TYPE_ID.CONTRACT, - Number.parseInt(contractId.split('.')[2]) + 1, + Number.parseInt(contractId.split('.')[2], 10) + 1, ].join('.'); console.log(nonexistentContractId); }); - shouldReject(async () => await echo.api.checkERC20Token('1.9.3213213213'), ''); + shouldReject(async () => echo.api.checkERC20Token('1.9.3213213213'), ''); }); }); diff --git a/test/api/database/get-contract-logs2.test.js b/test/api/database/get-contract-logs2.test.js index c09d09ee..ace4a9f2 100644 --- a/test/api/database/get-contract-logs2.test.js +++ b/test/api/database/get-contract-logs2.test.js @@ -1,7 +1,6 @@ -import { Echo, OPERATIONS_IDS } from "../../.."; -import { url, accountId, privateKey } from "../../_test-data"; -import { inspect } from "util"; -import { ok, deepStrictEqual } from "assert"; +import { ok, deepStrictEqual } from 'assert'; +import { Echo, OPERATIONS_IDS } from '../../..'; +import { url, accountId, privateKey } from '../../_test-data'; /* * pragma solidity ^0.4.24; @@ -11,14 +10,14 @@ import { ok, deepStrictEqual } from "assert"; * } */ const bytecode = [ - "608060405234801561001057600080fd5b5060e08061001f6000396000f300608060405260043610603f576000357c010000000000000000", - "0000000000000000000000000000000000000000900463ffffffff168063eb8ac921146044575b600080fd5b348015604f57600080fd5b50", - "607660048036038101908080359060200190929190803590602001909291905050506078565b005b817f91916a5e2c96453ddf6b58549726", - "2675140eb9f7a774095fb003d93e6dc69216826040518082815260200191505060405180910390a250505600a165627a7a7230582085d4cd", - "c749b60050d7df224ded452a41549e1880caf023c417b9e1aca69645670029", -].join(""); + '608060405234801561001057600080fd5b5060e08061001f6000396000f300608060405260043610603f576000357c010000000000000000', + '0000000000000000000000000000000000000000900463ffffffff168063eb8ac921146044575b600080fd5b348015604f57600080fd5b50', + '607660048036038101908080359060200190929190803590602001909291905050506078565b005b817f91916a5e2c96453ddf6b58549726', + '2675140eb9f7a774095fb003d93e6dc69216826040518082815260200191505060405180910390a250505600a165627a7a7230582085d4cd', + 'c749b60050d7df224ded452a41549e1880caf023c417b9e1aca69645670029', +].join(''); -describe("getContractLogs", () => { +describe('getContractLogs', () => { const echo = new Echo(); /** @type {string} */ let contractId; @@ -27,7 +26,7 @@ describe("getContractLogs", () => { await echo.connect(url); const txRes = await echo.createTransaction().addOperation(OPERATIONS_IDS.CONTRACT_CREATE, { registrar: accountId, - value: { amount: 0, asset_id: "1.3.0" }, + value: { amount: 0, asset_id: '1.3.0' }, code: bytecode, eth_accuracy: false, extensions: [], @@ -35,17 +34,17 @@ describe("getContractLogs", () => { /** @type {string} */ const opResId = txRes[0].trx.operation_results[0][1]; const opRes = await echo.api.getObject(opResId); - contractId = opRes.contracts_id[0]; + [contractId] = opRes.contracts_id; ok(contractId !== undefined); }); - describe("when options are not provided", () => { + describe('when options are not provided', () => { /** @type {[]} */ let result; - it("should not rejects", async () => { + it('should not rejects', async () => { result = await echo.api.getContractLogs(); ok(result !== undefined); }); - it("should return empty array", function () { + it('should return empty array', () => { if (result === undefined) this.skip(); else deepStrictEqual(result, []); }); diff --git a/test/api/network.api.test.js b/test/api/network.api.test.js index 966f8ebe..0bba8acb 100644 --- a/test/api/network.api.test.js +++ b/test/api/network.api.test.js @@ -13,8 +13,8 @@ const echo = new Echo(); */ describe('Network API', () => { - before(async () => await echo.connect(url, { apis: constants.WS_CONSTANTS.CHAIN_APIS })); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url, { apis: constants.WS_CONSTANTS.CHAIN_APIS })); + after(async () => echo.disconnect()); describe('getConnectedPeers', () => { describe('when not connected to any node', () => { /** @type {UnPromisify>} */ @@ -24,11 +24,11 @@ describe('Network API', () => { result = await echo.api.getConnectedPeers(); excepted = false; }); - it('should return array', function () { + it('should return array', () => { if (excepted) this.skip(); ok(Array.isArray(result)); }); - it('that is empty', function () { + it('that is empty', () => { if (excepted || !Array.isArray(result)) this.skip(); strictEqual(result.length, 0); }); @@ -42,12 +42,12 @@ describe('Network API', () => { result = await echo.api.getPotentialPeers(); excepted = false; }); - it('should return array', function () { + it('should return array', () => { if (excepted) this.skip(); ok(Array.isArray(result)); }); - it('if is not empty', function () { if (!Array.isArray(result) || result.length === 0) this.skip(); }); - it('every element is object', function () { + it('if is not empty', () => { if (!Array.isArray(result) || result.length === 0) this.skip(); }); + it('every element is object', () => { if (!Array.isArray(result) || result.length === 0) this.skip(); for (const e of result) ok(typeof e === 'object' && e !== null); }); @@ -60,16 +60,20 @@ describe('Network API', () => { 'number_of_failed_connection_attempts', 'last_error', ]); - it('with no unexpected fields', function () { + it('with no unexpected fields', () => { if (!Array.isArray(result) || result.length === 0) this.skip(); for (const e of result) { - for (const field in e) ok(expectedFields.has(field)); + for (const field in e) { + if (Object.prototype.hasOwnProperty.call(e, field)) { + ok(expectedFields.has(field)); + } + } } }); describe('with field "endpoint"', () => { /** @type {string[]} */ let endpoints; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); endpoints = result.map((e) => e.endpoint); ok(endpoints.every((e) => e !== undefined)); @@ -79,7 +83,7 @@ describe('Network API', () => { ok(endpoints.every((e) => typeof e === 'string')); isString = true; }); - it('that is ip-port url', function () { + it('that is ip-port url', () => { if (!isString) this.skip(); for (const e of endpoints) { const split = e.split(':'); @@ -101,7 +105,7 @@ describe('Network API', () => { describe('with field "last_seen_time"', () => { /** @type {string[]} */ let lastSeenTimes; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); lastSeenTimes = result.map((e) => e.last_seen_time); ok(lastSeenTimes.every((e) => e !== undefined)); @@ -111,15 +115,15 @@ describe('Network API', () => { ok(lastSeenTimes.every((e) => typeof e === 'string')); isString = true; }); - it('that is ISO time with no miliseconds and "Z" postfix', function () { + it('that is ISO time with no miliseconds and "Z" postfix', () => { if (!isString) this.skip(); - for (const e of lastSeenTimes) strictEqual(new Date(e + 'Z').toISOString().slice(0, 19), e); + for (const e of lastSeenTimes) strictEqual(new Date(`${e}Z`).toISOString().slice(0, 19), e); }); }); describe('with field "last_connection_disposition"', () => { /** @type {string[]} */ let lastConnectionDispositions; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); lastConnectionDispositions = result.map((e) => e.last_connection_disposition); ok(lastConnectionDispositions.every((e) => e !== undefined)); @@ -129,17 +133,16 @@ describe('Network API', () => { ok(lastConnectionDispositions.every((e) => typeof e === 'string')); isString = true; }); - it('that is "POTENTIAL_PEER_LAST_CONNECTION_DISPOSITION"', function () { + it('that is "POTENTIAL_PEER_LAST_CONNECTION_DISPOSITION"', () => { if (!isString) this.skip(); - ok(lastConnectionDispositions.every((e) => { - return Object.values(POTENTIAL_PEER_LAST_CONNECTION_DISPOSITION).includes(e); - })); + ok(lastConnectionDispositions + .every((e) => Object.values(POTENTIAL_PEER_LAST_CONNECTION_DISPOSITION).includes(e))); }); }); describe('with field "last_connection_attempt_time"', () => { /** @type {string[]} */ let lastConnectionAttemptTimes; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); lastConnectionAttemptTimes = result.map((e) => e.last_connection_attempt_time); ok(lastConnectionAttemptTimes.every((e) => e !== undefined)); @@ -149,17 +152,17 @@ describe('Network API', () => { ok(lastConnectionAttemptTimes.every((e) => typeof e === 'string')); isString = true; }); - it('that is ISO time with no miliseconds and "Z" postfix', function () { + it('that is ISO time with no miliseconds and "Z" postfix', () => { if (!isString) this.skip(); for (const e of lastConnectionAttemptTimes) { - strictEqual(new Date(e + 'Z').toISOString().slice(0, 19), e); + strictEqual(new Date(`${e}Z`).toISOString().slice(0, 19), e); } }); }); describe('with field "number_of_successful_connection_attempts"', () => { /** @type {number[]} */ let numbersOfSuccessfulConnectionAttempts; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); numbersOfSuccessfulConnectionAttempts = result.map((e) => e.number_of_successful_connection_attempts); ok(numbersOfSuccessfulConnectionAttempts.every((e) => e !== undefined)); @@ -173,7 +176,7 @@ describe('Network API', () => { describe('with field "number_of_failed_connection_attempts"', () => { /** @type {number[]} */ let numbersOfFailedConnectionAttempts; - before(function () { + before(() => { if (!Array.isArray(result) || result.length === 0) this.skip(); numbersOfFailedConnectionAttempts = result.map((e) => e.number_of_failed_connection_attempts); ok(numbersOfFailedConnectionAttempts.every((e) => e !== undefined)); diff --git a/test/api/register.account.test.js b/test/api/register.account.test.js index 549f2a13..0b24028a 100644 --- a/test/api/register.account.test.js +++ b/test/api/register.account.test.js @@ -11,21 +11,21 @@ describe('API register account POW', () => { pingTimeout: 3000, pingDelay: 10000, debug: false, - apis: ['database', 'registration'],//constants.WS_CONSTANTS.CHAIN_APIS, + apis: ['database', 'registration'], // constants.WS_CONSTANTS.CHAIN_APIS, }); }); - after(async () => await echo.disconnect()); + after(async () => { await echo.disconnect(); }); describe('register account', () => { it('register account', async () => { const result = await echo.api.registerAccount( - 'kokoko'+ Date.now(), + `kokoko${Date.now()}`, 'ECHODvHDsAfk2M8LhYcxLZTbrNJRWT3UH5zxdaWimWc6uZkH', 'ECHODvHDsAfk2M8LhYcxLZTbrNJRWT3UH5zxdaWimWc6uZkH', () => console.log('was broadcasted'), - ) + ); ok(Array.isArray(result)); }).timeout(1e8); }); diff --git a/test/cache.test.js b/test/cache.test.js index df28035f..6967ac06 100644 --- a/test/cache.test.js +++ b/test/cache.test.js @@ -1,324 +1,341 @@ - import 'mocha'; import { expect } from 'chai'; import echo, { constants, Echo } from '../src/index'; -import { USE_CACHE_BY_DEFAULT, DEFAULT_CACHE_EXPIRATION_TIME, DEFAULT_MIN_CACHE_CLEANING_TIME, CACHE_MAPS } from '../src/constants'; +import { + USE_CACHE_BY_DEFAULT, + DEFAULT_CACHE_EXPIRATION_TIME, + DEFAULT_MIN_CACHE_CLEANING_TIME, + CACHE_MAPS, +} from '../src/constants'; import { url } from './_test-data'; describe('cache', () => { - describe('options', () => { - describe('when cache option has not been specified', () => { - before(async () => await echo.connect(url, {})); - after(async () => await echo.disconnect()); - it('should use default options', () => { - const { isUsed, expirationTime, minCleaningTime } = echo.cache; - - expect(isUsed).to.be.equal(USE_CACHE_BY_DEFAULT); - expect(expirationTime).to.be.equal(DEFAULT_CACHE_EXPIRATION_TIME); - expect(minCleaningTime).to.be.equal(DEFAULT_MIN_CACHE_CLEANING_TIME); - }); - }); - - describe('when empty object was specified as cache options', () => { - before(async () => await echo.connect(url, { cache: {} })); - after(async () => await echo.disconnect()); - it('should use default options', () => { - const { isUsed, expirationTime, minCleaningTime } = echo.cache; - - expect(isUsed).to.be.equal(USE_CACHE_BY_DEFAULT); - expect(expirationTime).to.be.equal(DEFAULT_CACHE_EXPIRATION_TIME); - expect(minCleaningTime).to.be.equal(DEFAULT_MIN_CACHE_CLEANING_TIME); - }); - }); - - describe('when null was specified as cache option', () => { - before(async () => await echo.connect(url, { cache: null })); - after(async () => await echo.disconnect()); - it('cache should not be used', () => { - const { isUsed } = echo.cache; - - expect(isUsed).to.be.false; - }) - }); - - describe('when used specified options', () => { - const cache = { isUsed: false, expirationTime: 322, minCleaningTime: 777 } - before(async () => await echo.connect(url, { cache })); - after(async () => await echo.disconnect()); - it('should use specified options', () => { - const { isUsed, expirationTime, minCleaningTime } = echo.cache; - - expect(isUsed).to.be.equal(cache.isUsed); - expect(expirationTime).to.be.equal(cache.expirationTime); - expect(minCleaningTime).to.be.equal(cache.minCleaningTime); - }); - }); - }); - - describe('cleaning', () => { - const blocksRounds = [1, 2, 3, 4, 5]; + describe('options', () => { + describe('when cache option has not been specified', () => { + before(async () => echo.connect(url, {})); + after(async () => echo.disconnect()); + it('should use default options', () => { + const { isUsed, expirationTime, minCleaningTime } = echo.cache; + + expect(isUsed).to.be.equal(USE_CACHE_BY_DEFAULT); + expect(expirationTime).to.be.equal(DEFAULT_CACHE_EXPIRATION_TIME); + expect(minCleaningTime).to.be.equal(DEFAULT_MIN_CACHE_CLEANING_TIME); + }); + }); + + describe('when empty object was specified as cache options', () => { + before(async () => echo.connect(url, { cache: {} })); + after(async () => echo.disconnect()); + it('should use default options', () => { + const { isUsed, expirationTime, minCleaningTime } = echo.cache; + + expect(isUsed).to.be.equal(USE_CACHE_BY_DEFAULT); + expect(expirationTime).to.be.equal(DEFAULT_CACHE_EXPIRATION_TIME); + expect(minCleaningTime).to.be.equal(DEFAULT_MIN_CACHE_CLEANING_TIME); + }); + }); + + describe('when null was specified as cache option', () => { + before(async () => echo.connect(url, { cache: null })); + after(async () => echo.disconnect()); + it('cache should not be used', () => { + const { isUsed } = echo.cache; + + expect(isUsed).to.be.false; + }); + }); + + describe('when used specified options', () => { + const cache = { isUsed: false, expirationTime: 322, minCleaningTime: 777 }; + before(async () => echo.connect(url, { cache })); + after(async () => echo.disconnect()); + it('should use specified options', () => { + const { isUsed, expirationTime, minCleaningTime } = echo.cache; + + expect(isUsed).to.be.equal(cache.isUsed); + expect(expirationTime).to.be.equal(cache.expirationTime); + expect(minCleaningTime).to.be.equal(cache.minCleaningTime); + }); + }); + }); + + describe('cleaning', () => { + const blocksRounds = [1, 2, 3, 4, 5]; /** @type {import("../types").Echo} */ - const echo = new Echo(); + const newEcho = new Echo(); before(async function () { this.timeout(25e3); - await echo.connect(url); + await newEcho.connect(url); const blockToWait = Math.max(...blocksRounds) + 1; while (true) { - const { head_block_number } = await echo.api.getDynamicGlobalProperties(true); - if (head_block_number >= blockToWait) break; - console.log(`waiting for block #${blockToWait}. current head block number - ${head_block_number}`); + // eslint-disable-next-line no-await-in-loop + const globalProperties = await newEcho.api.getDynamicGlobalProperties(true); + const headBlockNumber = globalProperties.head_block_number; + if (headBlockNumber >= blockToWait) break; + console.log(`waiting for block #${blockToWait}. current head block number - ${headBlockNumber}`); + // eslint-disable-next-line no-await-in-loop await new Promise((resolve) => setTimeout(() => resolve(), 3e3)); } - await echo.disconnect(); + await newEcho.disconnect(); }); - afterEach(async () => { - await echo.disconnect(); - }); - - describe('clean only expired blocks', () => { - before(async () => { - await echo.connect(url, { - apis: [ - constants.WS_CONSTANTS.CHAIN_API.DATABASE_API - ], - cache: { - isUsed: false, - expirationTime: null, - minCleaningTime: null, - } - }); - }); - - it('should clean expired blocks', async () => { - try { - const promises = []; - - const expiredFromIndex = 3; - const currentTime = Date.now(); - const notExpiredRoundsTime = currentTime + 5 * 60 * 1000; - - blocksRounds.forEach((round, roundIndex) => { - promises.push(new Promise((res, rej) => { - echo.api.getBlock(round) - .then((block) => { - echo.cache.expirations.push({ time: roundIndex >= expiredFromIndex ? notExpiredRoundsTime : currentTime, map: CACHE_MAPS.BLOCKS, key: block.round }); - echo.cache[CACHE_MAPS.BLOCKS] = echo.cache[CACHE_MAPS.BLOCKS].set(block.round, block); - res(block.round); - }).catch((err) => { - rej(err); - }); - })); - }); - - await Promise.all(promises); - - echo.cache.isUsed = true; - echo.cache._removeExpired(); - - blocksRounds.forEach((round, roundIndex) => { - const expiretionIndex = echo.cache.expirations.findIndex((expiration) => { - return expiration.key === round - }); - - expect(expiretionIndex).to.be.equal(roundIndex >= expiredFromIndex ? roundIndex - expiredFromIndex : -1); - expect(echo.cache.blocks.has(round)).to.be.equal(roundIndex >= expiredFromIndex ? true : false); - }); - } catch (e) { - throw e; - } - }) - }); - - describe('clean several blocks at once', () => { - before(async () => { - await echo.connect(url, { - apis: [ - constants.WS_CONSTANTS.CHAIN_API.DATABASE_API - ], - cache: { - isUsed: false, - expirationTime: null, - minCleaningTime: null, - } - }); - }); - - it('should clean several blocks at once', async () => { - try { - const promises = []; - - blocksRounds.forEach((round) => { - promises.push(new Promise((res, rej) => { - echo.api.getBlock(round) - .then((block) => { - echo.cache.expirations.push({ time: Date.now(), map: CACHE_MAPS.BLOCKS, key: block.round }); - echo.cache[CACHE_MAPS.BLOCKS] = echo.cache[CACHE_MAPS.BLOCKS].set(block.round, block); - res(block.round); - }).catch((err) => { - rej(err); - }); - })); - }); - - await Promise.all(promises); - - echo.cache.isUsed = true; - echo.cache._removeExpired(); - - expect(echo.cache.expirations.length).to.be.equal(0); - expect(echo.cache.blocks.size).to.be.equal(0); - } catch (e) { - throw e; - } - }); - }); - - describe('cleaning does not happen more often then "minCleaningTime"', () => { - before(async () => { - await echo.connect(url, { - apis: [ - constants.WS_CONSTANTS.CHAIN_API.DATABASE_API - ], - cache: { - isUsed: false, - expirationTime: null, - minCleaningTime: 1000, - } - }); - }); - - it('should not clean more often then minCleaningTime', async () => { - try { - const promises = []; - const expirationTime = 100; - const tickInterval = 50; - - const tick = (res, callCount = 0, pastCacheSize = echo.cache.blocks.size) => { - const currentCacheSize = echo.cache.blocks.size; - - if (pastCacheSize !== currentCacheSize) { - expect(callCount * tickInterval).to.be.equal(echo.cache.minCleaningTime); - res(); - } else { - if (currentCacheSize !== 0) { - setTimeout(() => { - tick(res, callCount + 1, currentCacheSize); - }, tickInterval); - } - } - }; - - blocksRounds.forEach((round, roundIndex) => { - promises.push(new Promise((res, rej) => { - echo.api.getBlock(round) - .then((block) => { - echo.cache.expirations.push({ time: Date.now() + roundIndex * expirationTime, map: CACHE_MAPS.BLOCKS, key: block.round }); - echo.cache[CACHE_MAPS.BLOCKS] = echo.cache[CACHE_MAPS.BLOCKS].set(block.round, block); - res(block.round); - }).catch((err) => { - rej(err); - }); - })); - }); - - await Promise.all(promises); - - echo.cache.isUsed = true; - echo.cache._removeExpired(); - - await new Promise((res, rej) => { - try { - tick(res); - } catch (err) { - rej(err); - } - }); - - } catch (e) { - throw(e); - } - }) - }).timeout(5000); - - describe('when isUsed = false, cache is always empty', () => { - before(async () => { - await echo.connect(url, { - apis: [ - constants.WS_CONSTANTS.CHAIN_API.DATABASE_API - ], - cache: { - isUsed: false, - expirationTime: null, - minCleaningTime: 1000, - } - }); - }); - - it('cache should be empty', async () => { - try { - const promises = []; - - blocksRounds.forEach((round) => { - promises.push(new Promise((res, rej) => { - echo.api.getBlock(round) - .then((block) => { - res(block.round); - }).catch((err) => { - rej(err); - }); - })); - }); - - await Promise.all(promises); - - expect(echo.cache.expirations.length).to.be.equal(0); - expect(echo.cache.blocks.size).to.be.equal(0); - } catch (e) { - throw e; - } - }) - }); - - describe('when expirationTime = null, cache is used but never cleared', async () => { - before(async () => { - await echo.connect(url, { - apis: [ - constants.WS_CONSTANTS.CHAIN_API.DATABASE_API - ], - cache: { - isUsed: true, - expirationTime: null, - minCleaningTime: 1000, - } - }); - }); - - it('chache should not be cleared', async () => { - try { - const promises = []; - - blocksRounds.forEach((round) => { - promises.push(new Promise((res, rej) => { - echo.api.getBlock(round) - .then((block) => { - res(block.round); - }).catch((err) => { - rej(err); - }); - })); - }); - - await Promise.all(promises); - - expect(echo.cache.blocks.size).to.be.equal(blocksRounds.length); - expect(echo.cache.timeout).to.be.null; - } catch (e) { - throw e; - } - }); - }); - }); + afterEach(async () => newEcho.disconnect()); + + describe('clean only expired blocks', () => { + before(async () => { + await newEcho.connect(url, { + apis: [ + constants.WS_CONSTANTS.CHAIN_API.DATABASE_API, + ], + cache: { + isUsed: false, + expirationTime: null, + minCleaningTime: null, + }, + }); + }); + + it('should clean expired blocks', async () => { + try { + const promises = []; + + const expiredFromIndex = 3; + const currentTime = Date.now(); + const notExpiredRoundsTime = currentTime + (5 * 60 * 1000); + + blocksRounds.forEach((round, roundIndex) => { + promises.push(new Promise((res, rej) => { + newEcho.api.getBlock(round) + .then((block) => { + newEcho.cache.expirations.push({ + time: roundIndex >= expiredFromIndex ? notExpiredRoundsTime : currentTime, + map: CACHE_MAPS.BLOCKS, + key: block.round, + }); + newEcho.cache[CACHE_MAPS.BLOCKS] = newEcho.cache[CACHE_MAPS.BLOCKS] + .set(block.round, block); + res(block.round); + }).catch((err) => { + rej(err); + }); + })); + }); + + await Promise.all(promises); + + newEcho.cache.isUsed = true; + newEcho.cache._removeExpired(); + + blocksRounds.forEach((round, roundIndex) => { + const expiretionIndex = newEcho.cache.expirations + .findIndex((expiration) => expiration.key === round); + expect(expiretionIndex).to.be + .equal(roundIndex >= expiredFromIndex ? roundIndex - expiredFromIndex : -1); + expect(newEcho.cache.blocks.has(round)).to.be.equal(roundIndex >= expiredFromIndex); + }); + } catch (e) { + throw e; + } + }); + }); + + describe('clean several blocks at once', () => { + before(async () => { + await newEcho.connect(url, { + apis: [ + constants.WS_CONSTANTS.CHAIN_API.DATABASE_API, + ], + cache: { + isUsed: false, + expirationTime: null, + minCleaningTime: null, + }, + }); + }); + + it('should clean several blocks at once', async () => { + try { + const promises = []; + + blocksRounds.forEach((round) => { + promises.push(new Promise((res, rej) => { + newEcho.api.getBlock(round) + .then((block) => { + newEcho.cache.expirations.push({ + time: Date.now(), + map: CACHE_MAPS.BLOCKS, + key: block.round, + }); + newEcho.cache[CACHE_MAPS.BLOCKS] = newEcho.cache[CACHE_MAPS.BLOCKS] + .set(block.round, block); + res(block.round); + }).catch((err) => { + rej(err); + }); + })); + }); + + await Promise.all(promises); + + newEcho.cache.isUsed = true; + newEcho.cache._removeExpired(); + + expect(newEcho.cache.expirations.length).to.be.equal(0); + expect(newEcho.cache.blocks.size).to.be.equal(0); + } catch (e) { + throw e; + } + }); + }); + + describe('cleaning does not happen more often then "minCleaningTime"', () => { + before(async () => { + await newEcho.connect(url, { + apis: [ + constants.WS_CONSTANTS.CHAIN_API.DATABASE_API, + ], + cache: { + isUsed: false, + expirationTime: null, + minCleaningTime: 1000, + }, + }); + }); + + it('should not clean more often then minCleaningTime', async () => { + try { + const promises = []; + const expirationTime = 100; + const tickInterval = 50; + + const tick = (res, callCount = 0, pastCacheSize = newEcho.cache.blocks.size) => { + const currentCacheSize = newEcho.cache.blocks.size; + + if (pastCacheSize !== currentCacheSize) { + expect(callCount * tickInterval).to.be.equal(newEcho.cache.minCleaningTime); + res(); + } else if (currentCacheSize !== 0) { + setTimeout(() => { + tick(res, callCount + 1, currentCacheSize); + }, tickInterval); + } + }; + + blocksRounds.forEach((round, roundIndex) => { + promises.push(new Promise((res, rej) => { + newEcho.api.getBlock(round) + .then((block) => { + newEcho.cache.expirations.push({ + time: Date.now() + (roundIndex * expirationTime), + map: CACHE_MAPS.BLOCKS, + key: block.round, + }); + newEcho.cache[CACHE_MAPS.BLOCKS] = newEcho.cache[CACHE_MAPS.BLOCKS] + .set(block.round, block); + res(block.round); + }).catch((err) => { + rej(err); + }); + })); + }); + + await Promise.all(promises); + + newEcho.cache.isUsed = true; + newEcho.cache._removeExpired(); + + await new Promise((res, rej) => { + try { + tick(res); + } catch (err) { + rej(err); + } + }); + + } catch (e) { + throw (e); + } + }); + }).timeout(5000); + + describe('when isUsed = false, cache is always empty', () => { + before(async () => { + await newEcho.connect(url, { + apis: [ + constants.WS_CONSTANTS.CHAIN_API.DATABASE_API, + ], + cache: { + isUsed: false, + expirationTime: null, + minCleaningTime: 1000, + }, + }); + }); + + it('cache should be empty', async () => { + try { + const promises = []; + + blocksRounds.forEach((round) => { + promises.push(new Promise((res, rej) => { + newEcho.api.getBlock(round) + .then((block) => { + res(block.round); + }).catch((err) => { + rej(err); + }); + })); + }); + + await Promise.all(promises); + + expect(newEcho.cache.expirations.length).to.be.equal(0); + expect(newEcho.cache.blocks.size).to.be.equal(0); + } catch (e) { + throw e; + } + }); + }); + + describe('when expirationTime = null, cache is used but never cleared', async () => { + before(async () => { + await newEcho.connect(url, { + apis: [ + constants.WS_CONSTANTS.CHAIN_API.DATABASE_API, + ], + cache: { + isUsed: true, + expirationTime: null, + minCleaningTime: 1000, + }, + }); + }); + + it('chache should not be cleared', async () => { + try { + const promises = []; + + blocksRounds.forEach((round) => { + promises.push(new Promise((res, rej) => { + newEcho.api.getBlock(round) + .then((block) => { + res(block.round); + }).catch((err) => { + rej(err); + }); + })); + }); + + await Promise.all(promises); + + expect(newEcho.cache.blocks.size).to.be.equal(blocksRounds.length); + expect(newEcho.cache.timeout).to.be.null; + } catch (e) { + throw e; + } + }); + }); + }); }); diff --git a/test/contract/Method.test.js b/test/contract/Method.test.js index 52f485ba..ad560c81 100644 --- a/test/contract/Method.test.js +++ b/test/contract/Method.test.js @@ -49,7 +49,7 @@ describe('Method', () => { describe('code getter', () => { it('get code method', () => { /** @type {Abi} */ - const abi = [{ + const newAbi = [{ contract: false, inputs: [ { type: 'bytes24[3]', name: 'bytes72' }, @@ -62,8 +62,8 @@ describe('Method', () => { stateMutability: 'nonpayable', type: 'function', }]; - const contract = new Contract(abi); - const methodInstance = contract.methods.qwe( + const newContract = new Contract(newAbi); + const methodInstance = newContract.methods.qwe( [ Buffer.from($c(24, (i) => i)), { value: 'dead', align: 'left' }, @@ -110,7 +110,7 @@ describe('Method', () => { describe('broadcast', () => { it('successful', async () => { const res = await contract.methods.setVariable(123) - .broadcast({ privateKey: privateKey, registrar: accountId }); + .broadcast({ privateKey, registrar: accountId }); deepStrictEqual(new Set(Object.keys(res.contractResult)), new Set(['exec_res', 'tr_receipt'])); ok(BigNumber.isBigNumber(res.decodedResult)); ok(res.decodedResult.eq(123)); @@ -121,7 +121,7 @@ describe('Method', () => { new Set(Object.keys(res.transactionResult[0])), new Set(['id', 'block_num', 'trx_num', 'trx']), ); - ok(await contract.methods.getVariable().call().then((/** @type {BigNumber} */res) => res.eq(123))); + ok(await contract.methods.getVariable().call().then((/** @type {BigNumber} */result) => result.eq(123))); }).timeout(10e3); }); }); diff --git a/test/contract/decoders/_bitsCount.test.js b/test/contract/decoders/_bitsCount.test.js index c3c87235..ff151231 100644 --- a/test/contract/decoders/_bitsCount.test.js +++ b/test/contract/decoders/_bitsCount.test.js @@ -7,4 +7,4 @@ const bitsCountTest = [ { test: 'bits count is not divisible to 8', bitsCount: 7 }, ]; -export default bitsCountTest; \ No newline at end of file +export default bitsCountTest; diff --git a/test/contract/decoders/dynamic-array.test.js b/test/contract/decoders/dynamic-array.test.js index 32f4c54d..f0667602 100644 --- a/test/contract/decoders/dynamic-array.test.js +++ b/test/contract/decoders/dynamic-array.test.js @@ -1,8 +1,8 @@ import 'mocha'; +import BigNumber from 'bignumber.js'; import { deepStrictEqual, ok, strictEqual } from 'assert'; import { expect } from 'chai'; import decode from '../../../src/contract/decoders'; -import BigNumber from 'bignumber.js'; describe('dynamic array', () => { it('invalid offset', () => { @@ -30,7 +30,7 @@ describe('dynamic array', () => { '46273189767272440134904293994423341371457811516773246020914698249784488817547', '103484385753905248778390947944422951340612094383824644796051262783048805749501', ]; - for (let i = 0; i < res.length; i++) { + for (let i = 0; i < res.length; i += 1) { const element = res[i]; ok(BigNumber.isBigNumber(element)); ok(element.eq(expectedResults[i])); diff --git a/test/contract/decoders/dynamic-bytes-decoder.test.js b/test/contract/decoders/dynamic-bytes-decoder.test.js index 2a2019b0..39d6687d 100644 --- a/test/contract/decoders/dynamic-bytes-decoder.test.js +++ b/test/contract/decoders/dynamic-bytes-decoder.test.js @@ -1,8 +1,8 @@ import 'mocha'; import { ok, strictEqual } from 'assert'; import { expect } from 'chai'; -import decode from '../../../src/contract/decoders'; import BigNumber from 'bignumber.js'; +import decode from '../../../src/contract/decoders'; describe('dynamic bytes', () => { describe('failure', () => { diff --git a/test/contract/decoders/signed-integer-decoder.test.js b/test/contract/decoders/signed-integer-decoder.test.js index 5fce98f1..97a7f0ce 100644 --- a/test/contract/decoders/signed-integer-decoder.test.js +++ b/test/contract/decoders/signed-integer-decoder.test.js @@ -2,10 +2,10 @@ import 'mocha'; import { ok, strictEqual } from 'assert'; import BigNumber from 'bignumber.js'; import { expect } from 'chai'; -import { decodeSignedInteger } from '../../../src/contract/decoders'; +import decode, { decodeSignedInteger } from '../../../src/contract/decoders'; import bitsCountTests from './_bitsCount.test'; import valueTests from './_value.test'; -import decode from '../../../src/contract/decoders'; + describe('signed integer', () => { describe('failure', () => { diff --git a/test/contract/decoders/static-array-decoder.test.js b/test/contract/decoders/static-array-decoder.test.js index 7aeb39c1..83e5b652 100644 --- a/test/contract/decoders/static-array-decoder.test.js +++ b/test/contract/decoders/static-array-decoder.test.js @@ -1,5 +1,5 @@ import 'mocha'; describe('static array', () => { - + }); diff --git a/test/contract/decoders/static-bytes-decoder.test.js b/test/contract/decoders/static-bytes-decoder.test.js index 0a452086..0e0c9992 100644 --- a/test/contract/decoders/static-bytes-decoder.test.js +++ b/test/contract/decoders/static-bytes-decoder.test.js @@ -1,7 +1,7 @@ import 'mocha'; import { expect } from 'chai'; -import decode, { decodeStaticBytes } from '../../../src/contract/decoders'; import { ok, strictEqual } from 'assert'; +import decode, { decodeStaticBytes } from '../../../src/contract/decoders'; import bytesCountTest from '../_bytesCount.test'; describe('static bytes', () => { diff --git a/test/contract/decoders/string-decoder.test.js b/test/contract/decoders/string-decoder.test.js index 4e76864a..1db97903 100644 --- a/test/contract/decoders/string-decoder.test.js +++ b/test/contract/decoders/string-decoder.test.js @@ -1,8 +1,8 @@ import 'mocha'; import { expect } from 'chai'; -import decode from '../../../src/contract/decoders'; import { ok, strictEqual } from 'assert'; import BigNumber from 'bignumber.js'; +import decode from '../../../src/contract/decoders'; describe('string', () => { describe('failure', () => { diff --git a/test/contract/decoders/unsigned-integer-decoder.test.js b/test/contract/decoders/unsigned-integer-decoder.test.js index 0f180047..8ca422e6 100644 --- a/test/contract/decoders/unsigned-integer-decoder.test.js +++ b/test/contract/decoders/unsigned-integer-decoder.test.js @@ -1,9 +1,9 @@ import { ok, strictEqual } from 'assert'; import { expect } from 'chai'; +import BigNumber from 'bignumber.js'; import { decodeUnsignedInteger } from '../../../src/contract/decoders'; import bitsCountTests from './_bitsCount.test'; import valueTests from './_value.test'; -import BigNumber from 'bignumber.js'; describe('unsigned integer', () => { describe('failure', () => { diff --git a/test/contract/deploying.test.js b/test/contract/deploying.test.js index 97313092..61b2217e 100644 --- a/test/contract/deploying.test.js +++ b/test/contract/deploying.test.js @@ -1,8 +1,8 @@ import BigNumber from 'bignumber.js'; -import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; -import { Echo } from '../../'; -import { Contract } from '../../'; import { ok, strictEqual } from 'assert'; +import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; +import { Echo, Contract } from '../../'; + import { url, privateKey, accountId } from '../_test-data'; import { abi, bytecode as code } from '../operations/_contract.test'; /** @@ -14,16 +14,16 @@ function isContractId(id) { } describe('deploy', () => { - let echo = new Echo(); + const echo = new Echo(); before(async function () { // eslint-disable-next-line no-invalid-this this.timeout(10e3); - await echo.connect(url) + await echo.connect(url); }); it('successful (without abi)', async () => { - const res = await Contract.deploy(code, privateKey, { echo, accountId }); + const res = await Contract.deploy(code, privateKey, { echo, accountId }); strictEqual(typeof res, 'string', 'invalid result type'); ok(isContractId(res), 'invalid result format'); }).timeout(10e3); @@ -42,6 +42,6 @@ describe('deploy', () => { }).timeout(10e3); it('value is BigNumber', async () => { - await Contract.deploy(code, privateKey, { echo, accountId, value: { amount: new BigNumber(0) } }); + await Contract.deploy(code, privateKey, { echo, accountId, value: { amount: new BigNumber(0) } }); }).timeout(10e3); }); diff --git a/test/contract/encoders/default-encoder.test.js b/test/contract/encoders/default-encoder.test.js index 3df06de6..dbb52e82 100644 --- a/test/contract/encoders/default-encoder.test.js +++ b/test/contract/encoders/default-encoder.test.js @@ -152,22 +152,28 @@ describe('encode', () => { }); describe('static bytes', () => { - for (const { test, type, value, error } of [ - { test: 'not a hex string', type: 'bytes10', value: 'qwe', error: 'input is not a hex string' }, - { test: 'large input', type: 'bytes2', value: '0x012345', error: 'input is too large' }, - { - test: 'short input', - type: 'bytes3', - value: '0x0123', - error: 'input is too short, maybe u need to use align?', - }, - { - test: 'unknown align', - type: 'bytes3', - value: { value: '0x12', align: 'qwe' }, - error: 'unknown align', - }, - ]) it(test, () => expect(() => encode({ type, value })).to.throw(Error, error)); + for (const { + test, type, value, error, + } of [ + { + test: 'not a hex string', type: 'bytes10', value: 'qwe', error: 'input is not a hex string', + }, + { + test: 'large input', type: 'bytes2', value: '0x012345', error: 'input is too large', + }, + { + test: 'short input', + type: 'bytes3', + value: '0x0123', + error: 'input is too short, maybe u need to use align?', + }, + { + test: 'unknown align', + type: 'bytes3', + value: { value: '0x12', align: 'qwe' }, + error: 'unknown align', + }, + ]) it(test, () => expect(() => encode({ type, value })).to.throw(Error, error)); describe('invalid bytes count', () => { for (const { test, bytesCount, error } of [ diff --git a/test/contract/encoders/integers-encoders.test.js b/test/contract/encoders/integers-encoders.test.js index 87755c9d..29dc5635 100644 --- a/test/contract/encoders/integers-encoders.test.js +++ b/test/contract/encoders/integers-encoders.test.js @@ -5,8 +5,10 @@ describe('encodeIntegers', () => { for (const { test, bitsCount } of [ { test: 'bits count is not a number', bitsCount: 'not_a_number' }, { test: 'bits count is not a integer', bitsCount: 1.23 }, - ]) {it(test, () => { - expect(() => encodeInteger(bitsCount, 123)).to.throw(Error, test); - expect(() => encodeUnsignedInteger(bitsCount, 123)).to.throw(Error, test); - });} + ]) { + it(test, () => { + expect(() => encodeInteger(bitsCount, 123)).to.throw(Error, test); + expect(() => encodeUnsignedInteger(bitsCount, 123)).to.throw(Error, test); + }); + } }); diff --git a/test/contract/utils/number-representations.test.js b/test/contract/utils/number-representations.test.js index 7f3a8445..33102f36 100644 --- a/test/contract/utils/number-representations.test.js +++ b/test/contract/utils/number-representations.test.js @@ -17,9 +17,11 @@ describe('number representations', () => { { test: 'bits count is not a safe integer', bitsCount: Number.MAX_SAFE_INTEGER * 2 }, { test: 'bits count is negative', bitsCount: -12, error: 'bits count is not positive' }, { test: 'bits count is equals to zero', bitsCount: -12, error: 'bits count is not positive' }, - ]) {it(test, () => { - expect(() => toDirectRepresentation(123, bitsCount)).to.throw(Error, error || test); - });} + ]) { + it(test, () => { + expect(() => toDirectRepresentation(123, bitsCount)).to.throw(Error, error || test); + }); + } it('overflow', () => { const value = toTwosPower(8).plus(123); expect(() => toDirectRepresentation(value, 8)).to.throw(Error, 'int8 overflow'); diff --git a/test/crypto/private-key.test.js b/test/crypto/private-key.test.js index 337e110f..7865e66c 100644 --- a/test/crypto/private-key.test.js +++ b/test/crypto/private-key.test.js @@ -1,8 +1,8 @@ import { strictEqual, throws } from 'assert'; -import bs58 from 'bs58' -import ED25519 from '../../src/crypto/ed25519' -import PrivateKey from '../../src/crypto/private-key' -import { ED_PRIVATE, ED_PRIVATE_WITHOUT_PREFIX, WIF } from '../_test-data' +import bs58 from 'bs58'; +import ED25519 from '../../src/crypto/ed25519'; +import PrivateKey from '../../src/crypto/private-key'; +import { ED_PRIVATE, ED_PRIVATE_WITHOUT_PREFIX, WIF } from '../_test-data'; describe('PrivateKey EdDSA', () => { @@ -27,8 +27,6 @@ describe('PrivateKey EdDSA', () => { const edPrivateWithoutPrefixHex = edPrivateWithoutPrefix.toString('hex'); const res = ED25519.keyPairFromPrivateKey(edPrivateWithoutPrefixHex); - const publicKey = `ECHO${bs58.encode(res.publicKey)}`; - const privateKey = `ECHO${bs58.encode(res.privateKey)}`; const prKey = PrivateKey.fromBuffer(res.privateKey); const privateKeyString = prKey.toPrivateKeyString(); @@ -61,7 +59,7 @@ describe('PrivateKey EdDSA', () => { () => { PrivateKey.fromPrivateKeyStringOrThrow('wrong key'); }, - /Expecting key to begin with/ + /Expecting key to begin with/, ); }); diff --git a/test/crypto/utils.test.js b/test/crypto/utils.test.js index c2516677..38e09f50 100644 --- a/test/crypto/utils.test.js +++ b/test/crypto/utils.test.js @@ -1,5 +1,5 @@ import { strictEqual, throws } from 'assert'; -import { utils, PrivateKey, ED25519 } from '../../src/crypto'; +import { utils, PrivateKey } from '../../src/crypto'; import { WIF, WIF2 } from '../_test-data'; describe('Utils', () => { @@ -23,11 +23,15 @@ describe('Utils', () => { }); it('should throw an error when one of the elements in an array is not PrivateKey', async () => { - throws(() => utils.signData(Buffer.from('tst'), ['test']), /one of the elements in an array is not PrivateKey/); + throws(() => utils.signData( + Buffer.from('tst'), + ['test'], + ), /one of the elements in an array is not PrivateKey/); }); it('should return the expected result with one PrivateKey', async () => { + // eslint-disable-next-line max-len const expectedBuffer = '453ac952107e6279d3b31e8e257e010eaf3a36cf17e0a7a3cd24c02c7cbdd6afc155f71d20d4b5d2baef1db0ae9556db7d39ad4e1d0971a3fabcda337ddb7104'; const result = utils.signData(buffer, [privateKey1]); @@ -37,6 +41,7 @@ describe('Utils', () => { it('should return the concatenated result with two PrivateKeys', async () => { + // eslint-disable-next-line max-len const expectedBuffer = '453ac952107e6279d3b31e8e257e010eaf3a36cf17e0a7a3cd24c02c7cbdd6afc155f71d20d4b5d2baef1db0ae9556db7d39ad4e1d0971a3fabcda337ddb7104f41b7a26625a8578ba711cb9ae6956810206acc713d59f35ee751548ee6eab747c6d0d3df9790aece33412da18cd42176a9f0d3e5be3beae23477706db72cd0c'; const result = utils.signData(buffer, [privateKey1, privateKey2]); diff --git a/test/deserializer.test.js b/test/deserializer.test.js index 55b1b71a..d392999e 100644 --- a/test/deserializer.test.js +++ b/test/deserializer.test.js @@ -1,5 +1,5 @@ import { shouldReject } from './_test-utils'; -import { serializers } from '../' +import { serializers } from '../'; describe('deserializer', () => { describe('when first argument is not a buffer', () => { diff --git a/test/deserializer/chain/id/object-id.deserializer.test.js b/test/deserializer/chain/id/object-id.deserializer.test.js index b08e0da0..9e47016f 100644 --- a/test/deserializer/chain/id/object-id.deserializer.test.js +++ b/test/deserializer/chain/id/object-id.deserializer.test.js @@ -2,18 +2,18 @@ import { deepStrictEqual } from 'assert'; import { serializers, constants } from '../../../..'; const { CHAIN_TYPES, PROTOCOL_OBJECT_TYPE_ID } = constants; -const { objectId: objectId_t } = serializers.chain.ids; +const { objectId: objectIdT } = serializers.chain.ids; describe('object id', () => { describe('when should succeed', () => { const input = '1.2.345'; - const accountId_s = objectId_t(CHAIN_TYPES.RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.ACCOUNT); - const buffer = accountId_s.serialize(input); + const accountIdSer = objectIdT(CHAIN_TYPES.RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.ACCOUNT); + const buffer = accountIdSer.serialize(input); /** @type {typeof accountId_s['__TOutput__']} */ let result; let rejects = true; it('should not rejects', () => { - result = accountId_s.deserialize(buffer); + result = accountIdSer.deserialize(buffer); rejects = false; }); it('should returns correct value', function () { diff --git a/test/deserializer/chain/public-key.deserializer.test.js b/test/deserializer/chain/public-key.deserializer.test.js index d3dd93cf..08ef5a7b 100644 --- a/test/deserializer/chain/public-key.deserializer.test.js +++ b/test/deserializer/chain/public-key.deserializer.test.js @@ -2,22 +2,25 @@ import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; import { serializers, PrivateKey } from '../../../'; -const { publicKey: public_key_s } = serializers.chain; +const { publicKey: publicKeySer } = serializers.chain; describe('public key', () => { describe('when small buffer provided', () => { - shouldReject(() => public_key_s.deserialize(Buffer.from([123, 234])), 'unexpected end of buffer'); + shouldReject(() => publicKeySer.deserialize(Buffer.from([123, 234])), 'unexpected end of buffer'); }); describe('when should succeed', () => { const input = PrivateKey.fromSeed('test').toPublicKey(); /** @type {Buffer} */ let buffer; - before(() => buffer = public_key_s.serialize(input)); + before(() => { + buffer = publicKeySer.serialize(input); + return buffer; + }); /** @type {typeof public_key_s['__TOutput__']} */ let result; let rejects = true; it('should not rejects', () => { - result = public_key_s.deserialize(buffer); + result = publicKeySer.deserialize(buffer); rejects = false; }); it('should returns correct value', function () { diff --git a/test/deserializer/collections/static-variant.deserializer.test.js b/test/deserializer/collections/static-variant.deserializer.test.js index 1c3e43cb..98c73262 100644 --- a/test/deserializer/collections/static-variant.deserializer.test.js +++ b/test/deserializer/collections/static-variant.deserializer.test.js @@ -1,13 +1,13 @@ +import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; import { serializers } from '../../../'; -import { deepStrictEqual } from 'assert'; -const static_variant_t = serializers.collections.staticVariant; -const { string: string_s, bool } = serializers.basic; +const staticVariantT = serializers.collections.staticVariant; +const { string: stringSer, bool } = serializers.basic; const { uint32, varint32 } = serializers.basic.integers; describe('static variant', () => { - const s = static_variant_t({ 0: uint32, 1: string_s, 2: bool }); + const s = staticVariantT({ 0: uint32, 1: stringSer, 2: bool }); describe('when invalid key provided', () => { const key = 4; shouldReject(() => s.deserialize(varint32.serialize(key)), `serializer with key ${key} not found`); diff --git a/test/deserializer/collections/struct.deserializer.test.js b/test/deserializer/collections/struct.deserializer.test.js index e36948f0..64dd4af9 100644 --- a/test/deserializer/collections/struct.deserializer.test.js +++ b/test/deserializer/collections/struct.deserializer.test.js @@ -2,13 +2,13 @@ import { deepStrictEqual } from 'assert'; import { serializers } from '../../../'; const { uint32 } = serializers.basic.integers; -const { bool, string: string_s } = serializers.basic; +const { bool, string: stringSer } = serializers.basic; const { struct } = serializers.collections; describe('struct', () => { - const s = struct({ 'qwe': uint32, 'asd': bool, 'zxc': string_s }); + const s = struct({ qwe: uint32, asd: bool, zxc: stringSer }); describe('when should succeed', () => { - const input = { 'qwe': 123, 'asd': false, 'zxc': 'qwerty' }; + const input = { qwe: 123, asd: false, zxc: 'qwerty' }; let result; let rejects = true; it('should not rejects', () => { diff --git a/test/deserializer/operation.deserializer.test.js b/test/deserializer/operation.deserializer.test.js index a63c7d3c..b3d0cca4 100644 --- a/test/deserializer/operation.deserializer.test.js +++ b/test/deserializer/operation.deserializer.test.js @@ -1,7 +1,7 @@ import { deepEqual } from 'assert'; import { serializers } from '../..'; -const { operation: operation_s } = serializers; +const { operation: operationSer } = serializers; describe('operation', () => { describe('when should succeed', () => { @@ -13,12 +13,12 @@ describe('operation', () => { amount: { amount: 234, asset_id: '1.3.9' }, extensions: [], }]; - const buffer = operation_s.serialize(input); + const buffer = operationSer.serialize(input); /** @type {typeof input} */ let result; let rejects = true; it('should not rejects', () => { - result = operation_s.deserialize(buffer); + result = operationSer.deserialize(buffer); rejects = false; }); it('should returns correct value', function () { diff --git a/test/deserializer/vote-id-deserializer.test.js b/test/deserializer/vote-id-deserializer.test.js index 74e3fb02..74e735fe 100644 --- a/test/deserializer/vote-id-deserializer.test.js +++ b/test/deserializer/vote-id-deserializer.test.js @@ -1,17 +1,17 @@ import { strictEqual } from 'assert'; import { serializers } from '../..'; -const { voteId: voteId_s } = serializers.protocol; +const { voteId: voteIdSer } = serializers.protocol; describe('vote id', () => { describe('when should succeed', () => { - const input = '123:456' - const buffer = voteId_s.serialize(input); + const input = '123:456'; + const buffer = voteIdSer.serialize(input); /** @type {typeof voteId_s['__TOutput__']} */ let result; let rejects = true; it('should not rejects', () => { - result = voteId_s.deserialize(buffer); + result = voteIdSer.deserialize(buffer); rejects = false; }); it('should returns correct value', function () { diff --git a/test/main.test.js b/test/main.test.js index 36d6e64f..a3b53c8b 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -1,12 +1,12 @@ -import "@babel/polyfill"; -import { expect } from 'chai'; -import WS from '../src/echo/ws' -import WSAPI from '../src/echo/ws-api' -import Cache from '../src/echo/cache' -import API from '../src/echo/api' - -import { url } from './_test-data'; -import { ACCOUNT, ASSET, } from '../src/constants/object-types'; +// import '@babel/polyfill'; +// import { expect } from 'chai'; +// import WS from '../src/echo/ws'; +// import WSAPI from '../src/echo/ws-api'; +// import Cache from '../src/echo/cache'; +// import API from '../src/echo/api'; +// +// import { url } from './_test-data'; +// import { ACCOUNT, ASSET } from '../src/constants/object-types'; // describe('API', () => { // const ws = new WS(); @@ -42,7 +42,8 @@ import { ACCOUNT, ASSET, } from '../src/constants/object-types'; // const transactionIndex = 0; // const transaction = await api.getTransaction(blockNumber, transactionIndex); -// expect(transaction).to.deep.equal(cache.transactionsByBlockAndIndex.get(`${blockNumber}:${transactionIndex}`)); +// expect(transaction).to.deep +// .equal(cache.transactionsByBlockAndIndex.get(`${blockNumber}:${transactionIndex}`)); // } catch (e) { // throw e; // } diff --git a/test/operations/_contract.test.js b/test/operations/_contract.test.js index d9c07f1a..db644c89 100644 --- a/test/operations/_contract.test.js +++ b/test/operations/_contract.test.js @@ -1,10 +1,11 @@ +// eslint-disable-next-line max-len export const bytecode = '60806040526000805534801561001457600080fd5b506040516020806105168339810180604052810190808051906020019092919050505080600081905550506104c88061004e6000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d14610078578063506ef65c146100b957806386be3f80146100e45780639b96eece14610125578063d0e30db01461017c575b61007561019a565b50005b34801561008457600080fd5b506100a3600480360381019080803590602001909291905050506102a5565b6040518082815260200191505060405180910390f35b3480156100c557600080fd5b506100ce610439565b6040518082815260200191505060405180910390f35b3480156100f057600080fd5b5061010f60048036038101908080359060200190929190505050610442565b6040518082815260200191505060405180910390f35b34801561013157600080fd5b50610166600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610453565b6040518082815260200191505060405180910390f35b61018461019a565b6040518082815260200191505060405180910390f35b60008034111515610213576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260088152602001807f6e6f2076616c756500000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b34600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561035e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f696e73756666696369656e742066756e6473000000000000000000000000000081525060200191505060405180910390fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156103f1573d6000803e3d6000fd5b50600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054905090565b600081600081905550819050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490509190505600a165627a7a72305820ea02f1011dcf74eb605c58e822d1d73678e0a3538dab72ed89ef239138f67ddd0029'; export const abi = [{ inputs: [{ name: '_variable', type: 'uint256' }], payable: false, stateMutability: 'nonpayable', - type: 'constructor' + type: 'constructor', }, { constant: true, inputs: [{ name: '', type: 'address' }], @@ -12,7 +13,7 @@ export const abi = [{ outputs: [{ name: '', type: 'uint256' }], payable: false, stateMutability: 'view', - type: 'function' + type: 'function', }, { constant: true, inputs: [], @@ -20,15 +21,15 @@ export const abi = [{ outputs: [{ name: '', type: 'uint256' }], payable: false, stateMutability: 'view', - type: 'function' + type: 'function', }, { constant: true, inputs: [], name: 'getVariable', - outputs: [{name: '', type: 'uint256'}], + outputs: [{ name: '', type: 'uint256' }], payable: false, stateMutability: 'view', - type: 'function' + type: 'function', }, { constant: false, inputs: [{ name: 'newValue', type: 'uint256' }], @@ -36,7 +37,7 @@ export const abi = [{ outputs: [{ name: '', type: 'uint256' }], payable: false, stateMutability: 'nonpayable', - type: 'function' + type: 'function', }, { constant: false, inputs: [], @@ -44,7 +45,7 @@ export const abi = [{ outputs: [{ name: '', type: 'uint256' }], payable: true, stateMutability: 'payable', - type: 'function' + type: 'function', }, { constant: false, inputs: [{ name: 'value', type: 'uint256' }], @@ -52,5 +53,5 @@ export const abi = [{ outputs: [{ name: '', type: 'uint256' }], payable: false, stateMutability: 'nonpayable', - type: 'function' + type: 'function', }]; diff --git a/test/operations/_testExtensionsField.js b/test/operations/_testExtensionsField.js index 3c6888d8..20ba0363 100644 --- a/test/operations/_testExtensionsField.js +++ b/test/operations/_testExtensionsField.js @@ -1,5 +1,5 @@ -import { privateKey } from "../_test-data"; -import { deepStrictEqual, fail, ok, strictEqual } from "assert"; +import { deepStrictEqual, fail, ok, strictEqual } from 'assert'; +import { privateKey } from '../_test-data'; /** * @param {import("../../types/echo").default} echo @@ -22,14 +22,14 @@ export default function testExtensionsField(echo, operationId, getProps) { .addSigner(privateKey); }); - it('signing should succeed', async () => await transaction.sign()); + it('signing should succeed', async () => transaction.sign()); it('transaction object should contains "extensions" field, that equals to empty array', () => { - const { extensions } = transaction.transactionObject.operations[0][1]; - deepStrictEqual(extensions, []); + const newExtensions = transaction.transactionObject.operations[0][1].extensions; + deepStrictEqual(newExtensions, []); }); - it('broadcasting should succeed', async () => await transaction.broadcast()).timeout(15e3); + it('broadcasting should succeed', async () => transaction.broadcast()).timeout(15e3); }); } diff --git a/test/operations/account-create.operation.test.js b/test/operations/account-create.operation.test.js index 6d0c7fff..498099a7 100644 --- a/test/operations/account-create.operation.test.js +++ b/test/operations/account-create.operation.test.js @@ -1,10 +1,10 @@ -import "mocha"; -import { ok } from "assert"; +import 'mocha'; +import { ok } from 'assert'; -import { Echo, constants, PrivateKey, PublicKey } from "../../"; +import { Echo, constants, PrivateKey } from '../../'; import { ED25519 } from '../../src/crypto'; -import { privateKey, accountId, url } from "../_test-data"; +import { privateKey, accountId, url } from '../_test-data'; import { ACCOUNT } from '../../src/constants/object-types'; const { OPERATIONS_IDS } = constants; @@ -35,17 +35,17 @@ describe('account create operation', () => { key_auths: [[ publicKey, 1, - ]] + ]], }, echorand_key: publicKey, options: { - delegating_account: `1.${ACCOUNT}.3`, + delegating_account: `1.${ACCOUNT}.3`, delegate_share: 0, }, extensions: [], }) .addSigner(privateKey).broadcast(); - + ok(result instanceof Array); ok(!!result[0].id); diff --git a/test/operations/account-update.operations.test.js b/test/operations/account-update.operations.test.js index 270c4d27..86724dc0 100644 --- a/test/operations/account-update.operations.test.js +++ b/test/operations/account-update.operations.test.js @@ -1,9 +1,9 @@ import 'mocha'; +import { fail, ok, strictEqual } from 'assert'; -import { constants, Echo, PublicKey, OPERATIONS_IDS } from '../../'; +import { constants, Echo, OPERATIONS_IDS } from '../../'; import { privateKey, accountId, url } from '../_test-data'; -import { fail, ok, strictEqual } from 'assert'; import { ASSET } from '../../src/constants/object-types'; @@ -18,7 +18,7 @@ describe('account update', () => { describe('account update', () => { it('successful', async () => { - const result = await echo.createTransaction() + await echo.createTransaction() .addOperation(constants.OPERATIONS_IDS.ACCOUNT_UPDATE, { fee: { asset_id: `1.${ASSET}.0` }, account: accountId, @@ -28,7 +28,7 @@ describe('account update', () => { account_auths: [], key_auths: [[ privateKey.toPublicKey().toString(), - 1 + 1, ]], }, }) diff --git a/test/operations/asset-issue.test.js b/test/operations/asset-issue.test.js index b36ce1a3..544ac0f0 100644 --- a/test/operations/asset-issue.test.js +++ b/test/operations/asset-issue.test.js @@ -1,7 +1,8 @@ +import { strictEqual } from 'assert'; import { url, accountId, privateKey } from '../_test-data'; import { Echo, OPERATIONS_IDS, constants } from '../../'; import { getRandomAssetSymbol } from '../_test-utils'; -import { strictEqual } from 'assert'; + /** @typedef {ReturnType} Transaction */ @@ -29,9 +30,10 @@ describe('asset issue', () => { blacklist_authorities: [], description: '', }, - }).addSigner(privateKey).broadcast().then((txRes) => txRes[0].trx.operation_results[0][1]); + }).addSigner(privateKey).broadcast() + .then((txRes) => txRes[0].trx.operation_results[0][1]); }); - after(async () => await echo.disconnect()); + after(async () => echo.disconnect()); describe('when should succeed', () => { const value = 123; /** @type {Transaction} */ diff --git a/test/operations/balance-freeze.operation.test.js b/test/operations/balance-freeze.operation.test.js index 2b31051a..d9ddc3f9 100644 --- a/test/operations/balance-freeze.operation.test.js +++ b/test/operations/balance-freeze.operation.test.js @@ -3,7 +3,7 @@ import { ok } from 'assert'; import { Echo, constants } from '../../'; import { privateKey, accountId, url } from '../_test-data'; -import { ASSET} from '../../src/constants/object-types'; +import { ASSET } from '../../src/constants/object-types'; const echo = new Echo(); @@ -18,13 +18,13 @@ describe('balance freeze operation', () => { it('should not rejects and returns correct value', async () => { const duration = 90; - const transaction = echo.createTransaction(); + const transaction = echo.createTransaction(); - transaction.addOperation(constants.OPERATIONS_IDS.BALANCE_FREEZE, { + transaction.addOperation(constants.OPERATIONS_IDS.BALANCE_FREEZE, { account: accountId, amount: { asset_id: `1.${ASSET}.0`, - amount: 1000 + amount: 1000, }, duration, }); @@ -32,12 +32,12 @@ describe('balance freeze operation', () => { transaction.addSigner(privateKey); const result = await transaction.broadcast(); - + ok(result[0].trx.operations[0][0] === constants.OPERATIONS_IDS.BALANCE_FREEZE); ok(result[0].trx.operations[0][1].account === accountId); ok(result[0].trx.operations[0][1].duration === duration); }).timeout(50000); }); - + }); diff --git a/test/operations/call-contract.operation.test.js b/test/operations/call-contract.operation.test.js index 58e9bccb..3a4d4401 100644 --- a/test/operations/call-contract.operation.test.js +++ b/test/operations/call-contract.operation.test.js @@ -26,7 +26,7 @@ describe('call contract', () => { // asset_id: '1.3.0', // amount: 0, // }, - // code: '86be3f80' + '0000000000000000000000000000000000000000000000000000000000000001', // setVariable(uint256) + // code: '86be3f80' + '0000000000000000000000000000000000000000000000000000000000000001', // callee: options.contractAddress, // }) // .addSigner(privateKey) diff --git a/test/operations/create-asset.operation.test.js b/test/operations/create-asset.operation.test.js index 8dd045ba..d5062a3c 100644 --- a/test/operations/create-asset.operation.test.js +++ b/test/operations/create-asset.operation.test.js @@ -7,8 +7,8 @@ import testExtensionsField from './_testExtensionsField'; describe('create asset', () => { const echo = new Echo(); - before(async () => await echo.connect(url)); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url)); + after(async () => echo.disconnect()); describe('when "bitasset_opts" field is not provided', () => { /** @type {import("../../types/echo/transaction").default} */ @@ -33,9 +33,8 @@ describe('create asset', () => { bitasset_opts: undefined, }).addSigner(privateKey); }); - let result; it('transaction broadcasting should not rejects', async () => { - result = await tx.broadcast(); + await tx.broadcast(); }).timeout(15e3); }); diff --git a/test/operations/create-contract.operation.test.js b/test/operations/create-contract.operation.test.js index c86e0fbc..d82db63f 100644 --- a/test/operations/create-contract.operation.test.js +++ b/test/operations/create-contract.operation.test.js @@ -1,12 +1,12 @@ import 'mocha'; -import { ok } from 'assert'; +// import { ok } from 'assert'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url } from '../_test-data'; import { Echo, constants } from '../../'; +import { ECHO_ASSET_ID } from '../../src/constants'; +// import { OPERATION_HISTORY } from '../../src/constants/object-types'; const { OPERATIONS_IDS } = constants; -import { ECHO_ASSET_ID } from '../../src/constants'; -import { OPERATION_HISTORY } from '../../src/constants/object-types'; /** @type {{contractAddress:string|null, netAddress:string, startValue:string}} */ const options = { contractAddress: null, @@ -30,18 +30,18 @@ describe('create contract', () => { registrar: accountId, value: { asset_id: ECHO_ASSET_ID, - amount: 0 + amount: 0, }, }); await tx.sign(privateKey); /** @type {string} */ - const operationResultId = await tx.broadcast() + /* const operationResultId = */await tx.broadcast() .then((res) => res[0].trx.operation_results[0][1]); // TODO Should be fixed // const newAddress = await echo.api.getContractResult(operationResultId, true) - // .then((res) => res[1].exec_res.new_address) - // .catch((e) => console.log(e)); + // .then((res) => res[1].exec_res.new_address) + // .catch((e) => console.log(e)); // console.log(newAddress); // const contractId = `1.${OPERATION_HISTORY}.${parseInt(newAddress.slice(2), 16)}`; @@ -54,5 +54,3 @@ describe('create contract', () => { }).timeout(15e3); }); - -export { options }; diff --git a/test/operations/create-proposal.operation.test.js b/test/operations/create-proposal.operation.test.js index ef0dd48a..d2e92e7e 100644 --- a/test/operations/create-proposal.operation.test.js +++ b/test/operations/create-proposal.operation.test.js @@ -1,12 +1,12 @@ -import { Echo, OPERATIONS_IDS } from "../../src"; -import { url, accountId } from "../_test-data"; -import { fail, ok, strictEqual } from "assert"; -import { ECHO_ASSET_ID } from "../../src/constants"; +import { fail, ok, strictEqual } from 'assert'; +import { Echo, OPERATIONS_IDS } from '../../src'; +import { url, accountId } from '../_test-data'; +import { ECHO_ASSET_ID } from '../../src/constants'; describe('create proposal', () => { const echo = new Echo(); - before(async () => await echo.connect(url)); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url)); + after(async () => echo.disconnect()); describe('when element of "proposed_ops" field is not an object', () => { /** @type {Error} */ diff --git a/test/operations/disconnect-and-cache-renewing.operation.test.js b/test/operations/disconnect-and-cache-renewing.operation.test.js index 6c314001..25bd00ce 100644 --- a/test/operations/disconnect-and-cache-renewing.operation.test.js +++ b/test/operations/disconnect-and-cache-renewing.operation.test.js @@ -1,8 +1,8 @@ import 'mocha'; +import { expect } from 'chai'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url, contractId } from '../_test-data'; import { Echo, constants } from '../../'; -import { expect } from 'chai'; const { OPERATIONS_IDS } = constants; @@ -27,7 +27,7 @@ describe('error while disconnecting and updating cache', () => { registrar: accountId, value: { asset_id: '1.3.0', - amount: 0 + amount: 0, }, }); await tx.sign(privateKey); @@ -43,24 +43,24 @@ describe('error while disconnecting and updating cache', () => { describe('isAccountStatisticsId', () => { it('connection closed during get full accounts callbacks from history', async () => { try { - await echo.subscriber.setAccountSubscribe(() => {}, [accountId]); - await echo.createTransaction() - .addOperation(constants.OPERATIONS_IDS.ACCOUNT_UPDATE, { - fee: { asset_id: '1.3.0' }, - account: accountId, - echorand_key: privateKey.toPublicKey() - .toString(), - active: { - weight_threshold: 1, - account_auths: [], - key_auths: [[ privateKey.toPublicKey().toString(), 1 ]], - }, - }) - .addSigner(privateKey) - .broadcast(); + await echo.subscriber.setAccountSubscribe(() => {}, [accountId]); + await echo.createTransaction() + .addOperation(constants.OPERATIONS_IDS.ACCOUNT_UPDATE, { + fee: { asset_id: '1.3.0' }, + account: accountId, + echorand_key: privateKey.toPublicKey() + .toString(), + active: { + weight_threshold: 1, + account_auths: [], + key_auths: [[privateKey.toPublicKey().toString(), 1]], + }, + }) + .addSigner(privateKey) + .broadcast(); - await echo.subscriber._api.getFullAccounts([accountId], true, true); - await echo.disconnect(); + await echo.subscriber._api.getFullAccounts([accountId], true, true); + await echo.disconnect(); } catch (err) { expect(err.message).to.equal('Websocket is closed'); } @@ -68,5 +68,3 @@ describe('error while disconnecting and updating cache', () => { }); }); - -export { options }; diff --git a/test/operations/non-default-fee-asset.test.js b/test/operations/non-default-fee-asset.test.js index 98e2538a..0e93ff27 100644 --- a/test/operations/non-default-fee-asset.test.js +++ b/test/operations/non-default-fee-asset.test.js @@ -1,13 +1,13 @@ -import { Echo, OPERATIONS_IDS } from "../.."; -import { accountId, privateKey, url } from "../_test-data"; -import { getRandomAssetSymbol } from "../_test-utils"; -import { ok } from "assert"; +import { ok } from 'assert'; +import { Echo, OPERATIONS_IDS } from '../..'; +import { accountId, privateKey, url } from '../_test-data'; +import { getRandomAssetSymbol } from '../_test-utils'; /** * @typedef {import("../..")["serializers"]["protocol"]["asset"]["issue"]["__TOutput__"]} RawAssetIssueOperationProps */ -describe("Non default fee asset", () => { +describe('Non default fee asset', () => { const echo = new Echo(); /** @type {string} */ let assetId; @@ -19,10 +19,10 @@ describe("Non default fee asset", () => { common_options: { blacklist_authorities: [], core_exchange_rate: { - base: { asset_id: "1.3.0", amount: 10 }, - quote: { asset_id: "1.3.1", amount: 1 }, + base: { asset_id: '1.3.0', amount: 10 }, + quote: { asset_id: '1.3.1', amount: 1 }, }, - description: "", + description: '', extensions: [], flags: 0, issuer_permissions: 79, @@ -35,7 +35,8 @@ describe("Non default fee asset", () => { precision: 4, symbol: getRandomAssetSymbol(), }).addSigner(privateKey).broadcast(); - assetId = assetCreationRes[0].trx.operation_results[0][1]; + const { 1: chosenAssetId } = assetCreationRes[0].trx.operation_results[0]; + assetId = chosenAssetId; await echo.createTransaction().addOperation(OPERATIONS_IDS.ASSET_ISSUE, { asset_to_issue: { asset_id: assetId, amount: 1e5 }, extensions: [], @@ -44,11 +45,14 @@ describe("Non default fee asset", () => { issuer: accountId, }).addSigner(privateKey).broadcast(); }); - describe("when should succeed", () => { + describe('when should succeed', () => { /** @type {ReturnType} */ let tx; - before(() => tx = echo.createTransaction()); - it("creating operation should not rejects", () => { + before(() => { + tx = echo.createTransaction(); + return tx; + }); + it('creating operation should not rejects', () => { tx.addOperation(OPERATIONS_IDS.ASSET_ISSUE, { asset_to_issue: { asset_id: assetId, amount: 1e5 }, extensions: [], @@ -57,22 +61,23 @@ describe("Non default fee asset", () => { issuer: accountId, }); }); - it("required fees calculation should not rejects", async () => await tx.setRequiredFees()); + it('required fees calculation should not rejects', async () => tx.setRequiredFees()); /** @type {RawAssetIssueOperationProps} */ let operationProps; - it("transaction should contains operation", () => { + it('transaction should contains operation', () => { ok(tx.operations.length > 0); - operationProps = tx.operations[0][1]; + const [, txOperationProps] = tx.operations[0]; + operationProps = txOperationProps; }); - it("operation fee asset id should be equals to provided asset id", function () { + it('operation fee asset id should be equals to provided asset id', function () { if (operationProps === undefined) this.skip(); else ok(operationProps.fee.asset_id === assetId); - }) - it("calculated fee should not been equals to 0", function () { + }); + it('calculated fee should not been equals to 0', function () { if (operationProps === undefined) this.skip(); - else ok(operationProps.fee.amount !== "0"); + else ok(operationProps.fee.amount !== '0'); }); - it("transaction signing should not rejects", async () => await tx.sign(privateKey)); - it("transaction broadcasting should not rejects", async () => await tx.broadcast()).timeout(15e3); + it('transaction signing should not rejects', async () => tx.sign(privateKey)); + it('transaction broadcasting should not rejects', async () => tx.broadcast()).timeout(15e3); }); }); diff --git a/test/operations/sidechain.btc.operations.test.js b/test/operations/sidechain.btc.operations.test.js index 257fa7bf..99308df4 100644 --- a/test/operations/sidechain.btc.operations.test.js +++ b/test/operations/sidechain.btc.operations.test.js @@ -10,7 +10,7 @@ describe('sidechain btc', () => { after(() => echo.disconnect()); - let btcAddressId; + let btcAddressId; describe.skip('when we broadcast SIDECHAIN_BTC_CREATE_ADDRESS operation', () => { it('should create address', async () => { @@ -18,15 +18,16 @@ describe('sidechain btc', () => { const transaction = echo.createTransaction(); transaction.addOperation(constants.OPERATIONS_IDS.SIDECHAIN_BTC_CREATE_ADDRESS, { - account: accountId, - backup_address: 'msrvud1myzB5gpFds8riorVR87kpr1Ga7k', + account: accountId, + backup_address: 'msrvud1myzB5gpFds8riorVR87kpr1Ga7k', }); transaction.addSigner(privateKey); - const result = await transaction.broadcast(); - btcAddressId = result[0].trx.operation_results[0][1]; - + const result = await transaction.broadcast(); + const [, AddressId] = result[0].trx.operation_results[0]; + btcAddressId = AddressId; + }).timeout(50000); }); @@ -34,7 +35,7 @@ describe('sidechain btc', () => { it('should create intermediate deposit', async () => { const txInfo = { - block_number: 10, + block_number: 10, out: { tx_id: '4ce18f49ba153a51bcda9bb80d7f978e3de6e81b5fc326f00465464530c052f4', index: 10, @@ -56,7 +57,7 @@ describe('sidechain btc', () => { await transaction.broadcast(); }).timeout(50000); - }) + }); describe.skip('when we broadcast SIDECHAIN_BTC_DEPOSIT operation', () => { it('should create deposit', async () => { @@ -73,9 +74,9 @@ describe('sidechain btc', () => { transaction.addOperation(constants.OPERATIONS_IDS.SIDECHAIN_BTC_DEPOSIT, { committee_member_id: accountId, - account: accountId, + account: accountId, intermediate_deposit_id: `1.${BTC_INTERMEDIATE_DEPOSIT}.0`, - tx_info: txInfo + tx_info: txInfo, }); transaction.addSigner(privateKey); @@ -98,24 +99,24 @@ describe('sidechain btc', () => { committee_member_id: '1.2.10', deposits, withdrawals, - transaction_id: '2d94683fa2f8aaae4a6f377d93b875f680adf96b9c3e9577554b742f412fa9ad', //TODO + transaction_id: '2d94683fa2f8aaae4a6f377d93b875f680adf96b9c3e9577554b742f412fa9ad', // TODO aggregation_out_value: 1000, sma_address: { - address: 'msrvud1myzB5gpFds8riorVR87kpr1Ga7k' + address: 'msrvud1myzB5gpFds8riorVR87kpr1Ga7k', }, committee_member_ids_in_script: committeeMemberIdsInScript, cpfp_depth: 0, - signatures + signatures, }); transaction.addSigner(privateKey); await rejects( - async () => await transaction.broadcast(), + async () => transaction.broadcast(), { message: 'Assert Exception: sma_out > fee: ', - } - ); + }, + ); }).timeout(50000); }); diff --git a/test/operations/transfer.operation.test.js b/test/operations/transfer.operation.test.js index 4d8a3c4c..bcb6d1d4 100644 --- a/test/operations/transfer.operation.test.js +++ b/test/operations/transfer.operation.test.js @@ -4,7 +4,7 @@ import { Echo, constants, serializers } from '../../'; import { privateKey, accountId, url } from '../_test-data'; import testExtensionsField from './_testExtensionsField'; -import { ACCOUNT, ASSET} from '../../src/constants/object-types'; +import { ACCOUNT, ASSET } from '../../src/constants/object-types'; import { operation } from '../../src/serializers'; const { OPERATIONS_IDS } = constants; @@ -25,7 +25,7 @@ describe('transfer', () => { to: `1.${ACCOUNT}.9`, amount: { asset_id: `1.${ASSET}.0`, - amount: 1 + amount: 1, }, }); @@ -41,13 +41,13 @@ describe('transfer', () => { operation.toRaw([OPERATIONS_IDS.TRANSFER, { fee: { asset_id: `1.${ASSET}.1`, - amount: 20 + amount: 20, }, from: `1.${ACCOUNT}.123`, to: `1.${ACCOUNT}.456`, amount: { asset_id: `1.${ASSET}.2`, - amount: 30 + amount: 30, }, }], true); }); @@ -59,13 +59,13 @@ describe('transfer', () => { // FIXME: remove optional fee fee: { asset_id: `1.${ASSET}.1`, - amount: 20 + amount: 20, }, from: `1.${ACCOUNT}.123`, to: `1.${ACCOUNT}.456`, amount: { asset_id: `1.${ASSET}.2`, - amount: 30 + amount: 30, }, }; const result = serializers.protocol.transfer.default.serialize(txProps); diff --git a/test/operations/update-asset-feed-producers.test.js b/test/operations/update-asset-feed-producers.test.js index c9d0ab86..d5829e55 100644 --- a/test/operations/update-asset-feed-producers.test.js +++ b/test/operations/update-asset-feed-producers.test.js @@ -1,12 +1,12 @@ -import { Echo } from "../../src"; -import { url, accountId } from "../_test-data"; -import { OPERATIONS_IDS } from "../../src/constants"; -import { fail, ok, strictEqual } from "assert"; +import { fail, ok, strictEqual } from 'assert'; +import { Echo } from '../../src'; +import { url, accountId } from '../_test-data'; +import { OPERATIONS_IDS } from '../../src/constants'; describe('update asset feed producers', () => { const echo = new Echo(); - before(async () => await echo.connect(url)); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url)); + after(async () => echo.disconnect()); describe('when element of "new_feed_producers" is not a string', () => { /** @type {Error} */ let serializationError; diff --git a/test/operations/update-committee-member-global-parameters.operation.test.js b/test/operations/update-committee-member-global-parameters.operation.test.js index dc99d090..bc480432 100644 --- a/test/operations/update-committee-member-global-parameters.operation.test.js +++ b/test/operations/update-committee-member-global-parameters.operation.test.js @@ -1,11 +1,11 @@ -import { Echo, OPERATIONS_IDS } from "../../src"; -import { fail, strictEqual, ok } from "assert"; -import { url } from "../_test-data"; +import { fail, strictEqual, ok } from 'assert'; +import { Echo, OPERATIONS_IDS } from '../../src'; +import { url } from '../_test-data'; describe('update committee member global parameters', () => { const echo = new Echo(); - before(async () => await echo.connect(url)); - after(async () => await echo.disconnect()); + before(async () => echo.connect(url)); + after(async () => echo.disconnect()); describe('when fee schedule parameters element value is invalid', () => { /** @type {Error} */ let serializationError; @@ -58,7 +58,7 @@ describe('update committee member global parameters', () => { price: 0, gas_amount: 0, }, - } + }, }); } catch (error) { serializationError = error; diff --git a/test/preparation/preparation.js b/test/preparation/preparation.js index 3f043ca0..4f88c326 100644 --- a/test/preparation/preparation.js +++ b/test/preparation/preparation.js @@ -19,7 +19,7 @@ const prepare = async () => { balance_to_claim: `1.${constants.PROTOCOL_OBJECT_TYPE_ID.BALANCE}.0`, balance_owner_key: privateKey.toPublicKey().toString(), total_claimed: balanceObject.balance, - }).addSigner(privateKey) + }).addSigner(privateKey); console.log('broadcasting claim tx...'); await tx.broadcast(); console.log('claim tx was broadcasted'); @@ -29,6 +29,6 @@ prepare() .then(() => echo.disconnect()) .catch((e) => { console.log(e); - console.log(e.data.stack) + console.log(e.data.stack); throw e; }); diff --git a/test/redux.test.js b/test/redux.test.js index 43ee665d..01cc202a 100644 --- a/test/redux.test.js +++ b/test/redux.test.js @@ -1,175 +1,161 @@ import { expect } from 'chai'; -import { Echo } from '../src'; -import { encode } from 'bs58'; - import { combineReducers, createStore } from 'redux'; +import { Echo } from '../src'; -import cacheReducer from '../src/redux/reducer' +import cacheReducer from '../src/redux/reducer'; import { url } from './_test-data'; import { ACCOUNT } from '../src/constants/object-types'; -const defaultReducer = (state = {}, { type, payload }) => type === 'SET' ? { ...state, ...payload } : state; +const defaultReducer = (state = {}, { type, payload }) => (type === 'SET' ? { ...state, ...payload } : state); describe('redux', () => { - describe(('create reducer'), () => { - it('pass not array and throw caches is invalid', (done) => { - try { - const caches = ''; - cacheReducer(caches); - } catch (err) { - expect(err.message).to.equal('Caches is invalid'); - done(); - } - - }); - - it('pass not string array and throw caches is invalid', (done) => { - try { - const caches = [1]; - cacheReducer(caches); - } catch (err) { - expect(err.message).to.equal('Caches is invalid'); - done(); - } - - }); - - it('pass valid array and return function', () => { - const caches = ['objectsById']; - expect(cacheReducer(caches)).to.be.an('function'); - }); - - it('create store and pass cache reducer', () => { - const caches = ['objectsById']; - - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); - - const state = store.getState(); - - expect(state).to.have.property('cache') - }); - - it('state contain passed params', () => { - const caches = ['objectsById']; - - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); - - const { cache } = store.getState(); - - expect(cache.toJS()).to.have.property('objectsById'); - }); - }) - - describe('update redux', () => { - let echo; - beforeEach(async () => { - echo = new Echo(); - await echo.connect( - url, - { - apis: [ - 'database', - 'network_broadcast', - 'history', - 'registration', - 'asset', - 'login', - 'network_node', - ], - }, - ); - }); - - afterEach( async () => { - await echo.disconnect(); - }); - - it('state doest update when call get account', async () => { - const caches = ['objectsById']; - - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); - - const id = `1.${ACCOUNT}.0`; - - await echo.api.getObjects([id]) - - const { cache } = store.getState(); - - expect(cache.getIn(['objectsById', id])).to.be.an('undefined'); - }); - - it('implement store to cache', async () => { - const caches = ['objectsById']; + describe(('create reducer'), () => { + it('pass not array and throw caches is invalid', (done) => { + try { + const caches = ''; + cacheReducer(caches); + } catch (err) { + expect(err.message).to.equal('Caches is invalid'); + done(); + } + + }); + + it('pass not string array and throw caches is invalid', (done) => { + try { + const caches = [1]; + cacheReducer(caches); + } catch (err) { + expect(err.message).to.equal('Caches is invalid'); + done(); + } + + }); + + it('pass valid array and return function', () => { + const caches = ['objectsById']; + expect(cacheReducer(caches)).to.be.an('function'); + }); + + it('create store and pass cache reducer', () => { + const caches = ['objectsById']; + + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); + + const state = store.getState(); + + expect(state).to.have.property('cache'); + }); + + it('state contain passed params', () => { + const caches = ['objectsById']; + + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); + + const { cache } = store.getState(); + + expect(cache.toJS()).to.have.property('objectsById'); + }); + }); + + describe('update redux', () => { + let echo; + beforeEach(async () => { + echo = new Echo(); + await echo.connect( + url, + { + apis: [ + 'database', + 'network_broadcast', + 'history', + 'registration', + 'asset', + 'login', + 'network_node', + ], + }, + ); + }); + + afterEach(async () => { + await echo.disconnect(); + }); + + it('state doest update when call get account', async () => { + const caches = ['objectsById']; + + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); + + const id = `1.${ACCOUNT}.0`; + + await echo.api.getObjects([id]); + + const { cache } = store.getState(); + + expect(cache.getIn(['objectsById', id])).to.be.an('undefined'); + }); + + it('implement store to cache', async () => { + const caches = ['objectsById']; - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); - echo.syncCacheWithStore(store); + echo.syncCacheWithStore(store); - expect(echo.cache.redux).to.have.property('store', store); - }); + expect(echo.cache.redux).to.have.property('store', store); + }); - it('state does update when call get object', async () => { - const caches = ['objectsById']; + it('state does update when call get object', async () => { + const caches = ['objectsById']; - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); - echo.syncCacheWithStore(store); + echo.syncCacheWithStore(store); - const id = `1.${ACCOUNT}.0`; + const id = `1.${ACCOUNT}.0`; - const account = await echo.api.getObject(id); + const account = await echo.api.getObject(id); - const { cache } = store.getState(); + const { cache } = store.getState(); - expect(cache.getIn(['objectsById', id]).toJS()).to.deep.equal(account); - }); + expect(cache.getIn(['objectsById', id]).toJS()).to.deep.equal(account); + }); - it('state does update after store set', async () => { - const caches = ['objectsById']; + it('state does update after store set', async () => { + const caches = ['objectsById']; - const store = createStore( - combineReducers({ - defaultReducer, - cache: cacheReducer(caches), - }) - ); + const store = createStore(combineReducers({ + defaultReducer, + cache: cacheReducer(caches), + })); - const id = `1.${ACCOUNT}.0`; + const id = `1.${ACCOUNT}.0`; - const account = await echo.api.getObject(id); + const account = await echo.api.getObject(id); - echo.syncCacheWithStore(store); + echo.syncCacheWithStore(store); - const { cache } = store.getState(); + const { cache } = store.getState(); - expect(cache.getIn(['objectsById', id]).toJS()).to.deep.equal(account); - }); - }); + expect(cache.getIn(['objectsById', id]).toJS()).to.deep.equal(account); + }); + }); }); diff --git a/test/subscriber.test.js b/test/subscriber.test.js index 5a0df56e..e1de38a2 100644 --- a/test/subscriber.test.js +++ b/test/subscriber.test.js @@ -15,7 +15,7 @@ describe('SUBSCRIBER', () => { describe('setStatusSubscribe', () => { describe('when invalid status provided', () => { const echo = new Echo(); - shouldReject(async () => await echo.subscriber.setStatusSubscribe('conn', () => {}), 'Invalid status'); + shouldReject(async () => echo.subscriber.setStatusSubscribe('conn', () => {}), 'Invalid status'); }); describe('when subscribed, but not connected', () => { @@ -24,8 +24,8 @@ describe('SUBSCRIBER', () => { let disconnected = false; it('should not rejects', async () => { await Promise.all([ - echo.subscriber.setStatusSubscribe('connect', () => connected = true), - echo.subscriber.setStatusSubscribe('disconnect', () => disconnected = true), + echo.subscriber.setStatusSubscribe('connect', () => { connected = true; }), + echo.subscriber.setStatusSubscribe('disconnect', () => { disconnected = true; }), ]); }); it('should not emits "connect" event', () => ok(!connected)); @@ -35,12 +35,12 @@ describe('SUBSCRIBER', () => { describe('when subscribed on "connect" event', () => { const echo = new Echo(); let connected = false; - after(async () => await echo.disconnect()); + after(async () => echo.disconnect()); it('should not rejects', async () => { - await echo.subscriber.setStatusSubscribe('connect', () => connected = true); + await echo.subscriber.setStatusSubscribe('connect', () => { connected = true; }); }); it('should not emits before connect', () => ok(!connected)); - it('should not rejects on connect', async () => await echo.connect(url)); + it('should not rejects on connect', async () => echo.connect(url)); it('should emits after connect', () => ok(connected)); }); @@ -48,12 +48,12 @@ describe('SUBSCRIBER', () => { const echo = new Echo(); let disconnected = false; it('should not rejects', async () => { - await echo.subscriber.setStatusSubscribe('disconnect', () => disconnected = true); + await echo.subscriber.setStatusSubscribe('disconnect', () => { disconnected = true; }); }); it('should not emits before connect', () => ok(!disconnected)); - it('should not rejects on connect', async () => await echo.connect(url)); + it('should not rejects on connect', async () => echo.connect(url)); it('should not emits after connect', () => ok(!disconnected)); - it('should not rejects on disconnect', async () => await echo.disconnect()); + it('should not rejects on disconnect', async () => echo.disconnect()); it('should emits after disconnect', () => ok(disconnected)); }); @@ -61,7 +61,7 @@ describe('SUBSCRIBER', () => { const echo = new Echo(); const STATUS = { CONNECTED: 'CONNECTED', DISCONNECTED: 'DISCONNECTED' }; const events = []; - after(async () => await echo.disconnect()); + after(async () => echo.disconnect()); it('should not rejects', async () => { await Promise.all([ echo.subscriber.setStatusSubscribe('connect', () => events.push(STATUS.CONNECTED)), @@ -70,9 +70,9 @@ describe('SUBSCRIBER', () => { }); it('should not emits "connect" event before connect', () => ok(!events.includes(STATUS.CONNECTED))); it('should not emits "disconnect" event before connect', () => ok(!events.includes(STATUS.DISCONNECTED))); - it('should not rejects on connect', async () => await echo.connect(url)); + it('should not rejects on connect', async () => echo.connect(url)); it('should emits single event "connect"', () => deepStrictEqual(events, [STATUS.CONNECTED])); - it('should not rejects on reconnect', async () => await echo.reconnect()); + it('should not rejects on reconnect', async () => echo.reconnect()); it('should emits "disconnect" event on reconnect', () => strictEqual(events[1], STATUS.DISCONNECTED)); it('should emits "connect" event after reconnect', () => strictEqual(events[2], STATUS.CONNECTED)); it('should not emits more events', function () { @@ -82,7 +82,7 @@ describe('SUBSCRIBER', () => { }); }); - let echo = new Echo(); + const echo = new Echo(); describe('echorand', () => { describe('setEchorandSubscribe', () => { @@ -99,7 +99,7 @@ describe('SUBSCRIBER', () => { let isCalled = false; let isReconnected = false; - echo.subscriber.setEchorandSubscribe((result) => { + echo.subscriber.setEchorandSubscribe(() => { if (!isCalled && isReconnected) { done(); isCalled = true; @@ -113,7 +113,7 @@ describe('SUBSCRIBER', () => { it('test', async () => { let emitted = false; let onEmit; - const onceEmitted = new Promise((resolve) => onEmit = resolve); + const onceEmitted = new Promise((resolve) => { onEmit = resolve; }); echo.subscriber.setEchorandSubscribe((result) => { expect(result).to.be.an('array').that.is.not.empty; expect(result[0]).to.be.an('object').that.is.not.empty; @@ -179,7 +179,7 @@ describe('SUBSCRIBER', () => { it('test', async () => { let emitted = false; let onInited; - const onceEmitted = new Promise((resolve) => onInited = resolve); + const onceEmitted = new Promise((resolve) => { onInited = resolve; }); echo.subscriber.setBlockApplySubscribe((result) => { expect(result).to.be.an('array').that.is.not.empty; @@ -294,7 +294,7 @@ describe('SUBSCRIBER', () => { it('test', async () => { let emitted = false; let onEmit; - const onceEmitted = new Promise((resolve) => onEmit = resolve); + const onceEmitted = new Promise((resolve) => { onEmit = resolve; }); echo.subscriber.setGlobalSubscribe((result) => { if (result[0] && result[0].id === `2.${IMPLEMENTATION_OBJECT_TYPE_ID.DYNAMIC_GLOBAL_PROPERTY}.0`) { expect(result).to.be.an('array').that.is.not.empty; @@ -344,7 +344,7 @@ describe('SUBSCRIBER', () => { expect(echo.subscriber.subscriptions.transaction).to.be.false; expect(echo.subscriber.subscribers.transaction).to.be.an('array').that.is.empty; - echo.subscriber.setPendingTransactionSubscribe((result) => { + echo.subscriber.setPendingTransactionSubscribe((/* result */) => { // expect(result).to.be.an('array').that.is.not.empty; // expect(result[0]).to.be.an('object').that.is.not.empty; // expect(result[0].type).to.be.a('number'); @@ -396,7 +396,7 @@ describe('SUBSCRIBER', () => { describe.skip('removeStatusSubscribe', () => { - it('status - connect', async () => { + it('status - connect', async () => { const spy = chai.spy(() => {}); const { length } = echo.subscriber.subscribers.connect; diff --git a/test/transaction.test.js b/test/transaction.test.js index 05f06cc7..a8c26a4a 100644 --- a/test/transaction.test.js +++ b/test/transaction.test.js @@ -1,13 +1,13 @@ import 'mocha'; -import { expect } from 'chai'; +// import { expect } from 'chai'; import { Echo } from '../src'; -import Transaction from '../src/echo/transaction'; -import { strictEqual, notStrictEqual, deepStrictEqual, fail, ok } from 'assert'; +// import Transaction from '../src/echo/transaction'; +// import { strictEqual, notStrictEqual, deepStrictEqual, fail, ok } from 'assert'; import { TRANSFER } from '../src/constants/operations-ids'; -import PrivateKey from '../src/crypto/private-key'; +// import PrivateKey from '../src/crypto/private-key'; import { url } from './_test-data'; -import { ACCOUNT, ASSET} from '../src/constants/object-types'; +import { ACCOUNT, ASSET } from '../src/constants/object-types'; const echo = new Echo(); @@ -131,7 +131,7 @@ describe.skip('Transaction', () => { describe('get potential signatures', () => { it('asd', async () => { - const pk = '5KPT6sFAgx8sEiNyuF2QijsNCAPAvs4r6MV9Vn26z4NuTv86mfd'; + // const pk = '5KPT6sFAgx8sEiNyuF2QijsNCAPAvs4r6MV9Vn26z4NuTv86mfd'; const transaction = echo.createTransaction(); transaction.addOperation(TRANSFER, { from: `1.${ACCOUNT}.6`, @@ -140,7 +140,7 @@ describe.skip('Transaction', () => { }); // await transaction.sign(PrivateKey.fromWif(pk)); // console.log(await transaction.broadcast(console.log)); - console.log(await transaction.getPotentialSignatures()); + // console.log(await transaction.getPotentialSignatures()); }).timeout(12e3); }); diff --git a/test/wallet-api.test.js b/test/wallet-api.test.js index 5a9f1b19..8e9cfdf8 100644 --- a/test/wallet-api.test.js +++ b/test/wallet-api.test.js @@ -1,5 +1,6 @@ -import { inspect, promisify } from "util"; +// import { inspect, promisify } from 'util'; import { expect } from 'chai'; +import { ok } from 'assert'; import echo, { constants } from '../src'; @@ -12,8 +13,7 @@ import { WIF, walletURL, } from './_test-data'; -import { ACCOUNT, ASSET, COMMITTEE_MEMBER} from '../src/constants/object-types'; -import { ok } from 'assert'; +import { ACCOUNT, ASSET } from '../src/constants/object-types'; import { API_CONFIG } from '../src/constants'; import { TRANSFER } from '../src/constants/operations-ids'; import PrivateKey from '../src/crypto/private-key'; @@ -53,12 +53,13 @@ describe('WALLET API', () => { }; before(async () => { - await echo.connect(url, + await echo.connect( + url, { connectionTimeout: 10000, - apis: constants.WS_CONSTANTS.CHAIN_APIS, + apis: constants.WS_CONSTANTS.CHAIN_APIS, wallet: walletURL, - } + }, ); await echo.walletApi.setPassword('qwe'); await echo.walletApi.unlock('qwe'); @@ -110,7 +111,7 @@ describe('WALLET API', () => { describe('#networkAddNodes()', () => { it('should add new nodes to network', async () => { - const nodes = ["0.0.0.0:6311", "0.0.0.0:6310"]; + const nodes = ['0.0.0.0:6311', '0.0.0.0:6310']; const result = await echo.walletApi.networkAddNodes(nodes); expect(result) .to @@ -132,14 +133,14 @@ describe('WALLET API', () => { describe('#isNew()', () => { it('should get state of the wallet is it new or no', async () => { const result = await echo.walletApi.isNew(); - ok(!result); + ok(!result); }).timeout(5000); }); describe('#isLocked()', () => { it('should checks state of the wallet locked or unlocked', async () => { const result = await echo.walletApi.isLocked(); - ok(!result); + ok(!result); }).timeout(5000); }); @@ -216,8 +217,11 @@ describe('WALLET API', () => { describe('#importKey()', () => { it('Should imports the private key for an existing account', async () => { - const result = await echo.walletApi.importKey('1.2.11', '5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2'); - ok(result); + const result = await echo.walletApi.importKey( + '1.2.11', + '5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2', + ); + ok(result); }).timeout(5000); }); @@ -226,11 +230,7 @@ describe('WALLET API', () => { try { const filename = 'wallet.cpp'; const password = 'password'; - const result = await echo.walletApi.importAccounts(filename, password); - // expect(result) - // .to - // .be - // .an('boolean'); + await echo.walletApi.importAccounts(filename, password); } catch (e) { throw e; } @@ -333,7 +333,7 @@ describe('WALLET API', () => { it('should determine is key linked to any registered account', async () => { const pubKey = 'ECHOBMZ6kgpeij9zWpAXxQHkRRrQzVf7DmKnX8rQJxBtcMrs'; const result = await echo.walletApi.isPublicKeyRegistered(pubKey); - ok(!result) + ok(!result); }).timeout(5000); }); @@ -346,7 +346,7 @@ describe('WALLET API', () => { to: `1.${ACCOUNT}.7`, amount: { asset_id: constants.ECHO_ASSET_ID, - amount: 1000 + amount: 1000, }, }); await unsignedTr.sign(PrivateKey.fromWif(pk)); @@ -417,7 +417,7 @@ describe('WALLET API', () => { it('should get lists all accounts registered in the blockchain', async () => { const result = await echo.walletApi.listAccounts( accountName, - constants.API_CONFIG.LIST_ACCOUNTS_DEFAULT_LIMIT + constants.API_CONFIG.LIST_ACCOUNTS_DEFAULT_LIMIT, ); expect(result) .to @@ -485,25 +485,23 @@ describe('WALLET API', () => { describe.skip('#registerAccount()', () => { it('should registers an account', async () => { try { - const accountName = 'qweasdety'; + const newAccountName = 'qweasdety'; const privateKey = PrivateKey.fromSeed(Math.random().toString()); const activeKey = privateKey.toPublicKey(); const result = await echo.walletApi.registerAccount( - accountName, + newAccountName, activeKey, accountId, - shouldDoBroadcastToNetwork + shouldDoBroadcastToNetwork, ); - console.log('---------result---------', result); expect(result) .to .be .an('object').that.is.not.empty; - expect(result.name).equal(accountName); + expect(result.name).equal(newAccountName); expect(result.registrar).equal(accountId); expect(result.key_auths[0][0]).equal(activeKey); } catch (e) { - console.error(inspect(e, false, null, true)); throw e; } }).timeout(5000); @@ -511,12 +509,12 @@ describe('WALLET API', () => { describe('#createAccountWithBrainKey()', () => { it('should creates a new account and registers it', async () => { - const accountName = 'ales'; + const newAccountName = 'ales'; const result = await echo.walletApi.createAccountWithBrainKey( brainKey, - accountName, + newAccountName, accountId, - shouldDoBroadcastToNetwork + shouldDoBroadcastToNetwork, ); expect(result) .to @@ -539,8 +537,9 @@ describe('WALLET API', () => { useEthereumAssetAccuracy, shouldSaveToWallet, ); - - contractResultId = result.operation_results[0][1]; + + const [, contractIdOfResult] = result.operation_results[0]; + contractResultId = contractIdOfResult; expect(result) .to .be @@ -551,7 +550,8 @@ describe('WALLET API', () => { describe.skip('#callContract()', () => { it('should call a contract', async () => { try { - const contractCode = '86be3f80' + '0000000000000000000000000000000000000000000000000000000000000001'; + const code = '0000000000000000000000000000000000000000000000000000000000000001'; + const contractCode = '86be3f80'.concat(code); const amount = 1; const shouldSaveToWallet = true; const result = await echo.walletApi.callContract( @@ -713,7 +713,7 @@ describe('WALLET API', () => { it('Should returns the most recent operations on the named account', async () => { const result = await echo.walletApi.getAccountHistory( accountName, - constants.API_CONFIG.ACCOUNT_HISTORY_DEFAULT_LIMIT + constants.API_CONFIG.ACCOUNT_HISTORY_DEFAULT_LIMIT, ); expect(result) .to @@ -788,19 +788,18 @@ describe('WALLET API', () => { describe('#callContractNoChangingState()', () => { it('Should call contract but doesn\'t change the state', async () => { try { - const result = await echo.walletApi.callContractNoChangingState( - contractId, - accountId, - '0', - constants.ECHO_ASSET_ID, - bytecode, - ); - expect(result) - .to - .be - .an('string'); + const result = await echo.walletApi.callContractNoChangingState( + contractId, + accountId, + '0', + constants.ECHO_ASSET_ID, + bytecode, + ); + expect(result) + .to + .be + .an('string'); } catch (erro) { - console.log(JSON.stringify(erro)); throw erro; } }).timeout(5000); @@ -819,7 +818,6 @@ describe('WALLET API', () => { describe.skip('#getContractPoolWhitelist()', () => { it('Should get contract\'s whitelist and blacklist', async () => { const result = await echo.walletApi.getContractPoolWhitelist(contractId); - console.log('result', result); expect(result) .to .be @@ -830,12 +828,7 @@ describe('WALLET API', () => { describe('#getEthAddress()', () => { it('Should returns information about generated eth address', async () => { try { - const result = await echo.walletApi.getEthAddress(accountId); - // expect(result) - // .to - // .be - // .an('object'); - // console.log('result', result); + await echo.walletApi.getEthAddress(accountId); } catch (e) { throw e; } @@ -876,12 +869,7 @@ describe('WALLET API', () => { describe('#getErc20Token()', () => { it('Should returns information about erc20 token', async () => { const ethereumTokenAddress = '9a1348ebe10f1ae4461fcb885d8cba8260757957'; - const result = await echo.walletApi.getErc20Token(ethereumTokenAddress); - // expect(result) - // .to - // .be - // .an('object'); - // console.log('result', result); + await echo.walletApi.getErc20Token(ethereumTokenAddress); }).timeout(5000); }); @@ -933,16 +921,16 @@ describe('WALLET API', () => { describe('#generateAccountAddress()', () => { it('Should generate account address', async () => { - const label = 'label'; - const result = await echo.walletApi.generateAccountAddress( - accountId, - label, - shouldDoBroadcastToNetwork, - ); - expect(result) - .to - .be - .an('object').that.is.not.empty; + const label = 'label'; + const result = await echo.walletApi.generateAccountAddress( + accountId, + label, + shouldDoBroadcastToNetwork, + ); + expect(result) + .to + .be + .an('object').that.is.not.empty; }).timeout(5000); }); @@ -961,12 +949,7 @@ describe('WALLET API', () => { describe('#getAccountByAddress()', () => { it('Should get owner of specified address', async () => { const address = 'f54a5851e9372b87810a8e60cdd2e7cfd80b6e31'; - const result = await echo.walletApi.getAccountByAddress(address); - // expect(result) - // .to - // .be - // .an('string'); - // console.log('result', result); + await echo.walletApi.getAccountByAddress(address); }).timeout(5000); }); @@ -985,24 +968,23 @@ describe('WALLET API', () => { try { const proposalId = '1.5.0'; const delta = { - "active_approvals_to_add": ['1','1'], - "active_approvals_to_remove": ['1','1'], - "owner_approvals_to_add": ['1','1'], - "owner_approvals_to_remove": ['1','1'], - "key_approvals_to_add": ['1','1'], - "key_approvals_to_remove": ['1','1'], + active_approvals_to_add: ['1', '1'], + active_approvals_to_remove: ['1', '1'], + owner_approvals_to_add: ['1', '1'], + owner_approvals_to_remove: ['1', '1'], + key_approvals_to_add: ['1', '1'], + key_approvals_to_remove: ['1', '1'], }; const result = await echo.walletApi.approveProposal( accountId, proposalId, delta, shouldDoBroadcastToNetwork, - ); + ); expect(result) .to .be .an('object'); - console.log('result', result); } catch (e) { throw e; } @@ -1028,7 +1010,7 @@ describe('WALLET API', () => { ethAddress, value, shouldDoBroadcastToNetwork, - ); + ); expect(result) .to .be @@ -1048,18 +1030,18 @@ describe('WALLET API', () => { }).timeout(5000); }); - + describe('#listAssets()', () => { it('Should get lists of all assets registered', async () => { const result = await echo.walletApi.listAssets( constants.ECHO_ASSET_ID, - constants.API_CONFIG.LIST_ASSETS_MAX_LIMIT - ); - expect(result) - .to - .be - .an('array').that.is.not.empty; - expect(result[0]) + constants.API_CONFIG.LIST_ASSETS_MAX_LIMIT, + ); + expect(result) + .to + .be + .an('array').that.is.not.empty; + expect(result[0]); }).timeout(5000); }); @@ -1067,7 +1049,7 @@ describe('WALLET API', () => { it('Should get lists of all assets registered', async () => { const result = await echo.walletApi.listAssets( constants.ECHO_ASSET_ID, - constants.API_CONFIG.LIST_ASSETS_MAX_LIMIT + constants.API_CONFIG.LIST_ASSETS_MAX_LIMIT, ); expect(result) .to @@ -1102,32 +1084,31 @@ describe('WALLET API', () => { describe.skip('#updateAsset()', () => { it('Should update the core options on an asset', async () => { try { - const assetOption = { - "max_supply": 1, - "issuer_permissions": 0, - "flags": 0, - "core_exchange_rate": { - "base": { - "amount": 1, - "asset_id": '1.3.0', + const newAssetOption = { + max_supply: 1, + issuer_permissions: 0, + flags: 0, + core_exchange_rate: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": '1.3.1', + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "whitelist_authorities": [], - "blacklist_authorities": [], - "description": 'description', - "extensions": [], + whitelist_authorities: [], + blacklist_authorities: [], + description: 'description', + extensions: [], }; const result = await echo.walletApi.updateAsset( constants.ECHO_ASSET_ID, accountId, - assetOption, + newAssetOption, shouldDoBroadcastToNetwork, ); - console.log('result', result); expect(result) .to .be @@ -1140,15 +1121,15 @@ describe('WALLET API', () => { describe.skip('#updateBitasset()', () => { it('Should update the options specific to a BitAsset', async () => { - const bitassetOpts = { - feed_lifetime_sec: 1, - minimum_feeds: 2, - short_backing_asset: '1.3.0', - extensions: [], - }; + const newBitassetOpts = { + feed_lifetime_sec: 1, + minimum_feeds: 2, + short_backing_asset: '1.3.0', + extensions: [], + }; const result = await echo.walletApi.updateBitasset( constants.ECHO_ASSET_ID, - bitassetOpts, + newBitassetOpts, shouldDoBroadcastToNetwork, ); expect(result) @@ -1184,39 +1165,39 @@ describe('WALLET API', () => { assetOption, bitassetOpts, shouldDoBroadcastToNetwork, - ); - expect(result) - .to - .be - .an('object').that.is.not.empty; - }).timeout(5000); - }); + ); + expect(result) + .to + .be + .an('object').that.is.not.empty; + }).timeout(5000); + }); describe('#publishAssetFeed()', () => { it('Should publishes a price feed for the named asset', async () => { const priceFeed = { - "settlement_price": { - "base": { - "amount": 1, - "asset_id": "1.3.0", + settlement_price: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": "1.3.1", + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "core_exchange_rate": { - "base": { - "amount": 1, - "asset_id": "1.3.0", + core_exchange_rate: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": "1.3.1", + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "maintenance_collateral_ratio": 32e3, - "maximum_short_squeeze_ratio": 32e3, + maintenance_collateral_ratio: 32e3, + maximum_short_squeeze_ratio: 32e3, }; const result = await echo.walletApi.publishAssetFeed( accountId, @@ -1234,42 +1215,41 @@ describe('WALLET API', () => { describe.skip('#updateAsset()', () => { it('Should update the core options on an asset', async () => { try { - const assetOption = { - "max_supply": 1, - "issuer_permissions": 0, - "flags": 0, - "core_exchange_rate": { - "base": { - "amount": 1, - "asset_id": '1.3.0', + const newAssetOption = { + max_supply: 1, + issuer_permissions: 0, + flags: 0, + core_exchange_rate: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": '1.3.1', + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "whitelist_authorities": [], - "blacklist_authorities": [], - "description": 'description', - "extensions": [], + whitelist_authorities: [], + blacklist_authorities: [], + description: 'description', + extensions: [], }; const result = await echo.walletApi.updateAsset( constants.ECHO_ASSET_ID, accountId, - assetOption, + newAssetOption, shouldDoBroadcastToNetwork, - ); - console.log('result', result); - expect(result) - .to - .be - .an('object'); - } catch (e) { - throw e; - } - }).timeout(5000); - }); - + ); + expect(result) + .to + .be + .an('object'); + } catch (e) { + throw e; + } + }).timeout(5000); + }); + describe.skip('#issueAsset()', () => { it('Should do issue new shares of an asset', async () => { try { @@ -1281,7 +1261,6 @@ describe('WALLET API', () => { assetTicker, shouldDoBroadcastToNetwork, ); - console.log('result', result); expect(result) .to .be @@ -1294,15 +1273,15 @@ describe('WALLET API', () => { describe('#updateBitasset()', () => { it('Should update the options specific to a BitAsset', async () => { - const bitassetOpts = { - feed_lifetime_sec: 1, - minimum_feeds: 2, - short_backing_asset: '1.3.0', - extensions: [], - }; + const newBitassetOpts = { + feed_lifetime_sec: 1, + minimum_feeds: 2, + short_backing_asset: '1.3.0', + extensions: [], + }; const result = await echo.walletApi.updateBitasset( constants.ECHO_ASSET_ID, - bitassetOpts, + newBitassetOpts, shouldDoBroadcastToNetwork, ); expect(result) @@ -1321,9 +1300,9 @@ describe('WALLET API', () => { shouldDoBroadcastToNetwork, ); expect(result) - .to - .be - .an('object').that.is.not.empty; + .to + .be + .an('object').that.is.not.empty; }).timeout(5000); }); @@ -1340,28 +1319,28 @@ describe('WALLET API', () => { describe('#publishAssetFeed()', () => { it('Should publishes a price feed for the named asset', async () => { const priceFeed = { - "settlement_price": { - "base": { - "amount": 1, - "asset_id": "1.3.0", + settlement_price: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": "1.3.1", + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "core_exchange_rate": { - "base": { - "amount": 1, - "asset_id": "1.3.0", + core_exchange_rate: { + base: { + amount: 1, + asset_id: '1.3.0', }, - "quote": { - "amount": 1, - "asset_id": "1.3.1", + quote: { + amount: 1, + asset_id: '1.3.1', }, }, - "maintenance_collateral_ratio": 32e3, - "maximum_short_squeeze_ratio": 32e3, + maintenance_collateral_ratio: 32e3, + maximum_short_squeeze_ratio: 32e3, }; const result = await echo.walletApi.publishAssetFeed( accountId, @@ -1388,9 +1367,9 @@ describe('WALLET API', () => { shouldDoBroadcastToNetwork, ); expect(result) - .to - .be - .an('object'); + .to + .be + .an('object'); } catch (e) { throw e; } @@ -1402,7 +1381,7 @@ describe('WALLET API', () => { try { const symbol = 'TFYS'; const precision = 0; - const check = await echo.walletApi.createAsset( + await echo.walletApi.createAsset( accountId, symbol, precision, @@ -1410,14 +1389,12 @@ describe('WALLET API', () => { bitassetOpts, shouldDoBroadcastToNetwork, ); - console.log('check', check.operations[0][1]); const bitasset = '1.3.0'; const result = await echo.walletApi.getBitassetData(bitasset); expect(result) .to .be .an('object'); - console.log('result', result); } catch (e) { throw e; } @@ -1432,7 +1409,7 @@ describe('WALLET API', () => { constants.ECHO_ASSET_ID, amount, shouldDoBroadcastToNetwork, - ); + ); expect(result) .to .be @@ -1473,7 +1450,7 @@ describe('WALLET API', () => { const result = await echo.walletApi.listCommitteeMembers( lowerBoundName, constants.API_CONFIG.COMMITTEE_MEMBER_ACCOUNTS_DEFAULT_LIMIT, - ); + ); expect(result) .to .be @@ -1508,36 +1485,35 @@ describe('WALLET API', () => { describe.skip('#createCommitteeMember()', () => { it('Should creates a committee_member object owned by the given account', async () => { const newAccountId = '1.2.0'; - const url = ''; + const memberUrl = ''; const amount = '1'; const ethereumAddress = '7234F8149411B8F275373DC470011e18126489B6'; const btcPublicKey = '02c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e'; const result = await echo.walletApi.createCommitteeMember( newAccountId, - url, + memberUrl, amount, ethereumAddress, btcPublicKey, shouldDoBroadcastToNetwork, - ); - expect(result) - .to - .be - .an('object').that.is.not.empty; - }).timeout(5000); + ); + expect(result) + .to + .be + .an('object').that.is.not.empty; + }).timeout(5000); }); describe.skip('#setDesiredCommitteeMemberCount()', () => { it('Should set your vote for the number of committee_members', async () => { try { - const accountName = 'bruno'; - const newAccount = await echo.walletApi.createAccountWithBrainKey( - brainKey, - accountName, - accountId, - shouldDoBroadcastToNetwork - ); - // console.log('---------voting_account---------', newAccount.operations[0][1].options.voting_account); + const newAccountName = 'bruno'; + const newAccount = await echo.walletApi.createAccountWithBrainKey( + brainKey, + newAccountName, + accountId, + shouldDoBroadcastToNetwork, + ); const desiredNumberOfCommitteeMembers = 0; const result = await echo.walletApi.setDesiredCommitteeMemberCount( newAccount.operations[0][1].options.voting_account, @@ -1545,16 +1521,15 @@ describe('WALLET API', () => { shouldDoBroadcastToNetwork, ); expect(result) - .to - .be - .an('object'); - console.log('result', result); + .to + .be + .an('object'); } catch (e) { throw e; } }).timeout(5000); }); - + describe.skip('#proposeParameterChange()', () => { it('Should creates a transaction to propose a parameter change', async () => { try { @@ -1566,12 +1541,10 @@ describe('WALLET API', () => { changedValues, shouldDoBroadcastToNetwork, ); - // console.log('result', result); - expect(result) - .to - .be - .an('object'); - console.log('result', result); + expect(result) + .to + .be + .an('object'); } catch (e) { throw e; } @@ -1595,7 +1568,7 @@ describe('WALLET API', () => { const result = await echo.walletApi.listCommitteeMembers( lowerBoundName, constants.API_CONFIG.COMMITTEE_MEMBER_ACCOUNTS_DEFAULT_LIMIT, - ); + ); expect(result) .to .be @@ -1658,9 +1631,9 @@ describe('WALLET API', () => { it('should returns the 0 for ECHO asset', async () => { const result = await echo.walletApi.committeeWithdrawBalance('1.2.10', '1'); expect(result) - .to - .be - .an('object').that.is.not.empty; + .to + .be + .an('object').that.is.not.empty; }).timeout(5000); }); @@ -1680,7 +1653,6 @@ describe('WALLET API', () => { .to .be .an('object').that.is.not.empty; - console.log('result', result); } catch (e) { throw e; } @@ -1703,7 +1675,6 @@ describe('WALLET API', () => { .to .be .an('object').that.is.not.empty; - console.log('result', result); } catch (e) { throw e; } @@ -1711,17 +1682,16 @@ describe('WALLET API', () => { }); - describe.skip('#changeSidechainConfig()', () => { it('Should change sidechain config', async () => { const changedValues = { - "_time_net_1mb": 1, - "_time_net_256b": 1, - "_creator_count": 1, - "_verifier_count": 1, - "_ok_threshold": 1, - "_max_bba_steps": 1, - "_gc1_delay": 1, + _time_net_1mb: 1, + _time_net_256b: 1, + _creator_count: 1, + _verifier_count: 1, + _ok_threshold: 1, + _max_bba_steps: 1, + _gc1_delay: 1, }; const result = await echo.walletApi.changeSidechainConfig( accountId, @@ -1762,7 +1732,6 @@ describe('WALLET API', () => { .to .be .an('object').that.is.not.empty; - console.log('result', result); } catch (e) { throw e; } @@ -1772,13 +1741,13 @@ describe('WALLET API', () => { describe.skip('#changeSidechainConfig()', () => { it('Should change sidechain config', async () => { const changedValues = { - "_time_net_1mb": 1, - "_time_net_256b": 1, - "_creator_count": 1, - "_verifier_count": 1, - "_ok_threshold": 1, - "_max_bba_steps": 1, - "_gc1_delay": 1, + _time_net_1mb: 1, + _time_net_256b: 1, + _creator_count: 1, + _verifier_count: 1, + _ok_threshold: 1, + _max_bba_steps: 1, + _gc1_delay: 1, }; const result = await echo.walletApi.changeSidechainConfig( accountId, @@ -1828,10 +1797,10 @@ describe('WALLET API', () => { describe('#getGlobalProperties()', () => { it('should returns the number of registered accounts', async () => { const result = await echo.walletApi.getGlobalProperties(); - expect(result) - .to - .be - .an('object').that.is.not.empty; + expect(result) + .to + .be + .an('object').that.is.not.empty; }).timeout(5000); }); @@ -1859,10 +1828,10 @@ describe('WALLET API', () => { }).timeout(5000); }); - + describe('TRANSACTION BUILDER', () => { - beforeEach(async () => await echo.walletApi.beginBuilderTransaction()); + beforeEach(async () => echo.walletApi.beginBuilderTransaction()); describe('#beginBuilderTransaction()', () => { it('should returns number of built transaction', async () => { @@ -1886,7 +1855,7 @@ describe('WALLET API', () => { account_id: accountId, new_owner: '1.2.1', extensions: [], - } + }, ]; const result = await echo.walletApi.addOperationToBuilderTransaction(transactionTypeHandle, operation); expect(result) @@ -1909,7 +1878,7 @@ describe('WALLET API', () => { account_id: accountId, new_owner: '1.2.1', extensions: [], - } + }, ]; const unsignedOperation = 4; const result = await echo.walletApi.replaceOperationInBuilderTransaction( @@ -1922,7 +1891,6 @@ describe('WALLET API', () => { .be .an('null'); } catch (e) { - console.log(e); throw e; } }).timeout(5000); @@ -1956,7 +1924,7 @@ describe('WALLET API', () => { const transactionTypeHandle = 5; const result = await echo.walletApi.signBuilderTransaction( transactionTypeHandle, - shouldDoBroadcastToNetwork + shouldDoBroadcastToNetwork, ); expect(result) .to @@ -1968,7 +1936,7 @@ describe('WALLET API', () => { describe.skip('#proposeBuilderTransaction()', () => { it('should get sing transaction', async () => { const transactionTypeHandle = 6; - const date = new Date(2020,9,5); + const date = new Date(2020, 9, 5); const reviewPeriod = 60000; const result = await echo.walletApi.proposeBuilderTransaction( transactionTypeHandle, @@ -2084,8 +2052,8 @@ describe('WALLET API', () => { .to .be .an('array'); - }).timeout(5000); - }); + }).timeout(5000); + }); describe('#registerAccountWithApi()', () => { @@ -2095,8 +2063,7 @@ describe('WALLET API', () => { const pubKey = 'ECHOBMZ6kgpeij9zWpAXxQHkRRrQzVf7DmKnX8rQJxBtcMrs'; await echo.walletApi.registerAccountWithApi(name, pubKey, pubKey); - } catch(e) { - console.log(e); + } catch (e) { throw e; } }).timeout(5000); @@ -2114,9 +2081,8 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').that.is.not.empty; } catch (e) { - console.log(e); throw e; } }).timeout(5000); @@ -2131,16 +2097,16 @@ describe('WALLET API', () => { to: `1.${ACCOUNT}.7`, amount: { asset_id: constants.ECHO_ASSET_ID, - amount: 1000 + amount: 1000, }, }); await transaction.sign(PrivateKey.fromWif(pk)); const trx = transaction.transactionObject; const result = await echo.walletApi.serializeTransaction(trx); expect(result) - .to - .be - .an('string'); + .to + .be + .an('string'); }).timeout(5000); }); @@ -2149,39 +2115,38 @@ describe('WALLET API', () => { try { const result = await echo.walletApi.listFrozenBalances(accountId); expect(result) - .to - .be - .an('array').that.is.not.empty; - expect(result[0]) - .to - .be - .an('object').that.is.not.empty; - expect(result[0].id) - .to - .be - .an('string').that.is.not.empty; - expect(result[0].owner) - .to - .be - .an('string'); - expect(result[0].balance) - .to - .be - .an('object').that.is.not.empty; - expect(result[0].multiplier) - .to - .be - .an('number'); - expect(result[0].unfreeze_time) - .to - .be - .an('string').that.is.not.empty; - expect(result[0].extensions) - .to - .be - .an('array'); + .to + .be + .an('array').that.is.not.empty; + expect(result[0]) + .to + .be + .an('object').that.is.not.empty; + expect(result[0].id) + .to + .be + .an('string').that.is.not.empty; + expect(result[0].owner) + .to + .be + .an('string'); + expect(result[0].balance) + .to + .be + .an('object').that.is.not.empty; + expect(result[0].multiplier) + .to + .be + .an('number'); + expect(result[0].unfreeze_time) + .to + .be + .an('string').that.is.not.empty; + expect(result[0].extensions) + .to + .be + .an('array'); } catch (e) { - console.log(e); throw e; } }).timeout(5000); @@ -2197,11 +2162,10 @@ describe('WALLET API', () => { '02c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e', ); expect(result) - .to - .be - .an('object').that.is.not.empty; + .to + .be + .an('object').that.is.not.empty; } catch (e) { - console.log(e); throw e; } }).timeout(5000); From 55487767652715386f888c8665eec7695899e72c Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 09:41:33 +0300 Subject: [PATCH 02/11] fixed tests with lint checking --- .eslintrc.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 54181285..3e10cc27 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,6 @@ module.exports = { "import" ], "rules": { - "global-require": 0, "arrow-parens": [ "error", "always" @@ -46,13 +45,5 @@ module.exports = { ] } ] - }, - "overrides": [ - { - "files": ["*api.test.js", "*cache.test.js", "*subscriber.test.js"], - "rules": { - "no-unused-expressions": "off" - } - } - ] + } }; From e648c72b11733f94f8d61ba50de76d4f9f713655 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 09:48:25 +0300 Subject: [PATCH 03/11] fixed tests with lint pathes --- .eslintrc.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3e10cc27..3aa7ef72 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,6 +9,11 @@ module.exports = { "import" ], "rules": { + "global-require": 0, + "import/no-unresolved": [ + 2, + { "caseSensitive": false } + ], "arrow-parens": [ "error", "always" @@ -45,5 +50,13 @@ module.exports = { ] } ] - } + }, + "overrides": [ + { + "files": ["*api.test.js", "*cache.test.js", "*subscriber.test.js"], + "rules": { + "no-unused-expressions": "off" + } + } + ] }; From ec8f6363a461ed3efbaf97214541eae6c9ad0c78 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 10:08:06 +0300 Subject: [PATCH 04/11] fixed tests --- test/_test-data.js | 1 + test/api/database/check-erc20-token.test.js | 1 + test/api/database/get-contract-logs2.test.js | 1 + test/api/network.api.test.js | 1 + test/api/register.account.test.js | 1 + test/contract/Contract.test.js | 1 + test/contract/Method.test.js | 3 ++- test/contract/deploying.test.js | 1 + test/deserializer/chain/id/any-object-id.deserializer.test.js | 1 + test/deserializer/chain/id/object-id.deserializer.test.js | 1 + test/deserializer/chain/public-key.deserializer.test.js | 1 + .../collections/static-variant.deserializer.test.js | 1 + test/deserializer/collections/struct.deserializer.test.js | 1 + test/deserializer/operation.deserializer.test.js | 1 + test/deserializer/vote-id-deserializer.test.js | 1 + test/operations/account-create.operation.test.js | 1 + test/operations/asset-issue.test.js | 1 + test/operations/balance-freeze.operation.test.js | 1 + test/operations/create-asset.operation.test.js | 1 + test/operations/create-contract.operation.test.js | 1 + .../operations/disconnect-and-cache-renewing.operation.test.js | 1 + test/operations/non-default-fee-asset.test.js | 3 ++- test/preparation/preparation.js | 3 ++- test/subscriber.test.js | 1 + 24 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/_test-data.js b/test/_test-data.js index 308c7778..8cc54333 100644 --- a/test/_test-data.js +++ b/test/_test-data.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line import/no-unresolved, import/extensions import { PrivateKey, constants } from '../'; export const privateKey = PrivateKey.fromWif('5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2'); diff --git a/test/api/database/check-erc20-token.test.js b/test/api/database/check-erc20-token.test.js index 64610b3a..4b4156e5 100644 --- a/test/api/database/check-erc20-token.test.js +++ b/test/api/database/check-erc20-token.test.js @@ -1,6 +1,7 @@ import { ok, strictEqual } from 'assert'; import { url, accountId, privateKey } from '../../_test-data'; import { shouldReject, getMinContractBytecode } from '../../_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '../../../'; describe('checkERC20Token', () => { diff --git a/test/api/database/get-contract-logs2.test.js b/test/api/database/get-contract-logs2.test.js index ace4a9f2..ff1e5b95 100644 --- a/test/api/database/get-contract-logs2.test.js +++ b/test/api/database/get-contract-logs2.test.js @@ -1,4 +1,5 @@ import { ok, deepStrictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS } from '../../..'; import { url, accountId, privateKey } from '../../_test-data'; diff --git a/test/api/network.api.test.js b/test/api/network.api.test.js index 0bba8acb..8ef7248e 100644 --- a/test/api/network.api.test.js +++ b/test/api/network.api.test.js @@ -1,5 +1,6 @@ import { ok, strictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../..'; import { url } from '../_test-data'; diff --git a/test/api/register.account.test.js b/test/api/register.account.test.js index 0b24028a..bfe19d39 100644 --- a/test/api/register.account.test.js +++ b/test/api/register.account.test.js @@ -1,5 +1,6 @@ import { ok } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import echo from '../..'; import { url } from '../_test-data'; diff --git a/test/contract/Contract.test.js b/test/contract/Contract.test.js index de71d6c9..e3522d05 100644 --- a/test/contract/Contract.test.js +++ b/test/contract/Contract.test.js @@ -2,6 +2,7 @@ import 'mocha'; import { deepStrictEqual, notStrictEqual, strictEqual, ok } from 'assert'; import { expect } from 'chai'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Contract } from '../../'; /** @typedef {import("../types/interfaces/Abi").AbiMethod} AbiMethod */ diff --git a/test/contract/Method.test.js b/test/contract/Method.test.js index ad560c81..efe390c9 100644 --- a/test/contract/Method.test.js +++ b/test/contract/Method.test.js @@ -2,10 +2,11 @@ import 'mocha'; import { strictEqual, ok, fail, deepStrictEqual } from 'assert'; import BigNumber from 'bignumber.js'; import $c from 'comprehension'; -import { Echo, Contract } from '../../'; import checkContractIdTests from './_checkContractId.test'; import { abi, bytecode as code } from '../operations/_contract.test'; import { url, privateKey, accountId } from '../_test-data'; +// eslint-disable-next-line import/no-unresolved, import/extensions +import { Echo, Contract } from '../../'; describe('Method', () => { diff --git a/test/contract/deploying.test.js b/test/contract/deploying.test.js index 61b2217e..d11baaaa 100644 --- a/test/contract/deploying.test.js +++ b/test/contract/deploying.test.js @@ -1,6 +1,7 @@ import BigNumber from 'bignumber.js'; import { ok, strictEqual } from 'assert'; import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, Contract } from '../../'; import { url, privateKey, accountId } from '../_test-data'; diff --git a/test/deserializer/chain/id/any-object-id.deserializer.test.js b/test/deserializer/chain/id/any-object-id.deserializer.test.js index 63ab6fab..d5541aa8 100644 --- a/test/deserializer/chain/id/any-object-id.deserializer.test.js +++ b/test/deserializer/chain/id/any-object-id.deserializer.test.js @@ -1,4 +1,5 @@ import { deepStrictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../../'; const { anyObjectId } = serializers.chain.ids; diff --git a/test/deserializer/chain/id/object-id.deserializer.test.js b/test/deserializer/chain/id/object-id.deserializer.test.js index 9e47016f..ca213205 100644 --- a/test/deserializer/chain/id/object-id.deserializer.test.js +++ b/test/deserializer/chain/id/object-id.deserializer.test.js @@ -1,4 +1,5 @@ import { deepStrictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers, constants } from '../../../..'; const { CHAIN_TYPES, PROTOCOL_OBJECT_TYPE_ID } = constants; diff --git a/test/deserializer/chain/public-key.deserializer.test.js b/test/deserializer/chain/public-key.deserializer.test.js index 08ef5a7b..bc03f132 100644 --- a/test/deserializer/chain/public-key.deserializer.test.js +++ b/test/deserializer/chain/public-key.deserializer.test.js @@ -1,5 +1,6 @@ import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers, PrivateKey } from '../../../'; const { publicKey: publicKeySer } = serializers.chain; diff --git a/test/deserializer/collections/static-variant.deserializer.test.js b/test/deserializer/collections/static-variant.deserializer.test.js index 98c73262..c8b74cdb 100644 --- a/test/deserializer/collections/static-variant.deserializer.test.js +++ b/test/deserializer/collections/static-variant.deserializer.test.js @@ -1,5 +1,6 @@ import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../'; const staticVariantT = serializers.collections.staticVariant; diff --git a/test/deserializer/collections/struct.deserializer.test.js b/test/deserializer/collections/struct.deserializer.test.js index 64dd4af9..adc3b4c1 100644 --- a/test/deserializer/collections/struct.deserializer.test.js +++ b/test/deserializer/collections/struct.deserializer.test.js @@ -1,4 +1,5 @@ import { deepStrictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../'; const { uint32 } = serializers.basic.integers; diff --git a/test/deserializer/operation.deserializer.test.js b/test/deserializer/operation.deserializer.test.js index b3d0cca4..02c80323 100644 --- a/test/deserializer/operation.deserializer.test.js +++ b/test/deserializer/operation.deserializer.test.js @@ -1,4 +1,5 @@ import { deepEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../..'; const { operation: operationSer } = serializers; diff --git a/test/deserializer/vote-id-deserializer.test.js b/test/deserializer/vote-id-deserializer.test.js index 74e735fe..5738da12 100644 --- a/test/deserializer/vote-id-deserializer.test.js +++ b/test/deserializer/vote-id-deserializer.test.js @@ -1,4 +1,5 @@ import { strictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../..'; const { voteId: voteIdSer } = serializers.protocol; diff --git a/test/operations/account-create.operation.test.js b/test/operations/account-create.operation.test.js index 498099a7..6bcdc07f 100644 --- a/test/operations/account-create.operation.test.js +++ b/test/operations/account-create.operation.test.js @@ -1,6 +1,7 @@ import 'mocha'; import { ok } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants, PrivateKey } from '../../'; import { ED25519 } from '../../src/crypto'; diff --git a/test/operations/asset-issue.test.js b/test/operations/asset-issue.test.js index 544ac0f0..e1545da8 100644 --- a/test/operations/asset-issue.test.js +++ b/test/operations/asset-issue.test.js @@ -1,5 +1,6 @@ import { strictEqual } from 'assert'; import { url, accountId, privateKey } from '../_test-data'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '../../'; import { getRandomAssetSymbol } from '../_test-utils'; diff --git a/test/operations/balance-freeze.operation.test.js b/test/operations/balance-freeze.operation.test.js index d9ddc3f9..a9869d0e 100644 --- a/test/operations/balance-freeze.operation.test.js +++ b/test/operations/balance-freeze.operation.test.js @@ -1,5 +1,6 @@ import { ok } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; import { privateKey, accountId, url } from '../_test-data'; diff --git a/test/operations/create-asset.operation.test.js b/test/operations/create-asset.operation.test.js index d5062a3c..17cb9438 100644 --- a/test/operations/create-asset.operation.test.js +++ b/test/operations/create-asset.operation.test.js @@ -1,6 +1,7 @@ import 'mocha'; import { accountId, url, privateKey } from '../_test-data'; import { getRandomAssetSymbol } from '../_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS } from '../../'; import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; import testExtensionsField from './_testExtensionsField'; diff --git a/test/operations/create-contract.operation.test.js b/test/operations/create-contract.operation.test.js index d82db63f..5a03d18d 100644 --- a/test/operations/create-contract.operation.test.js +++ b/test/operations/create-contract.operation.test.js @@ -2,6 +2,7 @@ import 'mocha'; // import { ok } from 'assert'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url } from '../_test-data'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; import { ECHO_ASSET_ID } from '../../src/constants'; // import { OPERATION_HISTORY } from '../../src/constants/object-types'; diff --git a/test/operations/disconnect-and-cache-renewing.operation.test.js b/test/operations/disconnect-and-cache-renewing.operation.test.js index 25bd00ce..bbb31fd5 100644 --- a/test/operations/disconnect-and-cache-renewing.operation.test.js +++ b/test/operations/disconnect-and-cache-renewing.operation.test.js @@ -2,6 +2,7 @@ import 'mocha'; import { expect } from 'chai'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url, contractId } from '../_test-data'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; const { OPERATIONS_IDS } = constants; diff --git a/test/operations/non-default-fee-asset.test.js b/test/operations/non-default-fee-asset.test.js index 0e93ff27..bbb57634 100644 --- a/test/operations/non-default-fee-asset.test.js +++ b/test/operations/non-default-fee-asset.test.js @@ -1,7 +1,8 @@ import { ok } from 'assert'; -import { Echo, OPERATIONS_IDS } from '../..'; import { accountId, privateKey, url } from '../_test-data'; import { getRandomAssetSymbol } from '../_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions +import { Echo, OPERATIONS_IDS } from '../..'; /** * @typedef {import("../..")["serializers"]["protocol"]["asset"]["issue"]["__TOutput__"]} RawAssetIssueOperationProps diff --git a/test/preparation/preparation.js b/test/preparation/preparation.js index 4f88c326..684c63ba 100644 --- a/test/preparation/preparation.js +++ b/test/preparation/preparation.js @@ -1,5 +1,6 @@ -import echo, { constants, OPERATIONS_IDS } from '../../'; import { url, privateKey, accountId } from './../_test-data'; +// eslint-disable-next-line import/no-unresolved, import/extensions +import echo, { constants, OPERATIONS_IDS } from '../../'; const prepare = async () => { await echo.connect(url, { diff --git a/test/subscriber.test.js b/test/subscriber.test.js index e1de38a2..19871b6b 100644 --- a/test/subscriber.test.js +++ b/test/subscriber.test.js @@ -4,6 +4,7 @@ import spies from 'chai-spies'; import { url, accountId, privateKey } from './_test-data'; import { shouldReject } from './_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '..'; import { ACCOUNT, CONTRACT } from '../src/constants/object-types'; From 63e50746e30c4673dcc6fda92a33beef27edd703 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 10:13:29 +0300 Subject: [PATCH 05/11] fixed tests lint --- .eslintrc.js | 4 ---- test/deserializer.test.js | 1 + test/operations/account-update.operations.test.js | 1 + test/operations/sidechain.btc.operations.test.js | 3 ++- test/operations/transfer.operation.test.js | 3 ++- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3aa7ef72..54181285 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,10 +10,6 @@ module.exports = { ], "rules": { "global-require": 0, - "import/no-unresolved": [ - 2, - { "caseSensitive": false } - ], "arrow-parens": [ "error", "always" diff --git a/test/deserializer.test.js b/test/deserializer.test.js index d392999e..0db5bdfa 100644 --- a/test/deserializer.test.js +++ b/test/deserializer.test.js @@ -1,4 +1,5 @@ import { shouldReject } from './_test-utils'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../'; describe('deserializer', () => { diff --git a/test/operations/account-update.operations.test.js b/test/operations/account-update.operations.test.js index 86724dc0..90f4c4d4 100644 --- a/test/operations/account-update.operations.test.js +++ b/test/operations/account-update.operations.test.js @@ -1,6 +1,7 @@ import 'mocha'; import { fail, ok, strictEqual } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import { constants, Echo, OPERATIONS_IDS } from '../../'; import { privateKey, accountId, url } from '../_test-data'; diff --git a/test/operations/sidechain.btc.operations.test.js b/test/operations/sidechain.btc.operations.test.js index 99308df4..8665ca1e 100644 --- a/test/operations/sidechain.btc.operations.test.js +++ b/test/operations/sidechain.btc.operations.test.js @@ -1,7 +1,8 @@ import { rejects } from 'assert'; -import { Echo, constants } from '../../'; import { privateKey, accountId, url } from '../_test-data'; import { BTC_INTERMEDIATE_DEPOSIT } from '../../src/constants/object-types'; +// eslint-disable-next-line import/no-unresolved, import/extensions +import { Echo, constants } from '../../'; const echo = new Echo(); diff --git a/test/operations/transfer.operation.test.js b/test/operations/transfer.operation.test.js index bcb6d1d4..3043853f 100644 --- a/test/operations/transfer.operation.test.js +++ b/test/operations/transfer.operation.test.js @@ -1,8 +1,9 @@ import { strictEqual, ok } from 'assert'; -import { Echo, constants, serializers } from '../../'; import { privateKey, accountId, url } from '../_test-data'; import testExtensionsField from './_testExtensionsField'; +// eslint-disable-next-line import/no-unresolved, import/extensions +import { Echo, constants, serializers } from '../../'; import { ACCOUNT, ASSET } from '../../src/constants/object-types'; import { operation } from '../../src/serializers'; From f7c9ea3e53dcfa5471aba148bd57da636b6eef75 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 10:29:48 +0300 Subject: [PATCH 06/11] check fixes --- .eslintrc.js | 4 ++++ test/api/register.account.test.js | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 54181285..3aa7ef72 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,10 @@ module.exports = { ], "rules": { "global-require": 0, + "import/no-unresolved": [ + 2, + { "caseSensitive": false } + ], "arrow-parens": [ "error", "always" diff --git a/test/api/register.account.test.js b/test/api/register.account.test.js index 16516dda..2987cf95 100644 --- a/test/api/register.account.test.js +++ b/test/api/register.account.test.js @@ -1,6 +1,5 @@ import { ok } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import echo from '../..'; import { url } from '../_test-data'; @@ -26,7 +25,7 @@ describe('API register account POW', () => { 'kokoko'.concat(Date.now()), 'ECHODvHDsAfk2M8LhYcxLZTbrNJRWT3UH5zxdaWimWc6uZkH', 'ECHODvHDsAfk2M8LhYcxLZTbrNJRWT3UH5zxdaWimWc6uZkH', - () => { isResolved = true }, + () => { isResolved = true; }, ); await new Promise((resolve) => setTimeout(() => resolve(), 100)); await echo.api.getAccountCount(); From f4dbf6783f548e365d59e5ae99af6ead88e92b6d Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Thu, 21 Nov 2019 10:31:54 +0300 Subject: [PATCH 07/11] fixed tests complete --- .eslintrc.js | 4 ---- test/api/register.account.test.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3aa7ef72..54181285 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,10 +10,6 @@ module.exports = { ], "rules": { "global-require": 0, - "import/no-unresolved": [ - 2, - { "caseSensitive": false } - ], "arrow-parens": [ "error", "always" diff --git a/test/api/register.account.test.js b/test/api/register.account.test.js index 2987cf95..4b3d081c 100644 --- a/test/api/register.account.test.js +++ b/test/api/register.account.test.js @@ -1,5 +1,6 @@ import { ok } from 'assert'; +// eslint-disable-next-line import/no-unresolved, import/extensions import echo from '../..'; import { url } from '../_test-data'; From f14e19a6926f18a020c2c4c4969891d3ef6483d9 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Wed, 27 Nov 2019 13:45:56 +0300 Subject: [PATCH 08/11] fixing lint --- .eslintrc.js | 10 +-- test/_test-data.js | 1 - test/_test-utils.js | 4 +- test/api.test.js | 29 +++---- test/cache.test.js | 4 +- test/subscriber.test.js | 23 ++--- test/wallet-api.test.js | 186 ++++++++++++++++++++-------------------- 7 files changed, 123 insertions(+), 134 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 54181285..13c2f6e7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -46,13 +46,5 @@ module.exports = { ] } ] - }, - "overrides": [ - { - "files": ["*api.test.js", "*cache.test.js", "*subscriber.test.js"], - "rules": { - "no-unused-expressions": "off" - } - } - ] + } }; diff --git a/test/_test-data.js b/test/_test-data.js index 8cc54333..308c7778 100644 --- a/test/_test-data.js +++ b/test/_test-data.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line import/no-unresolved, import/extensions import { PrivateKey, constants } from '../'; export const privateKey = PrivateKey.fromWif('5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2'); diff --git a/test/_test-utils.js b/test/_test-utils.js index dde5ea5a..9fe41842 100644 --- a/test/_test-utils.js +++ b/test/_test-utils.js @@ -20,11 +20,11 @@ export function shouldReject(f, expectedErrorMessage, testErrorMessage) { console.log('got result:', inspect(res, false, null, true)); fail('should rejects'); }); - it('instance of Error', () => { + it('instance of Error', function () { if (!actualError) this.skip(); ok(actualError instanceof Error); }); - it(testErrorMessage || `with message "${expectedErrorMessage}"`, () => { + it(testErrorMessage || `with message "${expectedErrorMessage}"`, function () { if (!actualError || !(actualError instanceof Error)) this.skip(); strictEqual(actualError.message, expectedErrorMessage); }); diff --git a/test/api.test.js b/test/api.test.js index fa109e6f..1c99fefe 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -102,11 +102,11 @@ describe('API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('name'); expect(result[0].name) .to .be @@ -141,11 +141,11 @@ describe('API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('asset_id'); expect(result[0].asset_id) .to .be @@ -655,7 +655,7 @@ describe('API', () => { const account = await api.getAccountByName(accountName, true); - expect(account).to.exist; + expect(account).not.to.equal(null).not.to.equal(undefined); const { id } = account; @@ -859,8 +859,7 @@ describe('API', () => { .to .be .an('object'); - const { id } = object; - const voteId = object.vote_id; + const { id, vote_id: voteId } = object; expect(object) .to @@ -904,13 +903,12 @@ describe('API', () => { .be .an('object'); - const { amount } = object; - const assetId = object.asset_id; + const { amount, asset_id: assetId } = object; expect(assetId) .to .be - .an('string').that.is.not.empty; + .an('string').to.not.have.lengthOf(0); expect(amount) .to .be @@ -943,12 +941,11 @@ describe('API', () => { .timeout(5000); }); - /*eslint-disable */ - // TODO:: return 76a9148768abc89249471f990fdf33029ac6c733603a258763ac6775532102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e74 - // 2ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e4 - // 96e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efe - // b07e496e742ac84512e21026b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b56ae68 - /* eslint-enable */ + // TODO:: return 76a9148768abc89249471f990fdf33029ac6c733603a258763ac6775532102c16e97132e72738c9c0163656348cd1b + // e03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16 + // e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17e + // feb07e496e742ac84512e2102c16e97132e72738c9c0163656348cd1be03521de17efeb07e496e742ac84512e21026b86b273ff34fce + // 19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b56ae68 describe.skip('#getBtcDepositScript()', () => { it('should get null because script with this deposit id does not exist', async () => { diff --git a/test/cache.test.js b/test/cache.test.js index 6967ac06..e4ead922 100644 --- a/test/cache.test.js +++ b/test/cache.test.js @@ -43,7 +43,7 @@ describe('cache', () => { it('cache should not be used', () => { const { isUsed } = echo.cache; - expect(isUsed).to.be.false; + expect(isUsed).to.equal(false); }); }); @@ -331,7 +331,7 @@ describe('cache', () => { await Promise.all(promises); expect(newEcho.cache.blocks.size).to.be.equal(blocksRounds.length); - expect(newEcho.cache.timeout).to.be.null; + expect(newEcho.cache.timeout).to.equal(null); } catch (e) { throw e; } diff --git a/test/subscriber.test.js b/test/subscriber.test.js index 19871b6b..acaf548f 100644 --- a/test/subscriber.test.js +++ b/test/subscriber.test.js @@ -116,8 +116,8 @@ describe('SUBSCRIBER', () => { let onEmit; const onceEmitted = new Promise((resolve) => { onEmit = resolve; }); echo.subscriber.setEchorandSubscribe((result) => { - expect(result).to.be.an('array').that.is.not.empty; - expect(result[0]).to.be.an('object').that.is.not.empty; + expect(result).to.be.an('array').to.not.have.lengthOf(0); + expect(result[0]).to.be.an('object').to.have.property('type'); expect(result[0].type).to.be.a('string'); expect(result[0].round).to.be.a('number'); if (!emitted) { @@ -183,8 +183,8 @@ describe('SUBSCRIBER', () => { const onceEmitted = new Promise((resolve) => { onInited = resolve; }); echo.subscriber.setBlockApplySubscribe((result) => { - expect(result).to.be.an('array').that.is.not.empty; - expect(result[0]).to.be.an('string').that.is.not.empty; + expect(result).to.be.an('array').to.not.have.lengthOf(0); + expect(result[0]).to.be.an('string').to.not.have.lengthOf(0); if (!emitted) { emitted = true; @@ -270,7 +270,8 @@ describe('SUBSCRIBER', () => { let isCalled = false; echo.subscriber.setAccountSubscribe((result) => { - expect(result).to.be.an('object').that.is.not.empty; + expect(result).to.be.an('object'); + expect(Object.keys(result)).to.not.have.lengthOf(0); if (!isCalled) { done(); @@ -298,8 +299,8 @@ describe('SUBSCRIBER', () => { const onceEmitted = new Promise((resolve) => { onEmit = resolve; }); echo.subscriber.setGlobalSubscribe((result) => { if (result[0] && result[0].id === `2.${IMPLEMENTATION_OBJECT_TYPE_ID.DYNAMIC_GLOBAL_PROPERTY}.0`) { - expect(result).to.be.an('array').that.is.not.empty; - expect(result[0]).to.be.an('object').that.is.not.empty; + expect(result).to.be.an('array').to.not.have.lengthOf(0); + expect(result[0]).to.be.an('object').to.have.property('id'); expect(result[0].id).to.be.a('string'); expect(result[0].head_block_number).to.be.a('number'); @@ -342,8 +343,8 @@ describe('SUBSCRIBER', () => { /* callback test will be available, when transaction builder will be merged */ // let isCalled = false; - expect(echo.subscriber.subscriptions.transaction).to.be.false; - expect(echo.subscriber.subscribers.transaction).to.be.an('array').that.is.empty; + expect(echo.subscriber.subscriptions.transaction).to.equal(false); + expect(echo.subscriber.subscribers.transaction).to.be.an('array').to.have.lengthOf(0); echo.subscriber.setPendingTransactionSubscribe((/* result */) => { // expect(result).to.be.an('array').that.is.not.empty; @@ -356,8 +357,8 @@ describe('SUBSCRIBER', () => { // isCalled = true; // } }).then(() => { - expect(echo.subscriber.subscriptions.transaction).to.be.true; - expect(echo.subscriber.subscribers.transaction).to.be.an('array').that.is.not.empty; + expect(echo.subscriber.subscriptions.transaction).to.equal(true); + expect(echo.subscriber.subscribers.transaction).to.be.an('array').to.not.have.lengthOf(0); done(); }); }).timeout(30 * 1000); diff --git a/test/wallet-api.test.js b/test/wallet-api.test.js index 8e9cfdf8..213f220b 100644 --- a/test/wallet-api.test.js +++ b/test/wallet-api.test.js @@ -74,7 +74,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('blockchain_name'); }).timeout(5000); }); @@ -84,7 +84,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('head_block_num'); }).timeout(5000); }); @@ -183,7 +183,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be @@ -270,7 +270,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('brain_key'); expect(result.brain_key) .to .be @@ -301,11 +301,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('brain_key'); expect(result[0].brain_key) .to .be @@ -405,11 +405,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('name'); }).timeout(5000); }); @@ -422,15 +422,15 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0][0]) .to .be - .an('string').that.is.not.empty; + .an('string').to.not.have.lengthOf(0); expect(result[0][1]) .to .be @@ -444,11 +444,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('amount'); expect(result[0].amount) .to .be @@ -466,11 +466,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('amount'); expect(result[0].amount) .to .be @@ -497,7 +497,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('name'); expect(result.name).equal(newAccountName); expect(result.registrar).equal(accountId); expect(result.key_auths[0][0]).equal(activeKey); @@ -519,7 +519,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -543,7 +543,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(10000); }); @@ -565,7 +565,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } @@ -584,7 +584,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -594,11 +594,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[1]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -616,7 +616,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -633,7 +633,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be @@ -641,7 +641,7 @@ describe('WALLET API', () => { expect(result[1]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(10000); }); @@ -657,7 +657,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(10000); }); @@ -697,7 +697,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); expect(result.id).equal(accountId); }).timeout(5000); }); @@ -731,11 +731,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('op'); }).timeout(5000); }); @@ -745,7 +745,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -759,7 +759,7 @@ describe('WALLET API', () => { expect(result[1]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('code'); }).timeout(5000); }); @@ -781,7 +781,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -811,7 +811,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('amount'); }).timeout(5000); }); @@ -862,7 +862,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -915,7 +915,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -930,7 +930,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -997,7 +997,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1014,7 +1014,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1040,7 +1040,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]); }).timeout(5000); }); @@ -1054,11 +1054,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -1077,7 +1077,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1135,7 +1135,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); }).timeout(5000); }); @@ -1150,7 +1150,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1169,7 +1169,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1208,7 +1208,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1287,7 +1287,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1302,7 +1302,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1312,7 +1312,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -1351,7 +1351,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1413,7 +1413,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1429,7 +1429,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1439,7 +1439,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); expect(result.committee_member_account).equal(accountId); }).timeout(5000); }); @@ -1454,11 +1454,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0][0]) .to .be @@ -1478,7 +1478,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1500,7 +1500,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1557,7 +1557,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); expect(result.committee_member_account).equal(accountId); }).timeout(5000); }); @@ -1572,11 +1572,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0][0]) .to .be @@ -1591,7 +1591,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1602,7 +1602,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1612,7 +1612,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('amount'); expect(result.amount) .to .be @@ -1633,7 +1633,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1652,7 +1652,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } @@ -1674,7 +1674,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } @@ -1701,7 +1701,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(15000); }); @@ -1712,7 +1712,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('round'); expect(result.round).equal(blockNumber); }).timeout(5000); }); @@ -1731,7 +1731,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } @@ -1757,7 +1757,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(15000); }); @@ -1768,7 +1768,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('round'); expect(result.round).equal(blockNumber); }).timeout(5000); }); @@ -1800,7 +1800,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -1810,7 +1810,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -1820,11 +1820,11 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.not.have.lengthOf(0); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('id'); }).timeout(5000); }); @@ -1904,7 +1904,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1915,7 +1915,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1929,7 +1929,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1947,7 +1947,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1966,7 +1966,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -1996,7 +1996,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -2016,7 +2016,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); }).timeout(5000); }); @@ -2027,15 +2027,15 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.have.property('ref_block_num'); expect(result[1]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); expect(result[1].fee) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); expect(result[1].from) .to .be @@ -2047,7 +2047,7 @@ describe('WALLET API', () => { expect(result[1].amount) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); expect(result[1].extensions) .to .be @@ -2081,7 +2081,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } @@ -2117,15 +2117,15 @@ describe('WALLET API', () => { expect(result) .to .be - .an('array').that.is.not.empty; + .an('array').to.have.property('ref_block_num'); expect(result[0]) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); expect(result[0].id) .to .be - .an('string').that.is.not.empty; + .an('string').to.have.property('ref_block_num'); expect(result[0].owner) .to .be @@ -2133,7 +2133,7 @@ describe('WALLET API', () => { expect(result[0].balance) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); expect(result[0].multiplier) .to .be @@ -2141,7 +2141,7 @@ describe('WALLET API', () => { expect(result[0].unfreeze_time) .to .be - .an('string').that.is.not.empty; + .an('string').to.have.property('ref_block_num'); expect(result[0].extensions) .to .be @@ -2164,7 +2164,7 @@ describe('WALLET API', () => { expect(result) .to .be - .an('object').that.is.not.empty; + .an('object').to.have.property('ref_block_num'); } catch (e) { throw e; } From bcbb3ba04c3572211cbe0f552e24f7b10c942e62 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Wed, 27 Nov 2019 14:12:23 +0300 Subject: [PATCH 09/11] fixed lint issues --- .travis.yml | 4 ++-- test/api/database/check-erc20-token.test.js | 1 - test/api/database/get-contract-logs2.test.js | 1 - test/api/network.api.test.js | 1 - test/api/register.account.test.js | 1 - test/contract/Contract.test.js | 1 - test/contract/Method.test.js | 1 - test/contract/deploying.test.js | 1 - test/deserializer.test.js | 1 - test/deserializer/chain/id/any-object-id.deserializer.test.js | 1 - test/deserializer/chain/id/object-id.deserializer.test.js | 1 - test/deserializer/chain/public-key.deserializer.test.js | 1 - .../collections/static-variant.deserializer.test.js | 1 - test/deserializer/collections/struct.deserializer.test.js | 1 - test/deserializer/operation.deserializer.test.js | 1 - test/deserializer/vote-id-deserializer.test.js | 1 - test/operations/account-create.operation.test.js | 1 - test/operations/account-update.operations.test.js | 1 - test/operations/asset-issue.test.js | 1 - test/operations/balance-freeze.operation.test.js | 1 - test/operations/create-asset.operation.test.js | 1 - test/operations/create-contract.operation.test.js | 1 - .../disconnect-and-cache-renewing.operation.test.js | 1 - test/operations/non-default-fee-asset.test.js | 1 - test/operations/sidechain.btc.operations.test.js | 1 - test/operations/transfer.operation.test.js | 1 - test/preparation/preparation.js | 1 - test/subscriber.test.js | 1 - 28 files changed, 2 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6dc95cb9..5ffab855 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ jobs: if: tag IS blank name: "Test lint and audit" script: + - npm install + - npm run build - npm run lint - audit-ci --moderate - stage: test @@ -29,6 +31,4 @@ jobs: name: "Deploy to npm" script: - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc - - npm install - - npm run build - ./script.sh diff --git a/test/api/database/check-erc20-token.test.js b/test/api/database/check-erc20-token.test.js index 4b4156e5..64610b3a 100644 --- a/test/api/database/check-erc20-token.test.js +++ b/test/api/database/check-erc20-token.test.js @@ -1,7 +1,6 @@ import { ok, strictEqual } from 'assert'; import { url, accountId, privateKey } from '../../_test-data'; import { shouldReject, getMinContractBytecode } from '../../_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '../../../'; describe('checkERC20Token', () => { diff --git a/test/api/database/get-contract-logs2.test.js b/test/api/database/get-contract-logs2.test.js index ff1e5b95..ace4a9f2 100644 --- a/test/api/database/get-contract-logs2.test.js +++ b/test/api/database/get-contract-logs2.test.js @@ -1,5 +1,4 @@ import { ok, deepStrictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS } from '../../..'; import { url, accountId, privateKey } from '../../_test-data'; diff --git a/test/api/network.api.test.js b/test/api/network.api.test.js index 8ef7248e..0bba8acb 100644 --- a/test/api/network.api.test.js +++ b/test/api/network.api.test.js @@ -1,6 +1,5 @@ import { ok, strictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../..'; import { url } from '../_test-data'; diff --git a/test/api/register.account.test.js b/test/api/register.account.test.js index 4b3d081c..2987cf95 100644 --- a/test/api/register.account.test.js +++ b/test/api/register.account.test.js @@ -1,6 +1,5 @@ import { ok } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import echo from '../..'; import { url } from '../_test-data'; diff --git a/test/contract/Contract.test.js b/test/contract/Contract.test.js index e3522d05..de71d6c9 100644 --- a/test/contract/Contract.test.js +++ b/test/contract/Contract.test.js @@ -2,7 +2,6 @@ import 'mocha'; import { deepStrictEqual, notStrictEqual, strictEqual, ok } from 'assert'; import { expect } from 'chai'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Contract } from '../../'; /** @typedef {import("../types/interfaces/Abi").AbiMethod} AbiMethod */ diff --git a/test/contract/Method.test.js b/test/contract/Method.test.js index efe390c9..e34caaad 100644 --- a/test/contract/Method.test.js +++ b/test/contract/Method.test.js @@ -5,7 +5,6 @@ import $c from 'comprehension'; import checkContractIdTests from './_checkContractId.test'; import { abi, bytecode as code } from '../operations/_contract.test'; import { url, privateKey, accountId } from '../_test-data'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, Contract } from '../../'; describe('Method', () => { diff --git a/test/contract/deploying.test.js b/test/contract/deploying.test.js index d11baaaa..61b2217e 100644 --- a/test/contract/deploying.test.js +++ b/test/contract/deploying.test.js @@ -1,7 +1,6 @@ import BigNumber from 'bignumber.js'; import { ok, strictEqual } from 'assert'; import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, Contract } from '../../'; import { url, privateKey, accountId } from '../_test-data'; diff --git a/test/deserializer.test.js b/test/deserializer.test.js index 0db5bdfa..d392999e 100644 --- a/test/deserializer.test.js +++ b/test/deserializer.test.js @@ -1,5 +1,4 @@ import { shouldReject } from './_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../'; describe('deserializer', () => { diff --git a/test/deserializer/chain/id/any-object-id.deserializer.test.js b/test/deserializer/chain/id/any-object-id.deserializer.test.js index d5541aa8..63ab6fab 100644 --- a/test/deserializer/chain/id/any-object-id.deserializer.test.js +++ b/test/deserializer/chain/id/any-object-id.deserializer.test.js @@ -1,5 +1,4 @@ import { deepStrictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../../'; const { anyObjectId } = serializers.chain.ids; diff --git a/test/deserializer/chain/id/object-id.deserializer.test.js b/test/deserializer/chain/id/object-id.deserializer.test.js index ca213205..9e47016f 100644 --- a/test/deserializer/chain/id/object-id.deserializer.test.js +++ b/test/deserializer/chain/id/object-id.deserializer.test.js @@ -1,5 +1,4 @@ import { deepStrictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers, constants } from '../../../..'; const { CHAIN_TYPES, PROTOCOL_OBJECT_TYPE_ID } = constants; diff --git a/test/deserializer/chain/public-key.deserializer.test.js b/test/deserializer/chain/public-key.deserializer.test.js index bc03f132..08ef5a7b 100644 --- a/test/deserializer/chain/public-key.deserializer.test.js +++ b/test/deserializer/chain/public-key.deserializer.test.js @@ -1,6 +1,5 @@ import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers, PrivateKey } from '../../../'; const { publicKey: publicKeySer } = serializers.chain; diff --git a/test/deserializer/collections/static-variant.deserializer.test.js b/test/deserializer/collections/static-variant.deserializer.test.js index c8b74cdb..98c73262 100644 --- a/test/deserializer/collections/static-variant.deserializer.test.js +++ b/test/deserializer/collections/static-variant.deserializer.test.js @@ -1,6 +1,5 @@ import { deepStrictEqual } from 'assert'; import { shouldReject } from '../../_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../'; const staticVariantT = serializers.collections.staticVariant; diff --git a/test/deserializer/collections/struct.deserializer.test.js b/test/deserializer/collections/struct.deserializer.test.js index adc3b4c1..64dd4af9 100644 --- a/test/deserializer/collections/struct.deserializer.test.js +++ b/test/deserializer/collections/struct.deserializer.test.js @@ -1,5 +1,4 @@ import { deepStrictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../../../'; const { uint32 } = serializers.basic.integers; diff --git a/test/deserializer/operation.deserializer.test.js b/test/deserializer/operation.deserializer.test.js index 02c80323..b3d0cca4 100644 --- a/test/deserializer/operation.deserializer.test.js +++ b/test/deserializer/operation.deserializer.test.js @@ -1,5 +1,4 @@ import { deepEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../..'; const { operation: operationSer } = serializers; diff --git a/test/deserializer/vote-id-deserializer.test.js b/test/deserializer/vote-id-deserializer.test.js index 5738da12..74e735fe 100644 --- a/test/deserializer/vote-id-deserializer.test.js +++ b/test/deserializer/vote-id-deserializer.test.js @@ -1,5 +1,4 @@ import { strictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { serializers } from '../..'; const { voteId: voteIdSer } = serializers.protocol; diff --git a/test/operations/account-create.operation.test.js b/test/operations/account-create.operation.test.js index 6bcdc07f..498099a7 100644 --- a/test/operations/account-create.operation.test.js +++ b/test/operations/account-create.operation.test.js @@ -1,7 +1,6 @@ import 'mocha'; import { ok } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants, PrivateKey } from '../../'; import { ED25519 } from '../../src/crypto'; diff --git a/test/operations/account-update.operations.test.js b/test/operations/account-update.operations.test.js index 90f4c4d4..86724dc0 100644 --- a/test/operations/account-update.operations.test.js +++ b/test/operations/account-update.operations.test.js @@ -1,7 +1,6 @@ import 'mocha'; import { fail, ok, strictEqual } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { constants, Echo, OPERATIONS_IDS } from '../../'; import { privateKey, accountId, url } from '../_test-data'; diff --git a/test/operations/asset-issue.test.js b/test/operations/asset-issue.test.js index e1545da8..544ac0f0 100644 --- a/test/operations/asset-issue.test.js +++ b/test/operations/asset-issue.test.js @@ -1,6 +1,5 @@ import { strictEqual } from 'assert'; import { url, accountId, privateKey } from '../_test-data'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '../../'; import { getRandomAssetSymbol } from '../_test-utils'; diff --git a/test/operations/balance-freeze.operation.test.js b/test/operations/balance-freeze.operation.test.js index a9869d0e..d9ddc3f9 100644 --- a/test/operations/balance-freeze.operation.test.js +++ b/test/operations/balance-freeze.operation.test.js @@ -1,6 +1,5 @@ import { ok } from 'assert'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; import { privateKey, accountId, url } from '../_test-data'; diff --git a/test/operations/create-asset.operation.test.js b/test/operations/create-asset.operation.test.js index 17cb9438..d5062a3c 100644 --- a/test/operations/create-asset.operation.test.js +++ b/test/operations/create-asset.operation.test.js @@ -1,7 +1,6 @@ import 'mocha'; import { accountId, url, privateKey } from '../_test-data'; import { getRandomAssetSymbol } from '../_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS } from '../../'; import { PROTOCOL_OBJECT_TYPE_ID } from '../../src/constants'; import testExtensionsField from './_testExtensionsField'; diff --git a/test/operations/create-contract.operation.test.js b/test/operations/create-contract.operation.test.js index 5a03d18d..d82db63f 100644 --- a/test/operations/create-contract.operation.test.js +++ b/test/operations/create-contract.operation.test.js @@ -2,7 +2,6 @@ import 'mocha'; // import { ok } from 'assert'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url } from '../_test-data'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; import { ECHO_ASSET_ID } from '../../src/constants'; // import { OPERATION_HISTORY } from '../../src/constants/object-types'; diff --git a/test/operations/disconnect-and-cache-renewing.operation.test.js b/test/operations/disconnect-and-cache-renewing.operation.test.js index bbb31fd5..25bd00ce 100644 --- a/test/operations/disconnect-and-cache-renewing.operation.test.js +++ b/test/operations/disconnect-and-cache-renewing.operation.test.js @@ -2,7 +2,6 @@ import 'mocha'; import { expect } from 'chai'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url, contractId } from '../_test-data'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; const { OPERATIONS_IDS } = constants; diff --git a/test/operations/non-default-fee-asset.test.js b/test/operations/non-default-fee-asset.test.js index bbb57634..12e0c833 100644 --- a/test/operations/non-default-fee-asset.test.js +++ b/test/operations/non-default-fee-asset.test.js @@ -1,7 +1,6 @@ import { ok } from 'assert'; import { accountId, privateKey, url } from '../_test-data'; import { getRandomAssetSymbol } from '../_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS } from '../..'; /** diff --git a/test/operations/sidechain.btc.operations.test.js b/test/operations/sidechain.btc.operations.test.js index 8665ca1e..09396e22 100644 --- a/test/operations/sidechain.btc.operations.test.js +++ b/test/operations/sidechain.btc.operations.test.js @@ -1,7 +1,6 @@ import { rejects } from 'assert'; import { privateKey, accountId, url } from '../_test-data'; import { BTC_INTERMEDIATE_DEPOSIT } from '../../src/constants/object-types'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants } from '../../'; const echo = new Echo(); diff --git a/test/operations/transfer.operation.test.js b/test/operations/transfer.operation.test.js index 3043853f..2a1dc1be 100644 --- a/test/operations/transfer.operation.test.js +++ b/test/operations/transfer.operation.test.js @@ -2,7 +2,6 @@ import { strictEqual, ok } from 'assert'; import { privateKey, accountId, url } from '../_test-data'; import testExtensionsField from './_testExtensionsField'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, constants, serializers } from '../../'; import { ACCOUNT, ASSET } from '../../src/constants/object-types'; diff --git a/test/preparation/preparation.js b/test/preparation/preparation.js index 684c63ba..b005d35d 100644 --- a/test/preparation/preparation.js +++ b/test/preparation/preparation.js @@ -1,5 +1,4 @@ import { url, privateKey, accountId } from './../_test-data'; -// eslint-disable-next-line import/no-unresolved, import/extensions import echo, { constants, OPERATIONS_IDS } from '../../'; const prepare = async () => { diff --git a/test/subscriber.test.js b/test/subscriber.test.js index acaf548f..1c16e49a 100644 --- a/test/subscriber.test.js +++ b/test/subscriber.test.js @@ -4,7 +4,6 @@ import spies from 'chai-spies'; import { url, accountId, privateKey } from './_test-data'; import { shouldReject } from './_test-utils'; -// eslint-disable-next-line import/no-unresolved, import/extensions import { Echo, OPERATIONS_IDS, constants } from '..'; import { ACCOUNT, CONTRACT } from '../src/constants/object-types'; From 2636bd2e0a0a9c3d6d61bf835a4ac99fad72734b Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Wed, 27 Nov 2019 15:55:51 +0300 Subject: [PATCH 10/11] fixed lint --- test/cache.test.js | 2 +- test/contract/decoders/decoders.test.js | 2 +- test/contract/decoders/dynamic-array.test.js | 2 +- test/contract/decoders/dynamic-bytes-decoder.test.js | 2 +- test/contract/encoders/default-encoder.test.js | 2 +- test/crypto/private-key.test.js | 3 +-- test/crypto/public-key.test.js | 2 +- test/crypto/utils.test.js | 3 ++- test/operations/create-contract.operation.test.js | 3 +-- test/operations/create-proposal.operation.test.js | 2 +- .../disconnect-and-cache-renewing.operation.test.js | 6 +++--- test/operations/update-asset-feed-producers.test.js | 3 +-- ...ate-committee-member-global-parameters.operation.test.js | 2 +- test/redux.test.js | 4 +--- test/subscriber.test.js | 2 +- test/transaction.test.js | 4 ++-- test/wallet-api.test.js | 2 +- 17 files changed, 21 insertions(+), 25 deletions(-) diff --git a/test/cache.test.js b/test/cache.test.js index e4ead922..4c9e1c55 100644 --- a/test/cache.test.js +++ b/test/cache.test.js @@ -1,7 +1,7 @@ import 'mocha'; import { expect } from 'chai'; -import echo, { constants, Echo } from '../src/index'; +import echo, { constants, Echo } from '../'; import { USE_CACHE_BY_DEFAULT, DEFAULT_CACHE_EXPIRATION_TIME, diff --git a/test/contract/decoders/decoders.test.js b/test/contract/decoders/decoders.test.js index 2865f42a..21b4043b 100644 --- a/test/contract/decoders/decoders.test.js +++ b/test/contract/decoders/decoders.test.js @@ -1,6 +1,6 @@ import 'mocha'; import { expect } from 'chai'; -import decode from '../../../src/contract/decoders'; +import { decode } from '../../../'; describe('decoders', () => { it('unknown type', () => { diff --git a/test/contract/decoders/dynamic-array.test.js b/test/contract/decoders/dynamic-array.test.js index f0667602..7a337506 100644 --- a/test/contract/decoders/dynamic-array.test.js +++ b/test/contract/decoders/dynamic-array.test.js @@ -2,7 +2,7 @@ import 'mocha'; import BigNumber from 'bignumber.js'; import { deepStrictEqual, ok, strictEqual } from 'assert'; import { expect } from 'chai'; -import decode from '../../../src/contract/decoders'; +import { decode } from '../../../'; describe('dynamic array', () => { it('invalid offset', () => { diff --git a/test/contract/decoders/dynamic-bytes-decoder.test.js b/test/contract/decoders/dynamic-bytes-decoder.test.js index 39d6687d..c9c90af8 100644 --- a/test/contract/decoders/dynamic-bytes-decoder.test.js +++ b/test/contract/decoders/dynamic-bytes-decoder.test.js @@ -2,7 +2,7 @@ import 'mocha'; import { ok, strictEqual } from 'assert'; import { expect } from 'chai'; import BigNumber from 'bignumber.js'; -import decode from '../../../src/contract/decoders'; +import { decode } from '../../../'; describe('dynamic bytes', () => { describe('failure', () => { diff --git a/test/contract/encoders/default-encoder.test.js b/test/contract/encoders/default-encoder.test.js index dbb52e82..75ac3c97 100644 --- a/test/contract/encoders/default-encoder.test.js +++ b/test/contract/encoders/default-encoder.test.js @@ -3,7 +3,7 @@ import { strictEqual } from 'assert'; import BigNumber from 'bignumber.js'; import { expect } from 'chai'; import $c from 'comprehension'; -import encode from '../../../src/contract/encoders'; +import { encode } from '../../../'; import { toTwosPower } from '../../../src/contract/utils/converters'; import { invalidContractIds as invalidAddressesIds } from '../_checkContractId.test'; import { PROTOCOL_OBJECT_TYPE_ID } from '../../../src/constants'; diff --git a/test/crypto/private-key.test.js b/test/crypto/private-key.test.js index 7865e66c..4ed967ad 100644 --- a/test/crypto/private-key.test.js +++ b/test/crypto/private-key.test.js @@ -1,7 +1,6 @@ import { strictEqual, throws } from 'assert'; import bs58 from 'bs58'; -import ED25519 from '../../src/crypto/ed25519'; -import PrivateKey from '../../src/crypto/private-key'; +import { PrivateKey, ED25519 } from '../../'; import { ED_PRIVATE, ED_PRIVATE_WITHOUT_PREFIX, WIF } from '../_test-data'; describe('PrivateKey EdDSA', () => { diff --git a/test/crypto/public-key.test.js b/test/crypto/public-key.test.js index 34b803cf..acf416e1 100644 --- a/test/crypto/public-key.test.js +++ b/test/crypto/public-key.test.js @@ -1,5 +1,5 @@ import { strictEqual } from 'assert'; -import PublicKey from '../../src/crypto/public-key'; +import { PublicKey } from '../../'; describe('PublicKey', () => { diff --git a/test/crypto/utils.test.js b/test/crypto/utils.test.js index 38e09f50..bed2eef9 100644 --- a/test/crypto/utils.test.js +++ b/test/crypto/utils.test.js @@ -1,5 +1,6 @@ import { strictEqual, throws } from 'assert'; -import { utils, PrivateKey } from '../../src/crypto'; +import { utils } from '../../src/crypto'; +import { PrivateKey } from '../../'; import { WIF, WIF2 } from '../_test-data'; describe('Utils', () => { diff --git a/test/operations/create-contract.operation.test.js b/test/operations/create-contract.operation.test.js index d82db63f..f26b8b2a 100644 --- a/test/operations/create-contract.operation.test.js +++ b/test/operations/create-contract.operation.test.js @@ -2,11 +2,10 @@ import 'mocha'; // import { ok } from 'assert'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url } from '../_test-data'; -import { Echo, constants } from '../../'; +import { Echo, OPERATIONS_IDS } from '../../'; import { ECHO_ASSET_ID } from '../../src/constants'; // import { OPERATION_HISTORY } from '../../src/constants/object-types'; -const { OPERATIONS_IDS } = constants; /** @type {{contractAddress:string|null, netAddress:string, startValue:string}} */ const options = { contractAddress: null, diff --git a/test/operations/create-proposal.operation.test.js b/test/operations/create-proposal.operation.test.js index d2e92e7e..451e53c1 100644 --- a/test/operations/create-proposal.operation.test.js +++ b/test/operations/create-proposal.operation.test.js @@ -1,5 +1,5 @@ import { fail, ok, strictEqual } from 'assert'; -import { Echo, OPERATIONS_IDS } from '../../src'; +import { Echo, OPERATIONS_IDS } from '../../'; import { url, accountId } from '../_test-data'; import { ECHO_ASSET_ID } from '../../src/constants'; diff --git a/test/operations/disconnect-and-cache-renewing.operation.test.js b/test/operations/disconnect-and-cache-renewing.operation.test.js index 25bd00ce..81a48352 100644 --- a/test/operations/disconnect-and-cache-renewing.operation.test.js +++ b/test/operations/disconnect-and-cache-renewing.operation.test.js @@ -2,9 +2,9 @@ import 'mocha'; import { expect } from 'chai'; import { bytecode } from './_contract.test'; import { privateKey, accountId, url, contractId } from '../_test-data'; -import { Echo, constants } from '../../'; +import { Echo, OPERATIONS_IDS } from '../../'; -const { OPERATIONS_IDS } = constants; +// const { OPERATIONS_IDS } = constants; /** @type {{contractAddress:string|null, netAddress:string, startValue:string}} */ const options = { @@ -45,7 +45,7 @@ describe('error while disconnecting and updating cache', () => { try { await echo.subscriber.setAccountSubscribe(() => {}, [accountId]); await echo.createTransaction() - .addOperation(constants.OPERATIONS_IDS.ACCOUNT_UPDATE, { + .addOperation(OPERATIONS_IDS.ACCOUNT_UPDATE, { fee: { asset_id: '1.3.0' }, account: accountId, echorand_key: privateKey.toPublicKey() diff --git a/test/operations/update-asset-feed-producers.test.js b/test/operations/update-asset-feed-producers.test.js index d5829e55..0d22dfa7 100644 --- a/test/operations/update-asset-feed-producers.test.js +++ b/test/operations/update-asset-feed-producers.test.js @@ -1,7 +1,6 @@ import { fail, ok, strictEqual } from 'assert'; -import { Echo } from '../../src'; +import { Echo, OPERATIONS_IDS } from '../../'; import { url, accountId } from '../_test-data'; -import { OPERATIONS_IDS } from '../../src/constants'; describe('update asset feed producers', () => { const echo = new Echo(); diff --git a/test/operations/update-committee-member-global-parameters.operation.test.js b/test/operations/update-committee-member-global-parameters.operation.test.js index bc480432..eb030465 100644 --- a/test/operations/update-committee-member-global-parameters.operation.test.js +++ b/test/operations/update-committee-member-global-parameters.operation.test.js @@ -1,5 +1,5 @@ import { fail, strictEqual, ok } from 'assert'; -import { Echo, OPERATIONS_IDS } from '../../src'; +import { Echo, OPERATIONS_IDS } from '../../'; import { url } from '../_test-data'; describe('update committee member global parameters', () => { diff --git a/test/redux.test.js b/test/redux.test.js index 01cc202a..a5b20fc1 100644 --- a/test/redux.test.js +++ b/test/redux.test.js @@ -1,11 +1,9 @@ import { expect } from 'chai'; import { combineReducers, createStore } from 'redux'; -import { Echo } from '../src'; +import { Echo } from '../'; import cacheReducer from '../src/redux/reducer'; - import { url } from './_test-data'; - import { ACCOUNT } from '../src/constants/object-types'; const defaultReducer = (state = {}, { type, payload }) => (type === 'SET' ? { ...state, ...payload } : state); diff --git a/test/subscriber.test.js b/test/subscriber.test.js index 1c16e49a..94c35cf5 100644 --- a/test/subscriber.test.js +++ b/test/subscriber.test.js @@ -4,7 +4,7 @@ import spies from 'chai-spies'; import { url, accountId, privateKey } from './_test-data'; import { shouldReject } from './_test-utils'; -import { Echo, OPERATIONS_IDS, constants } from '..'; +import { Echo, OPERATIONS_IDS, constants } from '../'; import { ACCOUNT, CONTRACT } from '../src/constants/object-types'; import { IMPLEMENTATION_OBJECT_TYPE_ID } from '../src/constants/chain-types'; diff --git a/test/transaction.test.js b/test/transaction.test.js index a8c26a4a..0db7ebf1 100644 --- a/test/transaction.test.js +++ b/test/transaction.test.js @@ -1,10 +1,10 @@ import 'mocha'; // import { expect } from 'chai'; -import { Echo } from '../src'; +import { Echo } from '../'; // import Transaction from '../src/echo/transaction'; // import { strictEqual, notStrictEqual, deepStrictEqual, fail, ok } from 'assert'; import { TRANSFER } from '../src/constants/operations-ids'; -// import PrivateKey from '../src/crypto/private-key'; +// import PrivateKey from '../'; import { url } from './_test-data'; import { ACCOUNT, ASSET } from '../src/constants/object-types'; diff --git a/test/wallet-api.test.js b/test/wallet-api.test.js index 213f220b..89809d3d 100644 --- a/test/wallet-api.test.js +++ b/test/wallet-api.test.js @@ -19,7 +19,7 @@ import { TRANSFER } from '../src/constants/operations-ids'; import PrivateKey from '../src/crypto/private-key'; import { bytecode } from './operations/_contract.test'; -describe('WALLET API', () => { +describe.only('WALLET API', () => { const shouldDoBroadcastToNetwork = false; const brainKey = 'some key12'; From 36916f6d81dd08db50eeb0a330add0010be74f77 Mon Sep 17 00:00:00 2001 From: "a.pazniak" Date: Wed, 27 Nov 2019 16:12:48 +0300 Subject: [PATCH 11/11] fixing issues --- test/wallet-api.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/wallet-api.test.js b/test/wallet-api.test.js index 89809d3d..213f220b 100644 --- a/test/wallet-api.test.js +++ b/test/wallet-api.test.js @@ -19,7 +19,7 @@ import { TRANSFER } from '../src/constants/operations-ids'; import PrivateKey from '../src/crypto/private-key'; import { bytecode } from './operations/_contract.test'; -describe.only('WALLET API', () => { +describe('WALLET API', () => { const shouldDoBroadcastToNetwork = false; const brainKey = 'some key12';