// SPDX-License-Identifier: Apache-2.0
import { getTestCacheDirectory, getTestCluster, HEDERA_PLATFORM_VERSION_TAG } from '../test-utility.js';
import { InjectTokens } from '../../src/core/dependency-injection/inject-tokens.js';
import { container } from 'tsyringe-neo';
import { Suite } from 'mocha';
export class EndToEndTestSuite extends Suite {
    testName;
    testSuiteName;
    namespace;
    deployment;
    clusterCount;
    consensusNodesCount;
    loadBalancerEnabled;
    pinger;
    realm;
    shard;
    testSuiteCallback;
    endToEndTestSuiteInstance;
    testCacheDirectory;
    contexts;
    testLogger;
    createdAccountIds = [];
    enableLocalBuildPathTesting = process.env.SOLO_LOCAL_BUILD_PATH_TESTING?.toLowerCase() === 'true';
    localBuildPath = process.env.SOLO_LOCAL_BUILD_PATH || '../hiero-consensus-node/hedera-node/data';
    localBuildReleaseTag = process.env.SOLO_LOCAL_BUILD_RELEASE_TAG || HEDERA_PLATFORM_VERSION_TAG;
    clusterReferenceNameArray = [];
    clusterReferences = new Map();
    options;
    constructor(testName, testSuiteName, namespace, deployment, clusterCount, consensusNodesCount, loadBalancerEnabled, pinger, realm = 0, shard = 0, testSuiteCallback) {
        super(testName);
        this.testName = testName;
        this.testSuiteName = testSuiteName;
        this.namespace = namespace;
        this.deployment = deployment;
        this.clusterCount = clusterCount;
        this.consensusNodesCount = consensusNodesCount;
        this.loadBalancerEnabled = loadBalancerEnabled;
        this.pinger = pinger;
        this.realm = realm;
        this.shard = shard;
        this.testSuiteCallback = testSuiteCallback;
        const soloTestClusterName = getTestCluster();
        const testClusterName = soloTestClusterName.includes('c1') || soloTestClusterName.includes('c2')
            ? soloTestClusterName
            : `${soloTestClusterName}-c1`;
        const testClusterReferenceNames = ['e2e-cluster-alpha', 'e2e-cluster-beta'];
        if (clusterCount === 1) {
            this.clusterReferences.set(testClusterReferenceNames[0], testClusterName);
            this.contexts = [testClusterName];
            this.clusterReferenceNameArray.push(testClusterReferenceNames[0]);
        }
        else if (clusterCount === 2) {
            this.clusterReferences.set(testClusterReferenceNames[0], testClusterName);
            const secondContext = `${testClusterName.replace(soloTestClusterName.includes('-c1') ? '-c1' : '-c2', soloTestClusterName.includes('-c1') ? '-c2' : '-c1')}`;
            this.clusterReferences.set(testClusterReferenceNames[1], secondContext);
            this.clusterReferenceNameArray.push(testClusterReferenceNames[0], testClusterReferenceNames[1]);
            this.contexts = [testClusterName, secondContext];
        }
        else {
            throw new Error(`Unsupported cluster count: ${clusterCount}. Only 1 or 2 clusters are supported.`);
        }
        const testClusterReferences = new Map();
        for (let index = 0; index < clusterCount; index++) {
            testClusterReferences.set(testClusterReferenceNames[index], this.contexts[index]);
        }
        this.testCacheDirectory = getTestCacheDirectory(testName);
        this.testLogger = container.resolve(InjectTokens.SoloLogger);
        this.endToEndTestSuiteInstance = this;
        this.options = {
            testName,
            testLogger: this.testLogger,
            clusterReferences: this.clusterReferences,
            clusterReferenceNameArray: this.clusterReferenceNameArray,
            contexts: this.contexts,
            deployment,
            namespace,
            testCacheDirectory: this.testCacheDirectory,
            enableLocalBuildPathTesting: this.enableLocalBuildPathTesting,
            localBuildReleaseTag: this.localBuildReleaseTag,
            localBuildPath: this.localBuildPath,
            createdAccountIds: this.createdAccountIds,
            consensusNodesCount: this.consensusNodesCount,
            loadBalancerEnabled: this.loadBalancerEnabled,
            pinger: this.pinger,
            realm: this.realm,
            shard: this.shard,
        };
    }
    runTestSuite() {
        const endToEndTestSuiteInstance = this.endToEndTestSuiteInstance;
        describe(endToEndTestSuiteInstance.testSuiteName, function endToEndTestSuiteCallback() {
            this.bail(true);
            endToEndTestSuiteInstance.testSuiteCallback(endToEndTestSuiteInstance.options);
        });
    }
}
//# sourceMappingURL=end-to-end-test-suite.js.map