Skip to content

Commit

Permalink
fix: updated bootstrap.test.ts to use #410 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Jul 12, 2022
1 parent e7e6ad0 commit 8e5e3b6
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions tests/bin/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('bootstrap', () => {
const password = 'password';
const passwordPath = path.join(dataDir, 'password');
await fs.promises.writeFile(passwordPath, password);
const { exitCode, stdout } = await testBinUtils.pkStdio(
const { exitCode, stdout } = await testBinUtils.pkStdioSwitch(
global.testCmd,
)(
[
'bootstrap',
'--password-file',
Expand Down Expand Up @@ -60,7 +62,9 @@ describe('bootstrap', () => {
await fs.promises.mkdir(path.join(dataDir, 'polykey'));
await fs.promises.writeFile(path.join(dataDir, 'polykey', 'test'), '');
let exitCode, stdout, stderr;
({ exitCode, stdout, stderr } = await testBinUtils.pkStdio(
({ exitCode, stdout, stderr } = await testBinUtils.pkStdioSwitch(
global.testCmd,
)(
[
'bootstrap',
'--node-path',
Expand All @@ -82,7 +86,9 @@ describe('bootstrap', () => {
testBinUtils.expectProcessError(exitCode, stderr, [
errorBootstrapExistingState,
]);
({ exitCode, stdout, stderr } = await testBinUtils.pkStdio(
({ exitCode, stdout, stderr } = await testBinUtils.pkStdioSwitch(
global.testCmd,
)(
[
'bootstrap',
'--node-path',
Expand Down Expand Up @@ -112,7 +118,7 @@ describe('bootstrap', () => {
async () => {
const password = 'password';
const [bootstrapProcess1, bootstrapProcess2] = await Promise.all([
testBinUtils.pkSpawn(
testBinUtils.pkSpawnSwitch(global.testCmd)(
[
'bootstrap',
'--root-key-pair-bits',
Expand All @@ -129,7 +135,7 @@ describe('bootstrap', () => {
dataDir,
logger.getChild('bootstrapProcess1'),
),
testBinUtils.pkSpawn(
testBinUtils.pkSpawnSwitch(global.testCmd)(
[
'bootstrap',
'--root-key-pair-bits',
Expand Down Expand Up @@ -194,7 +200,9 @@ describe('bootstrap', () => {
'bootstrap when interrupted, requires fresh on next bootstrap',
async () => {
const password = 'password';
const bootstrapProcess1 = await testBinUtils.pkSpawn(
const bootstrapProcess1 = await testBinUtils.pkSpawnSwitch(
global.testCmd,
)(
['bootstrap', '--root-key-pair-bits', '1024', '--verbose'],
{
PK_TEST_DATA_PATH: dataDir,
Expand All @@ -219,10 +227,12 @@ describe('bootstrap', () => {
});
});
await new Promise((res) => {
bootstrapProcess1.once('exit', () => res(null))
})
bootstrapProcess1.once('exit', () => res(null));
});
// Attempting to bootstrap should fail with existing state
const bootstrapProcess2 = await testBinUtils.pkStdio(
const bootstrapProcess2 = await testBinUtils.pkStdioSwitch(
global.testCmd,
)(
[
'bootstrap',
'--root-key-pair-bits',
Expand All @@ -246,7 +256,9 @@ describe('bootstrap', () => {
[errorBootstrapExistingState],
);
// Attempting to bootstrap with --fresh should succeed
const bootstrapProcess3 = await testBinUtils.pkStdio(
const bootstrapProcess3 = await testBinUtils.pkStdioSwitch(
global.testCmd,
)(
['bootstrap', '--root-key-pair-bits', '1024', '--fresh', '--verbose'],
{
PK_TEST_DATA_PATH: dataDir,
Expand Down

0 comments on commit 8e5e3b6

Please sign in to comment.