// SPDX-License-Identifier: Apache-2.0
import { describe, it } from 'mocha';
import { expect } from 'chai';
import { Flags as flags } from '../../../src/commands/flags.js';
import { accountCreationShouldSucceed, balanceQueryShouldSucceed } from '../../test-utility.js';
import { Duration } from '../../../src/core/time/duration.js';
import { ConsensusCommandDefinition } from '../../../src/commands/command-definitions/consensus-command-definition.js';
export function testSeparateNodeDelete(argv, bootstrapResp, namespace) {
    const nodeAlias = 'node1';
    argv.setArg(flags.nodeAliasesUnparsed, 'node1,node2,node3');
    argv.setArg(flags.nodeAlias, nodeAlias);
    const temporaryDirectory = 'contextDir';
    const argvPrepare = argv.clone();
    argvPrepare.setArg(flags.outputDir, temporaryDirectory);
    const argvExecute = argv.clone();
    argvExecute.setArg(flags.inputDir, temporaryDirectory);
    const { opts: { k8Factory, accountManager, remoteConfig, logger, commandInvoker }, cmd: { nodeCmd }, } = bootstrapResp;
    describe('Node delete via separated commands', async () => {
        it('should delete a node from the network successfully', async () => {
            await commandInvoker.invoke({
                argv: argvPrepare,
                command: ConsensusCommandDefinition.COMMAND_NAME,
                subcommand: ConsensusCommandDefinition.DEV_NODE_DELETE_SUBCOMMAND_NAME,
                action: ConsensusCommandDefinition.DEV_NODE_PREPARE,
                callback: async (argv) => nodeCmd.handlers.destroyPrepare(argv),
            });
            await commandInvoker.invoke({
                argv: argvExecute,
                command: ConsensusCommandDefinition.COMMAND_NAME,
                subcommand: ConsensusCommandDefinition.DEV_NODE_DELETE_SUBCOMMAND_NAME,
                action: ConsensusCommandDefinition.DEV_NODE_SUBMIT_TRANSACTION,
                callback: async (argv) => nodeCmd.handlers.destroySubmitTransactions(argv),
            });
            await commandInvoker.invoke({
                argv: argvExecute,
                command: ConsensusCommandDefinition.COMMAND_NAME,
                subcommand: ConsensusCommandDefinition.DEV_NODE_DELETE_SUBCOMMAND_NAME,
                action: ConsensusCommandDefinition.DEV_NODE_EXECUTE,
                callback: async (argv) => nodeCmd.handlers.destroyExecute(argv),
            });
            await accountManager.close();
        }).timeout(Duration.ofMinutes(10).toMillis());
        balanceQueryShouldSucceed(accountManager, namespace, remoteConfig, logger, nodeAlias);
        accountCreationShouldSucceed(accountManager, namespace, remoteConfig, logger, nodeAlias);
        it('deleted consensus node should not be running', async () => {
            const pods = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
            expect(pods.length).to.equal(2);
        }).timeout(Duration.ofMinutes(10).toMillis());
    });
}
//# sourceMappingURL=separate-node-destroy.test.js.map