Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Oct 19, 2023
1 parent a6c125d commit d8e2bdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/core/src/cli/validate/validate-upgrade-safety.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from 'path';
import os from 'os';

import { artifacts } from 'hardhat';
import { validateUpgradeSafety } from './validate-upgrade-safety';
import { findSpecifiedContracts, validateUpgradeSafety, withCliDefaults } from './validate-upgrade-safety';
import { ReferenceContractNotFound } from './find-contract';

test.before(async () => {
Expand Down Expand Up @@ -97,3 +97,15 @@ test('invalid annotation args - upgrades', async t => {
);
t.true(error?.message.includes('Found 1, expected 0'));
});

test('findSpecifiedContracts - requireReference option without contract', async t => {
try {
findSpecifiedContracts([], withCliDefaults({ requireReference: true }));
} catch (e: any) {
t.true(
e.message.includes(
'The requireReference option can only be specified when the contract option is also specified.',
),
);
}
});
2 changes: 1 addition & 1 deletion packages/core/src/cli/validate/validate-upgrade-safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function validateUpgradeSafety(
return getProjectReport(contractReports);
}

function findSpecifiedContracts(
export function findSpecifiedContracts(
sourceContracts: SourceContract[],
opts: Required<ValidateUpgradeSafetyOptions>,
contractName?: string,
Expand Down

0 comments on commit d8e2bdd

Please sign in to comment.