diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 838990f49..84d77be91 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -27,6 +27,7 @@ import { BaseCommand } from './base.mjs' import * as flags from './flags.mjs' import * as prompts from './prompts.mjs' import { + AccountBalanceQuery, AccountId, FileContentsQuery, FileId, @@ -35,6 +36,7 @@ import { Timestamp } from '@hashgraph/sdk' import * as crypto from 'crypto' +import { FREEZE_ADMIN_ACCOUNT } from '../core/constants.mjs' /** * Defines the core functionalities of 'node' command @@ -1705,6 +1707,20 @@ export class NodeCommand extends BaseCommand { const client = this.accountManager._nodeClient try { + // transfer some tiny amount to the freeze admin account + await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, FREEZE_ADMIN_ACCOUNT, 100000) + + // query the balance + const balance = await new AccountBalanceQuery() + .setAccountId(FREEZE_ADMIN_ACCOUNT) + .execute(this.accountManager._nodeClient) + this.logger.debug(`Freeze admin account balance: ${balance.hbars}`) + + // set operator of freeze transaction as freeze admin account + const accountKeys = await this.accountManager.getAccountKeysFromSecret(FREEZE_ADMIN_ACCOUNT, config.namespace) + const freezeAdminPrivateKey = accountKeys.privateKey + client.setOperator(FREEZE_ADMIN_ACCOUNT, freezeAdminPrivateKey) + // fetch special file const fileId = FileId.fromString('0.0.150') const fileQuery = new FileContentsQuery().setFileId(fileId) diff --git a/src/core/constants.mjs b/src/core/constants.mjs index 523517e9e..b6e6c7e1f 100644 --- a/src/core/constants.mjs +++ b/src/core/constants.mjs @@ -67,9 +67,11 @@ export const DEFAULT_CHART_REPO = new Map() export const OPERATOR_ID = process.env.SOLO_OPERATOR_ID || '0.0.2' export const OPERATOR_KEY = process.env.SOLO_OPERATOR_KEY || '302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137' export const OPERATOR_PUBLIC_KEY = process.env.SOLO_OPERATOR_PUBLIC_KEY || '302a300506032b65700321000aa8e21064c61eab86e2a9c164565b4e7a9a4146106e0a6cd03a8c395a110e92' +export const FREEZE_ADMIN_ACCOUNT = process.env.FREEZE_ADMIN_ACCOUNT || '0.0.58' export const TREASURY_ACCOUNT_ID = `${HEDERA_NODE_ACCOUNT_ID_START.realm}.${HEDERA_NODE_ACCOUNT_ID_START.shard}.2` export const GENESIS_KEY = process.env.GENESIS_KEY || '302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137' export const SYSTEM_ACCOUNTS = [[3, 100], [200, 349], [400, 750], [900, 1000]] // do account 0.0.2 last and outside the loop +export const SHORTER_SYSTEM_ACCOUNTS = [[3, 100], [200, 349]] export const TREASURY_ACCOUNT = 2 export const LOCAL_NODE_START_PORT = process.env.LOCAL_NODE_START_PORT || 30212 export const LOCAL_NODE_PROXY_START_PORT = process.env.LOCAL_NODE_PROXY_START_PORT || 30313 diff --git a/test/e2e/e2e_node_util.js b/test/e2e/e2e_node_util.js index 377e66d77..ee39884dd 100644 --- a/test/e2e/e2e_node_util.js +++ b/test/e2e/e2e_node_util.js @@ -47,8 +47,9 @@ import { getNodeLogs, sleep } from '../../src/core/helpers.mjs' import path from 'path' import fs from 'fs' import crypto from 'crypto' -import { ROOT_CONTAINER } from '../../src/core/constants.mjs' +import { ROOT_CONTAINER, SHORTER_SYSTEM_ACCOUNTS } from '../../src/core/constants.mjs' import { NodeCommand } from '../../src/commands/node.mjs' +import { AccountCommand } from '../../src/commands/account.mjs' export function e2eNodeKeyRefreshAddTest (keyFormat, testName, mode, releaseTag = HEDERA_PLATFORM_VERSION_TAG) { const defaultTimeout = 120000 @@ -71,6 +72,7 @@ export function e2eNodeKeyRefreshAddTest (keyFormat, testName, mode, releaseTag const accountManager = bootstrapResp.opts.accountManager const k8 = bootstrapResp.opts.k8 const nodeCmd = bootstrapResp.cmd.nodeCmd + const accountCmd = new AccountCommand(bootstrapResp.opts, SHORTER_SYSTEM_ACCOUNTS) afterEach(async () => { await nodeCmd.close() @@ -159,6 +161,11 @@ export function e2eNodeKeyRefreshAddTest (keyFormat, testName, mode, releaseTag accountCreationShouldSucceed(accountManager, nodeCmd, namespace) + it('should succeed with init command', async () => { + const status = await accountCmd.init(argv) + expect(status).toBeTruthy() + }, 450000) + it(`add ${nodeId} to the network`, async () => { try { await expect(nodeCmd.add(argv)).resolves.toBeTruthy()