Skip to content

Commit 717a16b

Browse files
committed
fix test cases
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 40d9513 commit 717a16b

File tree

3 files changed

+11
-55
lines changed

3 files changed

+11
-55
lines changed

src/commands/node.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ export class NodeCommand extends BaseCommand {
864864
*/
865865

866866
// create a config object for subsequent steps
867-
const config = /** @type {NodeKeysConfigClass} **/ this.getConfig(NodeCommand.SETUP_CONFIGS_NAME, NodeCommand.SETUP_FLAGS_LIST,
867+
const config = /** @type {NodeKeysConfigClass} **/ this.getConfig(NodeCommand.KEYS_CONFIGS_NAME, NodeCommand.KEYS_FLAGS_LIST,
868868
[
869869
'curDate',
870870
'keysDir',

test/e2e/core/platform_installer_e2e.test.mjs

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ describe('PackageInstallerE2E', () => {
4242
argv[flags.nodeIDs.name] = 'node0'
4343
argv[flags.clusterName.name] = TEST_CLUSTER
4444
argv[flags.fstChartVersion.name] = version.FST_CHART_VERSION
45+
argv[flags.generateGossipKeys.name] = true
46+
argv[flags.generateTlsKeys.name] = true
4547
// set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts
4648
argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined
4749
const bootstrapResp = bootstrapNetwork(namespace, argv, undefined, undefined, undefined, undefined, undefined, undefined, false)
@@ -98,58 +100,4 @@ describe('PackageInstallerE2E', () => {
98100
testLogger.showUser(outputs)
99101
}, 60000)
100102
})
101-
102-
describe('copyGossipKeys', () => {
103-
it('should succeed to copy legacy pfx gossip keys for node0', async () => {
104-
const podName = 'network-node0-0'
105-
const nodeId = 'node0'
106-
107-
// generate pfx keys
108-
const pfxDir = 'test/data/pfx'
109-
await k8.execContainer(podName, constants.ROOT_CONTAINER, ['bash', '-c', `rm -f ${constants.HEDERA_HAPI_PATH}/data/keys/*`])
110-
const fileList = await installer.copyGossipKeys('node0', pfxDir, ['node0'], constants.KEY_FORMAT_PFX)
111-
112-
const destDir = `${constants.HEDERA_HAPI_PATH}/data/keys`
113-
expect(fileList.length).toBe(2)
114-
expect(fileList).toContain(`${destDir}/${Templates.renderGossipPfxPrivateKeyFile(nodeId)}`)
115-
expect(fileList).toContain(`${destDir}/public.pfx`)
116-
}, 60000)
117-
118-
it('should succeed to copy pem gossip keys for node0', async () => {
119-
const podName = 'network-node0-0'
120-
121-
const pemDir = 'test/data/pem'
122-
await k8.execContainer(podName, constants.ROOT_CONTAINER, ['bash', '-c', `rm -f ${constants.HEDERA_HAPI_PATH}/data/keys/*`])
123-
const fileList = await installer.copyGossipKeys('node0', pemDir, ['node0'], constants.KEY_FORMAT_PEM)
124-
125-
const destDir = `${constants.HEDERA_HAPI_PATH}/data/keys`
126-
expect(fileList.length).toBe(4)
127-
expect(fileList).toContain(`${destDir}/${Templates.renderGossipPemPrivateKeyFile(constants.SIGNING_KEY_PREFIX, 'node0')}`)
128-
expect(fileList).toContain(`${destDir}/${Templates.renderGossipPemPrivateKeyFile(constants.AGREEMENT_KEY_PREFIX, 'node0')}`)
129-
130-
// public keys
131-
expect(fileList).toContain(`${destDir}/${Templates.renderGossipPemPublicKeyFile(constants.SIGNING_KEY_PREFIX, 'node0')}`)
132-
expect(fileList).toContain(`${destDir}/${Templates.renderGossipPemPublicKeyFile(constants.AGREEMENT_KEY_PREFIX, 'node0')}`)
133-
}, 60000)
134-
})
135-
136-
describe('copyTLSKeys', () => {
137-
it('should succeed to copy TLS keys for node0', async () => {
138-
const nodeId = 'node0'
139-
const podName = Templates.renderNetworkPodName(nodeId)
140-
const tmpDir = getTmpDir()
141-
142-
// create mock files
143-
const pemDir = 'test/data/pem'
144-
await k8.execContainer(podName, constants.ROOT_CONTAINER, ['bash', '-c', `rm -f ${constants.HEDERA_HAPI_PATH}/hedera.*`])
145-
const fileList = await installer.copyTLSKeys(podName, pemDir)
146-
147-
expect(fileList.length).toBe(2) // [data , hedera.crt, hedera.key]
148-
expect(fileList.length).toBeGreaterThanOrEqual(2)
149-
expect(fileList).toContain(`${constants.HEDERA_HAPI_PATH}/hedera.crt`)
150-
expect(fileList).toContain(`${constants.HEDERA_HAPI_PATH}/hedera.key`)
151-
152-
fs.rmSync(tmpDir, { recursive: true })
153-
}, defaultTimeout)
154-
})
155103
})

test/test_util.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ export function bootstrapNetwork (testName, argv,
220220
}
221221
}, 120000)
222222

223+
it('generate key files', async () => {
224+
await expect(nodeCmd.keys(argv)).resolves.toBeTruthy()
225+
expect(nodeCmd.getUnusedConfigs(NodeCommand.KEYS_CONFIGS_NAME)).toEqual([
226+
flags.cacheDir.constName,
227+
flags.devMode.constName
228+
])
229+
}, 120000)
230+
223231
it('should succeed with network deploy', async () => {
224232
expect.assertions(1)
225233
await networkCmd.deploy(argv)

0 commit comments

Comments
 (0)