diff --git a/packages/core/src/cli/validate/validate-upgrade-safety.test.ts b/packages/core/src/cli/validate/validate-upgrade-safety.test.ts index 0489592a1..149385ffb 100644 --- a/packages/core/src/cli/validate/validate-upgrade-safety.test.ts +++ b/packages/core/src/cli/validate/validate-upgrade-safety.test.ts @@ -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 () => { @@ -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.', + ), + ); + } +}); diff --git a/packages/core/src/cli/validate/validate-upgrade-safety.ts b/packages/core/src/cli/validate/validate-upgrade-safety.ts index b54b1321f..afcdb28f9 100644 --- a/packages/core/src/cli/validate/validate-upgrade-safety.ts +++ b/packages/core/src/cli/validate/validate-upgrade-safety.ts @@ -45,7 +45,7 @@ export async function validateUpgradeSafety( return getProjectReport(contractReports); } -function findSpecifiedContracts( +export function findSpecifiedContracts( sourceContracts: SourceContract[], opts: Required, contractName?: string,