diff --git a/test/command/call.test.js b/test/command/call.test.js index 15be62c..e4e52af 100644 --- a/test/command/call.test.js +++ b/test/command/call.test.js @@ -1,12 +1,13 @@ import { Command } from 'commander'; import path from 'path'; import AElf from 'aelf-sdk'; +import inquirer from 'inquirer'; import { CallCommand } from '../../src/command'; import { callCommandUsages, callCommandParameters } from '../../src/utils/constants.js'; import { getContractInstance } from '../../src/utils/utils.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger.js'; -import inquirer from 'inquirer'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; const sampleRc = { getConfigs: jest.fn() }; jest.mock('../../src/utils/myLogger'); @@ -14,13 +15,10 @@ jest.mock('../../src/utils/myLogger'); describe('CallCommand', () => { let callCommand; let mockOraInstance; - const endPoint = 'https://tdvw-test-node.aelf.io/'; const aelf = new AElf(new AElf.providers.HttpProvider(endPoint)); const wallet = AElf.wallet.getWalletByPrivateKey('943df6d39fd1e1cc6ae9813e54f7b9988cf952814f9c31e37744b52594cb4096'); const address = 'ASh2Wt7nSEmYqnGxPPzp4pnVDU4uhj1XW9Se5VeZcX2UDdyjx'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); + beforeEach(() => { backup = inquirer.prompt; mockOraInstance = { diff --git a/test/command/console.test.js b/test/command/console.test.js index dd480f9..7cb01e2 100644 --- a/test/command/console.test.js +++ b/test/command/console.test.js @@ -5,6 +5,7 @@ import { Command } from 'commander'; import ConsoleCommand from '../../src/command/console.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('boxen'); jest.mock('repl'); @@ -16,10 +17,6 @@ describe('ConsoleCommand', () => { const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstance = { succeed: jest.fn(), diff --git a/test/command/create.test.js b/test/command/create.test.js index e8b1ad3..96e7f52 100644 --- a/test/command/create.test.js +++ b/test/command/create.test.js @@ -4,6 +4,7 @@ import CreateCommand from '../../src/command/create.js'; import { saveKeyStore } from '../../src/utils/wallet'; import { logger } from '../../src/utils/myLogger'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/wallet'); jest.mock('../../src/utils/myLogger'); @@ -12,10 +13,6 @@ describe('CreateCommand', () => { let createCommand; let oraInstance; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstance = { succeed: jest.fn(), diff --git a/test/command/deploy.test.js b/test/command/deploy.test.js index 23ff970..3d18ba6 100644 --- a/test/command/deploy.test.js +++ b/test/command/deploy.test.js @@ -4,6 +4,7 @@ import path from 'path'; import chalk from 'chalk'; import DeployCommand from '../../src/command/deploy.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('chalk', () => { return { @@ -21,10 +22,6 @@ describe('DeployCommand', () => { let deployCommand; let consoleSpy; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); deployCommand = new DeployCommand(sampleRc); diff --git a/test/command/getBlkHeight.test.js b/test/command/getBlkHeight.test.js index 820620b..270a48e 100644 --- a/test/command/getBlkHeight.test.js +++ b/test/command/getBlkHeight.test.js @@ -2,6 +2,7 @@ import { Command } from 'commander'; import path from 'path'; import GetBlkHeightCommand from '../../src/command/getBlkHeight.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); @@ -9,10 +10,6 @@ describe('GetBlkHeightCommand', () => { let getBlkHeightCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = { diff --git a/test/command/getBlkInfo.test.js b/test/command/getBlkInfo.test.js index 0d80cde..53ed52f 100644 --- a/test/command/getBlkInfo.test.js +++ b/test/command/getBlkInfo.test.js @@ -4,6 +4,7 @@ import path from 'path'; import GetBlkInfoCommand from '../../src/command/getBlkInfo.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); @@ -11,10 +12,6 @@ describe('GetBlkInfoCommand', () => { let getBlkInfoCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = { diff --git a/test/command/getChainStatus.test.js b/test/command/getChainStatus.test.js index b22bb0c..7347c86 100644 --- a/test/command/getChainStatus.test.js +++ b/test/command/getChainStatus.test.js @@ -2,6 +2,7 @@ import { Command } from 'commander'; import path from 'path'; import GetChainStatusCommand from '../../src/command/getChainStatus.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); @@ -9,10 +10,6 @@ describe('GetChainStatusCommand', () => { let getChainStatusCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = { diff --git a/test/command/getTxResult.test.js b/test/command/getTxResult.test.js index 470ca92..fd5d8a3 100644 --- a/test/command/getTxResult.test.js +++ b/test/command/getTxResult.test.js @@ -2,6 +2,7 @@ import { Command } from 'commander'; import path from 'path'; import GetTxResultCommand from '../../src/command/getTxResult.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); @@ -9,10 +10,6 @@ describe('GetTxResultCommand', () => { let getTxResultCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = { diff --git a/test/command/load.test.js b/test/command/load.test.js index d5bef8f..95ef3bd 100644 --- a/test/command/load.test.js +++ b/test/command/load.test.js @@ -5,6 +5,7 @@ import LoadCommand from '../../src/command/load.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger'; import { saveKeyStore } from '../../src/utils/wallet'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/wallet'); jest.mock('../../src/utils/myLogger'); @@ -13,10 +14,6 @@ describe('LoadCommand', () => { let loadCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); const privateKey = '9a2c6023e8b2221f4b02f4ccc5128392c1bd968ae45a42fa62848d793fff148f'; beforeEach(() => { oraInstanceMock = { diff --git a/test/command/proposal.test.js b/test/command/proposal.test.js index 8b44169..e1bf002 100644 --- a/test/command/proposal.test.js +++ b/test/command/proposal.test.js @@ -10,6 +10,7 @@ import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger'; import * as utils from '../../src/utils/utils.js'; import { getWallet } from '../../src/utils/wallet.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); jest.mock('inquirer'); @@ -27,10 +28,6 @@ describe('ProposalCommand processAddressAfterPrompt', () => { let proposalCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = { start: jest.fn(), @@ -59,10 +56,6 @@ describe('ProposalCommand run', () => { let proposalCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); let mockParliamentContract, mockGenesisContract; beforeEach(() => { oraInstanceMock = { diff --git a/test/command/wallet.test.js b/test/command/wallet.test.js index 540b92f..9b32c43 100644 --- a/test/command/wallet.test.js +++ b/test/command/wallet.test.js @@ -5,6 +5,7 @@ import GetTxResultCommand from '../../src/command/wallet.js'; import { userHomeDir } from '../../src/utils/userHomeDir.js'; import { logger } from '../../src/utils/myLogger.js'; import { getWallet } from '../../src/utils/wallet.js'; +import { endpoint as endPoint, account, password, dataDir } from '../constants.js'; jest.mock('../../src/utils/myLogger'); @@ -12,10 +13,6 @@ describe('WalletCommand', () => { let walletCommand; let oraInstanceMock; const sampleRc = { getConfigs: jest.fn() }; - const endPoint = 'https://tdvw-test-node.aelf.io/'; - const account = 'GyQX6t18kpwaD9XHXe1ToKxfov8mSeTLE9q9NwUAeTE8tULZk'; - const password = '1234*Qwer'; - const dataDir = path.resolve(__dirname, '../dataDir/aelf'); beforeEach(() => { oraInstanceMock = {