Skip to content

Commit

Permalink
test: refactor to BuildInfo
Browse files Browse the repository at this point in the history
We are attempting to use `any` and testing casting less.
  • Loading branch information
kanej committed Jun 3, 2024
1 parent a1280bb commit 77933e0
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions packages/core/test/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,59 @@ describe("verify", () => {
});

describe("getImportSourceNames", () => {
const exampleBuildInfo: BuildInfo = {
_format: "hh-sol-artifact-1",
id: "example",
solcVersion: "0.8.19",
solcLongVersion: "0.8.19+commit.7dd6d404",
input: {
language: "Solidity",
settings: {
optimizer: {},
outputSelection: {},
},
sources: {},
},
output: {
contracts: {},
sources: {},
},
};

it("should handle circular imports", () => {
const buildInfo = {
const buildInfo: BuildInfo = {
...exampleBuildInfo,
input: {
...exampleBuildInfo.input,
sources: {
"contracts/A.sol": {
content: 'import "./B.sol";',
},
"contracts/B.sol": {
content: 'import "./A.sol";',
},
},
},
};

const result = getImportSourceNames("contracts/A.sol", buildInfo);

assert.deepEqual(result, ["contracts/B.sol", "contracts/A.sol"]);
});

it("should handle indirect circular imports", () => {
const buildInfo: BuildInfo = {
...exampleBuildInfo,
input: {
...exampleBuildInfo.input,
sources: {
"contracts/A.sol": {
content: 'import "./B.sol";',
},
"contracts/B.sol": {
content: 'import "./C.sol";',
},
"contracts/C.sol": {
content: 'import "./A.sol";',
},
},
Expand All @@ -223,7 +268,11 @@ describe("verify", () => {
buildInfo as unknown as BuildInfo
);

assert.deepEqual(result, ["contracts/B.sol", "contracts/A.sol"]);
assert.deepEqual(result, [
"contracts/B.sol",
"contracts/C.sol",
"contracts/A.sol",
]);
});
});
});

0 comments on commit 77933e0

Please sign in to comment.