Skip to content

Commit

Permalink
expect(await instead of await expect(
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Nov 19, 2024
1 parent b1a5ee3 commit 279d730
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions test/e2e/commands/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/commands/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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', () => {
Expand Down Expand Up @@ -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)
})
8 changes: 4 additions & 4 deletions test/e2e/commands/mirror_node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/commands/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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...')
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/commands/relay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/e2e_node_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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}`)
Expand All @@ -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()
Expand All @@ -139,7 +139,7 @@ export function e2eNodeKeyRefreshTest (testName: string, mode: string, releaseTa
function nodeRefreshShouldSucceed (nodeAlias: NodeAlias, nodeCmd: NodeCommand, argv: Record<any, any>) {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/integration/core/k8_e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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' ]
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/integration/core/platform_installer_e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 3 additions & 3 deletions test/test_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
])
Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions test/unit/core/key_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
Expand All @@ -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)
Expand Down

0 comments on commit 279d730

Please sign in to comment.