Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Oct 19, 2023
1 parent 6bea71a commit a6c125d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions packages/core/src/cli/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,15 @@ test('validate - requireReference - no reference, no upgradesFrom', async t => {
await fs.writeFile(path.join(temp, 'validate.json'), JSON.stringify(buildInfo));

const error = await t.throwsAsync(execAsync(`${CLI} validate ${temp} --contract StorageV1 --requireReference`));
t.true(
error?.message.includes(
'does not specify what contract it upgrades from',
),
error?.message,
);
t.true(error?.message.includes('does not specify what contract it upgrades from'), error?.message);
});

test('validate - requireReference - no reference, has upgradesFrom - safe', async t => {
const temp = await getTempDir(t);
const buildInfo = await artifacts.getBuildInfo(`contracts/test/cli/Validate.sol:BecomesSafe`);
await fs.writeFile(path.join(temp, 'validate.json'), JSON.stringify(buildInfo));

const output = (await (execAsync(`${CLI} validate ${temp} --contract BecomesSafe --requireReference`))).stdout;
const output = (await execAsync(`${CLI} validate ${temp} --contract BecomesSafe --requireReference`)).stdout;
t.snapshot(output);
});

Expand All @@ -219,7 +214,9 @@ test('validate - requireReference - has reference - unsafe', async t => {
const buildInfo = await artifacts.getBuildInfo(`contracts/test/cli/Validate.sol:StorageV2_Bad_NoAnnotation`);
await fs.writeFile(path.join(temp, 'validate.json'), JSON.stringify(buildInfo));

const error = await t.throwsAsync(execAsync(`${CLI} validate ${temp} --contract StorageV2_Bad_NoAnnotation --reference StorageV1 --requireReference`));
const error = await t.throwsAsync(
execAsync(`${CLI} validate ${temp} --contract StorageV2_Bad_NoAnnotation --reference StorageV1 --requireReference`),
);
const expectation: string[] = [`Stdout: ${(error as any).stdout}`, `Stderr: ${(error as any).stderr}`];
t.snapshot(expectation.join('\n'));
});
Expand All @@ -229,7 +226,11 @@ test('validate - requireReference - has reference - safe', async t => {
const buildInfo = await artifacts.getBuildInfo(`contracts/test/cli/Validate.sol:StorageV2_Ok_NoAnnotation`);
await fs.writeFile(path.join(temp, 'validate.json'), JSON.stringify(buildInfo));

const output = (await (execAsync(`${CLI} validate ${temp} --contract StorageV2_Ok_NoAnnotation --reference StorageV1 --requireReference`))).stdout;
const output = (
await execAsync(
`${CLI} validate ${temp} --contract StorageV2_Ok_NoAnnotation --reference StorageV1 --requireReference`,
)
).stdout;
t.snapshot(output);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/cli/validate/validate-upgrade-safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SourceContract, validateBuildInfoContracts } from './validations';
*/
export type ValidateUpgradeSafetyOptions = Omit<ValidationOptions, 'kind'> & {
requireReference?: boolean;
}
};

export type SpecifiedContracts = {
contract: SourceContract;
Expand Down Expand Up @@ -70,4 +70,4 @@ export function withCliDefaults(opts: ValidateUpgradeSafetyOptions): Required<Va
...withValidationDefaults(opts),
requireReference: opts.requireReference ?? false,
};
}
}

0 comments on commit a6c125d

Please sign in to comment.