From 279d730bc136aed3974f85a425fd4b878d1876c3 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Tue, 19 Nov 2024 20:43:12 +0000 Subject: [PATCH] expect(await instead of await expect( Signed-off-by: Jeromy Cannon --- test/e2e/commands/account.test.ts | 14 +++++++------- test/e2e/commands/cluster.test.ts | 6 +++--- test/e2e/commands/mirror_node.test.ts | 8 ++++---- test/e2e/commands/network.test.ts | 10 +++++----- test/e2e/commands/relay.test.ts | 4 ++-- test/e2e/e2e_node_util.ts | 12 ++++++------ .../helm_dependency_manager.test.ts | 2 +- test/e2e/integration/core/k8_e2e.test.ts | 10 +++++----- .../core/platform_installer_e2e.test.ts | 2 +- test/test_add.ts | 2 +- test/test_util.ts | 6 +++--- test/unit/core/key_manager.test.ts | 8 ++++---- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/test/e2e/commands/account.test.ts b/test/e2e/commands/account.test.ts index 592e8d69f..ce4db29a2 100644 --- a/test/e2e/commands/account.test.ts +++ b/test/e2e/commands/account.test.ts @@ -121,7 +121,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin it('should create account with no options', async () => { try { argv[flags.amount.name] = 200 - await expect(accountCmd.create(argv)).to.eventually.be.ok + expect(await accountCmd.create(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo @@ -146,7 +146,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.amount.name] = 777 configManager.update(argv) - await expect(accountCmd.create(argv)).to.eventually.be.ok + expect(await accountCmd.create(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo @@ -168,7 +168,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.accountId.name] = accountId1 configManager.update(argv) - await expect(accountCmd.update(argv)).to.eventually.be.ok + expect(await accountCmd.update(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo @@ -190,7 +190,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.amount.name] = 333 configManager.update(argv) - await expect(accountCmd.update(argv)).to.eventually.be.ok + expect(await accountCmd.update(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo @@ -210,7 +210,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.accountId.name] = accountId1 configManager.update(argv) - await expect(accountCmd.get(argv)).to.eventually.be.ok + expect(await accountCmd.get(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo expect(accountInfo).not.to.be.null @@ -229,7 +229,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.accountId.name] = accountId2 configManager.update(argv) - await expect(accountCmd.get(argv)).to.eventually.be.ok + expect(await accountCmd.get(argv)).to.be.true // @ts-ignore to access the private property const accountInfo = accountCmd.accountInfo expect(accountInfo).not.to.be.null @@ -251,7 +251,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin argv[flags.setAlias.name] = true configManager.update(argv) - await expect(accountCmd.create(argv)).to.eventually.be.ok + expect(await accountCmd.create(argv)).to.be.true // @ts-ignore to access the private property const newAccountInfo = accountCmd.accountInfo diff --git a/test/e2e/commands/cluster.test.ts b/test/e2e/commands/cluster.test.ts index ffa86f261..ef9fa980b 100644 --- a/test/e2e/commands/cluster.test.ts +++ b/test/e2e/commands/cluster.test.ts @@ -82,7 +82,7 @@ describe('ClusterCommand', () => { it('should cleanup existing deployment', async () => { if (await chartManager.isChartInstalled(constants.SOLO_SETUP_NAMESPACE, constants.SOLO_CLUSTER_SETUP_CHART)) { - await expect(clusterCmd.reset(argv)).to.eventually.be.ok + expect(await clusterCmd.reset(argv)).to.be.true } }).timeout(MINUTES) @@ -95,7 +95,7 @@ describe('ClusterCommand', () => { it('solo cluster setup should work with valid args', async () => { argv[flags.clusterSetupNamespace.name] = namespace configManager.update(argv) - await expect(clusterCmd.setup(argv)).to.eventually.be.ok + expect(await clusterCmd.setup(argv)).to.be.true }).timeout(MINUTES) it('function getClusterInfo should return true', () => { @@ -127,6 +127,6 @@ describe('ClusterCommand', () => { it('solo cluster reset should work with valid args', async () => { argv[flags.clusterSetupNamespace.name] = namespace configManager.update(argv) - await expect(clusterCmd.reset(argv)).to.eventually.be.ok + expect(await clusterCmd.reset(argv)).to.be.true }).timeout(MINUTES) }) diff --git a/test/e2e/commands/mirror_node.test.ts b/test/e2e/commands/mirror_node.test.ts index 6dc75842b..1ed84a26a 100644 --- a/test/e2e/commands/mirror_node.test.ts +++ b/test/e2e/commands/mirror_node.test.ts @@ -84,7 +84,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin it('mirror node deploy should success', async () => { try { - await expect(mirrorNodeCmd.deploy(argv)).to.eventually.be.ok + expect(await mirrorNodeCmd.deploy(argv)).to.be.true } catch (e) { mirrorNodeCmd.logger.showUserError(e) expect.fail() @@ -113,7 +113,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin // check if mirror node api server is running const apiURL = 'http://127.0.0.1:8080/api/v1/transactions' - await expect(downloader.urlExists(apiURL)).to.eventually.be.ok + expect(await downloader.urlExists(apiURL)).to.be.true await sleep(2 * SECONDS) } catch (e) { mirrorNodeCmd.logger.showUserError(e) @@ -124,7 +124,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin it('Explorer GUI should be running', async () => { try { const guiURL = 'http://127.0.0.1:8080/localnet/dashboard' - await expect(downloader.urlExists(guiURL)).to.eventually.be.ok + expect(await downloader.urlExists(guiURL)).to.be.true await sleep(2 * SECONDS) mirrorNodeCmd.logger.debug('mirror node API and explorer GUI are running') @@ -203,7 +203,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin it('mirror node destroy should success', async () => { try { - await expect(mirrorNodeCmd.destroy(argv)).to.eventually.be.ok + expect(await mirrorNodeCmd.destroy(argv)).to.be.true } catch (e) { mirrorNodeCmd.logger.showUserError(e) expect.fail() diff --git a/test/e2e/commands/network.test.ts b/test/e2e/commands/network.test.ts index 741a136aa..cb91d958d 100644 --- a/test/e2e/commands/network.test.ts +++ b/test/e2e/commands/network.test.ts @@ -78,12 +78,12 @@ describe('NetworkCommand', () => { }) it('keys should be generated', async () => { - await expect(nodeCmd.handlers.keys(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.keys(argv)).to.be.true }) it('network deploy command should succeed', async () => { try { - await expect(networkCmd.deploy(argv)).to.eventually.be.ok + expect(await networkCmd.deploy(argv)).to.be.true // check pod names should match expected values await expect(k8.getPodByName('network-node1-0')) @@ -129,7 +129,7 @@ describe('NetworkCommand', () => { configManager.update(argv) try { - await expect(networkCmd.destroy(argv)).to.eventually.be.ok + expect(await networkCmd.destroy(argv)).to.be.true while ((await k8.getPodsByLabel(['solo.hedera.com/type=network-node'])).length > 0) { networkCmd.logger.debug('Pods are still running. Waiting...') @@ -142,8 +142,8 @@ describe('NetworkCommand', () => { } // check if chart is uninstalled - await expect(bootstrapResp.opts.chartManager.isChartInstalled(namespace, constants.SOLO_DEPLOYMENT_CHART)) - .to.eventually.not.be.ok + expect(await bootstrapResp.opts.chartManager.isChartInstalled(namespace, constants.SOLO_DEPLOYMENT_CHART)) + .to.be.true // check if pvc are deleted await expect(k8.listPvcsByNamespace(namespace)).eventually.to.have.lengthOf(0) diff --git a/test/e2e/commands/relay.test.ts b/test/e2e/commands/relay.test.ts index e73536a58..f504460d6 100644 --- a/test/e2e/commands/relay.test.ts +++ b/test/e2e/commands/relay.test.ts @@ -61,7 +61,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin // test relay deploy try { - await expect(relayCmd.deploy(argv)).to.eventually.be.ok + expect(await relayCmd.deploy(argv)).to.be.true } catch (e) { relayCmd.logger.showUserError(e) expect.fail() @@ -75,7 +75,7 @@ e2eTestSuite(testName, argv, undefined, undefined, undefined, undefined, undefin // test relay destroy try { - await expect(relayCmd.destroy(argv)).to.eventually.be.ok + expect(await relayCmd.destroy(argv)).to.be.true } catch (e) { relayCmd.logger.showUserError(e) expect.fail() diff --git a/test/e2e/e2e_node_util.ts b/test/e2e/e2e_node_util.ts index e1fad71b8..27d9be25b 100644 --- a/test/e2e/e2e_node_util.ts +++ b/test/e2e/e2e_node_util.ts @@ -77,10 +77,10 @@ export function e2eNodeKeyRefreshTest (testName: string, mode: string, releaseTa it(`Node Proxy should be UP [mode ${mode}, release ${releaseTag}`, async () => { try { - await expect(k8.waitForPodReady( + expect(await k8.waitForPodReady( ['app=haproxy-node1', 'solo.hedera.com/type=haproxy'], - 1, 300, 1000)).to.eventually.be.ok + 1, 300, 1000)).to.be.true } catch (e) { nodeCmd.logger.showUserError(e) expect.fail() @@ -103,7 +103,7 @@ export function e2eNodeKeyRefreshTest (testName: string, mode: string, releaseTa expect(resp.response.statusCode).to.equal(200) await sleep(20 * SECONDS) // sleep to wait for pod to finish terminating } else if (mode === 'stop') { - await expect(nodeCmd.handlers.stop(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.stop(argv)).to.be.true await sleep(20 * SECONDS) // give time for node to stop and update its logs } else { throw new Error(`invalid mode: ${mode}`) @@ -125,8 +125,8 @@ export function e2eNodeKeyRefreshTest (testName: string, mode: string, releaseTa it(`${nodeAlias} should be running`, async () => { try { // @ts-ignore to access tasks which is a private property - await expect(nodeCmd.tasks.checkNetworkNodePod(namespace, - nodeAlias)).to.eventually.be.ok + expect(await nodeCmd.tasks.checkNetworkNodePod(namespace, + nodeAlias)).to.be.true } catch (e) { nodeCmd.logger.showUserError(e) expect.fail() @@ -139,7 +139,7 @@ export function e2eNodeKeyRefreshTest (testName: string, mode: string, releaseTa function nodeRefreshShouldSucceed (nodeAlias: NodeAlias, nodeCmd: NodeCommand, argv: Record) { it(`${nodeAlias} refresh should succeed`, async () => { try { - await expect(nodeCmd.handlers.refresh(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.refresh(argv)).to.be.true expect(nodeCmd.getUnusedConfigs( NodeCommandConfigs.REFRESH_CONFIGS_NAME)).to.deep.equal([ flags.devMode.constName, diff --git a/test/e2e/integration/core/dependency_managers/helm_dependency_manager.test.ts b/test/e2e/integration/core/dependency_managers/helm_dependency_manager.test.ts index 9ef67ec5c..b287d88fb 100644 --- a/test/e2e/integration/core/dependency_managers/helm_dependency_manager.test.ts +++ b/test/e2e/integration/core/dependency_managers/helm_dependency_manager.test.ts @@ -71,7 +71,7 @@ describe('HelmDependencyManager', () => { helmDependencyManager.uninstall() expect(helmDependencyManager.isInstalled()).not.to.be.ok - await expect(helmDependencyManager.install(getTestCacheDir())).to.eventually.be.ok + expect(await helmDependencyManager.install(getTestCacheDir())).to.be.true expect(helmDependencyManager.isInstalled()).to.be.ok fs.rmSync(tmpDir, { recursive: true }) diff --git a/test/e2e/integration/core/k8_e2e.test.ts b/test/e2e/integration/core/k8_e2e.test.ts index 243bc8716..bc515c02a 100644 --- a/test/e2e/integration/core/k8_e2e.test.ts +++ b/test/e2e/integration/core/k8_e2e.test.ts @@ -134,8 +134,8 @@ describe('K8', () => { it('should be able to create and delete a namespaces', async () => { const name = uuid4() - await expect(k8.createNamespace(name)).to.eventually.be.ok - await expect(k8.deleteNamespace(name)).to.eventually.be.ok + expect(await k8.createNamespace(name)).to.be.true + expect(await k8.deleteNamespace(name)).to.be.true }).timeout(defaultTimeout) it('should be able to run wait for pod', async () => { @@ -178,7 +178,7 @@ describe('K8', () => { it('should be able to check if a path is directory inside a container', async () => { const pods = await k8.getPodsByLabel([`app=${podLabelValue}`]) const podName = pods[0].metadata.name - await expect(k8.hasDir(podName, containerName, '/tmp')).to.eventually.be.ok + expect(await k8.hasDir(podName, containerName, '/tmp')).to.be.true }).timeout(defaultTimeout) const testCases = [ 'test/data/pem/keys/a-private-node0.pem', 'test/data/build-v0.54.0-alpha.4.zip' ] @@ -197,10 +197,10 @@ describe('K8', () => { const originalStat = fs.statSync(localFilePath) // upload the file - await expect(k8.copyTo(podName, containerName, localFilePath, remoteTmpDir)).to.eventually.be.ok + expect(await k8.copyTo(podName, containerName, localFilePath, remoteTmpDir)).to.be.true // download the same file - await expect(k8.copyFrom(podName, containerName, remoteFilePath, localTmpDir)).to.eventually.be.ok + expect(await k8.copyFrom(podName, containerName, remoteFilePath, localTmpDir)).to.be.true const downloadedFilePath = path.join(localTmpDir, fileName) const downloadedFileData = fs.readFileSync(downloadedFilePath) const downloadedFileHash = crypto.createHash('sha384').update(downloadedFileData).digest('hex') diff --git a/test/e2e/integration/core/platform_installer_e2e.test.ts b/test/e2e/integration/core/platform_installer_e2e.test.ts index cb70703b7..607898ac9 100644 --- a/test/e2e/integration/core/platform_installer_e2e.test.ts +++ b/test/e2e/integration/core/platform_installer_e2e.test.ts @@ -98,7 +98,7 @@ e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefi }).timeout(defaultTimeout) it('should succeed with valid tag and pod', async () => { - await expect(installer.fetchPlatform(podName, packageVersion)).to.eventually.be.ok + expect(await installer.fetchPlatform(podName, packageVersion)).to.be.true const outputs = await k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`) testLogger.showUser(outputs) }).timeout(MINUTES) diff --git a/test/test_add.ts b/test/test_add.ts index 63db5b381..b0559cdd7 100644 --- a/test/test_add.ts +++ b/test/test_add.ts @@ -76,7 +76,7 @@ export function testNodeAdd (localBuildPath: string, testDescription = 'Node add }).timeout(defaultTimeout) it('should succeed with init command', async () => { - await expect(accountCmd.init(argv)).to.eventually.be.ok + expect(await accountCmd.init(argv)).to.be.true }).timeout(8 * MINUTES) it('should add a new node to the network successfully', async () => { diff --git a/test/test_util.ts b/test/test_util.ts index 0cc23f675..9683b699c 100644 --- a/test/test_util.ts +++ b/test/test_util.ts @@ -243,7 +243,7 @@ export function e2eTestSuite ( }).timeout(2 * MINUTES) it('generate key files', async () => { - await expect(nodeCmd.handlers.keys(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.keys(argv)).to.be.true expect(nodeCmd.getUnusedConfigs(NodeCommandConfigs.KEYS_CONFIGS_NAME)).to.deep.equal([ flags.devMode.constName, flags.quiet.constName @@ -274,7 +274,7 @@ export function e2eTestSuite ( it('should succeed with node setup command', async () => { // cache this, because `solo node setup.finalize()` will reset it to false try { - await expect(nodeCmd.handlers.setup(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.setup(argv)).to.be.true expect(nodeCmd.getUnusedConfigs(NodeCommandConfigs.SETUP_CONFIGS_NAME)).to.deep.equal([ flags.devMode.constName ]) @@ -286,7 +286,7 @@ export function e2eTestSuite ( it('should succeed with node start command', async () => { try { - await expect(nodeCmd.handlers.start(argv)).to.eventually.be.ok + expect(await nodeCmd.handlers.start(argv)).to.be.true } catch (e) { nodeCmd.logger.showUserError(e) expect.fail() diff --git a/test/unit/core/key_manager.test.ts b/test/unit/core/key_manager.test.ts index c7c29c15d..f66655946 100644 --- a/test/unit/core/key_manager.test.ts +++ b/test/unit/core/key_manager.test.ts @@ -45,10 +45,10 @@ describe('KeyManager', () => { expect(nodeKey.privateKey.algorithm).to.deep.equal(signingKey.privateKey.algorithm) expect(nodeKey.privateKey.type).to.deep.equal(signingKey.privateKey.type) - await expect(signingKey.certificate.verify({ + expect(await signingKey.certificate.verify({ publicKey: signingKey.certificate.publicKey, signatureOnly: true - })).to.eventually.be.ok + })).to.be.true fs.rmSync(tmpDir, { recursive: true }) }) @@ -72,10 +72,10 @@ describe('KeyManager', () => { expect(nodeKey.privateKey.algorithm).to.deep.equal(tlsKey.privateKey.algorithm) expect(nodeKey.privateKey.type).to.deep.equal(tlsKey.privateKey.type) - await expect(tlsKey.certificate.verify({ + expect(await tlsKey.certificate.verify({ publicKey: tlsKey.certificate.publicKey, signatureOnly: true - })).to.eventually.be.ok + })).to.be.true fs.rmSync(tmpDir, { recursive: true }) }).timeout(20 * SECONDS)