Skip to content

Commit

Permalink
Add testcase for reference contract not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Aug 21, 2024
1 parent 79a9629 commit 16df025
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/core/src/cli/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,28 @@ test('validate - references other build info dir by command - ok', async t => {
t.snapshot(output);
});

test('validate - references other build info dir by command - contract not found due to wrong dir in reference', async t => {
const temp = await getTempDir(t);
const referenceDir = path.join(temp, 'build-info-v1');
await fs.mkdir(referenceDir);

const referenceBuildInfo = await artifacts.getBuildInfo(`contracts/test/cli/ValidateBuildInfoV1.sol:MyContract`);
await fs.writeFile(path.join(referenceDir, 'validate.json'), JSON.stringify(referenceBuildInfo));

const updatedDir = path.join(temp, 'build-info');
await fs.mkdir(updatedDir);

const updatedBuildInfo = await artifacts.getBuildInfo(`contracts/test/cli/ValidateBuildInfoV2_Ok.sol:MyContract`);
await fs.writeFile(path.join(updatedDir, 'validate.json'), JSON.stringify(updatedBuildInfo));

const error = await t.throwsAsync(
execAsync(
`${CLI} validate ${updatedDir} --referenceBuildInfoDirs ${referenceDir} --contract MyContract --reference build-info-NOT-FOUND:MyContract`,
),
);
t.true(error?.message.includes('Could not find contract build-info-NOT-FOUND:MyContract.'), error?.message);
});

test('validate - references other build info dir by command with fully qualified names - ok', async t => {
const temp = await getTempDir(t);
const referenceDir = path.join(temp, 'build-info-v1');
Expand Down

0 comments on commit 16df025

Please sign in to comment.