Skip to content

Commit

Permalink
Add test for consistent build-info names
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed Nov 1, 2022
1 parent f6c74bc commit c6420a3
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/hardhat-core/test/builtin-tasks/compile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from "chai";
import ci from "ci-info";
import * as fsExtra from "fs-extra";
import * as path from "path";

Expand Down Expand Up @@ -817,4 +818,30 @@ Read about compiler configuration at https://hardhat.org/config
});
});
});

describe("project where two contracts import the same dependency", function () {
useFixtureProject("consistent-build-info-names");
useEnvironment();

it("should always produce the same build-info name", async function () {
await this.env.run("compile");

const buildInfos = getBuildInfos();
assert.lengthOf(buildInfos, 1);

const expectedBuildInfoName = buildInfos[0];

const runs = ci.isCI ? 10 : 100;

for (let i = 0; i < runs; i++) {
await this.env.run("clean");
await this.env.run("compile");

const newBuildInfos = getBuildInfos();
assert.lengthOf(newBuildInfos, 1);

assert.equal(newBuildInfos[0], expectedBuildInfoName);
}
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
artifacts/
cache/
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.7.0;

import "dependency/contracts/Dep1.sol";
import "dependency/contracts/Dep2.sol";

contract A {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma solidity ^0.7.0;

import "dependency/contracts/Dep1.sol";

contract B {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
solidity: "0.7.3",
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6420a3

Please sign in to comment.