Skip to content

Commit

Permalink
feat: add constants
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Jun 26, 2024
1 parent 4ea8708 commit 55c08a6
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 49 deletions.
8 changes: 3 additions & 5 deletions test/command/call.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
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');

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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/console.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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(),
Expand Down
5 changes: 1 addition & 4 deletions test/command/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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(),
Expand Down
5 changes: 1 addition & 4 deletions test/command/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions test/command/getBlkHeight.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ 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');

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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/getBlkInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ 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');

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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/getChainStatus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ 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');

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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/getTxResult.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ 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');

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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/load.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 = {
Expand Down
9 changes: 1 addition & 8 deletions test/command/proposal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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(),
Expand Down Expand Up @@ -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 = {
Expand Down
5 changes: 1 addition & 4 deletions test/command/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ 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');

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 = {
Expand Down

0 comments on commit 55c08a6

Please sign in to comment.