Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the first batch of solidity build system tests #6194

Merged
merged 7 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,9 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
return result;
}

public async cleanupArtifacts(): Promise<void> {
public async cleanupArtifacts(rootFilePaths: string[]): Promise<void> {
log(`Cleaning up artifacts`);

const rootFilePaths = await this.getRootFilePaths();

const publicSourceNames = rootFilePaths.map((rootFilePath) => {
const parsed = parseRootPath(rootFilePath);
return isNpmParsedRootPath(parsed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export type ParsedRootPath = { npmPath: string } | { fsPath: string };
* @param rootPath The root path.
* @returns The parsed root path.
*/
export function parseRootPath(
rootPath: string,
): { npmPath: string } | { fsPath: string } {
export function parseRootPath(rootPath: string): ParsedRootPath {
if (rootPath.startsWith("npm:")) {
return { npmPath: rootPath.substring(4) };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { DependencyGraphImplementation } from "./dependency-graph.js";
import type {
SolcConfig,
SolidityBuildProfileConfig,
} from "../../../../types/config.js";
import type { CompilationJobCreationError } from "../../../../types/solidity/build-system.js";
import type { ResolvedFile } from "../../../../types/solidity/resolved-file.js";
import type { DependencyGraph } from "../../../../types/solidity.js";

import { assertHardhatInvariant } from "@ignored/hardhat-vnext-errors";
import { shortenPath } from "@ignored/hardhat-vnext-utils/path";
Expand All @@ -30,7 +30,7 @@ export class SolcConfigSelector {
constructor(
buildProfileName: string,
buildProfile: SolidityBuildProfileConfig,
_dependencyGraph: DependencyGraphImplementation,
_dependencyGraph: DependencyGraph,
) {
this.#buildProfileName = buildProfileName;
this.#buildProfile = buildProfile;
Expand All @@ -45,7 +45,7 @@ export class SolcConfigSelector {
* CompilationJobCreationError if no compatible solc version could be found.
*/
public selectBestSolcConfigForSingleRootGraph(
subgraph: DependencyGraphImplementation,
subgraph: DependencyGraph,
): SolcConfig | CompilationJobCreationError {
const roots = subgraph.getRoots();

Expand Down Expand Up @@ -105,7 +105,7 @@ export class SolcConfigSelector {

#getCompilationJobCreationError(
root: ResolvedFile,
dependencyGraph: DependencyGraphImplementation,
dependencyGraph: DependencyGraph,
compilerVersions: string[],
overriden: boolean,
): CompilationJobCreationError {
Expand Down Expand Up @@ -165,7 +165,7 @@ export class SolcConfigSelector {

*#getTransitiveDependencies(
root: ResolvedFile,
dependencyGraph: DependencyGraphImplementation,
dependencyGraph: DependencyGraph,
visited = new Set<ResolvedFile>([root]),
): Generator<{
fsPath: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"_format": "hh3-sol-build-info-1",
"id": "89eed7b31e13eec3ee71467386d39108",
"solcVersion": "0.7.1",
"solcLongVersion": "0.7.1+commit.f4a555be",
"publicSourceNameMap": {
"contracts/NoImports.sol": "contracts/NoImports.sol"
},
"input": {
"language": "Solidity",
"sources": {
"contracts/NoImports.sol": {
"content": "// SPDX-License-Identifier: SEE LICENSE IN LICENSE\npragma solidity ^0.7.0;\n\ncontract NoImports {}\n"
}
},
"settings": {
"evmVersion": "istanbul",
"outputSelection": {
"*": {
"": ["ast"]
},
"contracts/NoImports.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
}
},
"remappings": [
"remapped/=npm/@openzeppelin/[email protected]/access/",
"@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"_format": "hh3-sol-build-info-output-1",
"id": "89eed7b31e13eec3ee71467386d39108",
"output": {
"contracts": {
"contracts/NoImports.sol": {
"NoImports": {
"abi": [],
"evm": {
"bytecode": {
"linkReferences": {},
"object": "6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220622ff1f92fb75a340477cc69a6f9fcbbd9518f40d01c4ed0fc96c42f94e05c5a64736f6c63430007010033",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH1 0xF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x3F DUP1 PUSH1 0x1D PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH3 0x2FF1F9 0x2F 0xB7 GAS CALLVALUE DIV PUSH24 0xCC69A6F9FCBBD9518F40D01C4ED0FC96C42F94E05C5A6473 PUSH16 0x6C634300070100330000000000000000 ",
"sourceMap": "76:21:0:-:0;;;;;;;;;;;;;;;;;;;"
},
"deployedBytecode": {
"immutableReferences": {},
"linkReferences": {},
"object": "6080604052600080fdfea2646970667358221220622ff1f92fb75a340477cc69a6f9fcbbd9518f40d01c4ed0fc96c42f94e05c5a64736f6c63430007010033",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x0 DUP1 REVERT INVALID LOG2 PUSH5 0x6970667358 0x22 SLT KECCAK256 PUSH3 0x2FF1F9 0x2F 0xB7 GAS CALLVALUE DIV PUSH24 0xCC69A6F9FCBBD9518F40D01C4ED0FC96C42F94E05C5A6473 PUSH16 0x6C634300070100330000000000000000 ",
"sourceMap": "76:21:0:-:0;;;;;"
},
"methodIdentifiers": {}
},
"metadata": "{\"compiler\":{\"version\":\"0.7.1+commit.f4a555be\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/NoImports.sol\":\"NoImports\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[\":@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/\",\":remapped/=npm/@openzeppelin/[email protected]/access/\"]},\"sources\":{\"contracts/NoImports.sol\":{\"keccak256\":\"0x3a28c66ec59da4cb822584ed8f391ddaff26410fb89766d49d577497823bc5ea\",\"license\":\"SEE LICENSE IN LICENSE\",\"urls\":[\"bzz-raw://fb9c7244739857b5c2b14000e0cdf717a521671457ed04d73bf4dfce002cf454\",\"dweb:/ipfs/QmZH2Ky7fy8Q87bsf7g9wcMnM1qNJQLzjcyQSG8nX84yPY\"]}},\"version\":1}"
}
}
},
"sources": {
"contracts/NoImports.sol": {
"ast": {
"absolutePath": "contracts/NoImports.sol",
"exportedSymbols": { "NoImports": [2] },
"id": 3,
"license": "SEE LICENSE IN LICENSE",
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1,
"literals": ["solidity", "^", "0.7", ".0"],
"nodeType": "PragmaDirective",
"src": "51:23:0"
},
{
"abstract": false,
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"fullyImplemented": true,
"id": 2,
"linearizedBaseContracts": [2],
"name": "NoImports",
"nodeType": "ContractDefinition",
"nodes": [],
"scope": 3,
"src": "76:21:0"
}
],
"src": "51:47:0"
},
"id": 0
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"_format": "hh3-sol-build-info-1",
"id": "c6d3d46c7bda8aac0e4258c216012f50",
"solcVersion": "0.8.22",
"solcLongVersion": "0.8.22+commit.4fc1097e",
"publicSourceNameMap": {
"contracts/A.sol": "contracts/A.sol",
"contracts/B.sol": "contracts/B.sol",
"contracts/C.sol": "contracts/C.sol",
"contracts/D.sol": "contracts/D.sol",
"contracts/E.sol": "contracts/E.sol",
"contracts/UserRemappedImport.sol": "contracts/UserRemappedImport.sol"
},
"input": {
"language": "Solidity",
"sources": {
"contracts/A.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\npragma solidity *;\n\nimport \"./B.sol\";\n\ncontract A is B {}\n"
},
"contracts/B.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract B {}\n"
},
"contracts/C.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"./B.sol\";\n\ncontract C {}\n\ncontract C2 {}\n"
},
"contracts/D.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.22;\n\nimport \"./C.sol\";\n"
},
"contracts/E.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.22;\n\nimport \"./C.sol\";\n"
},
"contracts/UserRemappedImport.sol": {
"content": "// SPDX-License-Identifier: SEE LICENSE IN LICENSE\npragma solidity ^0.8.0;\n\nimport \"remapped/Ownable.sol\";\n"
},
"npm/@openzeppelin/[email protected]/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nabstract contract Ownable {}\n"
}
},
"settings": {
"evmVersion": "shanghai",
"outputSelection": {
"*": {
"": ["ast"]
},
"contracts/A.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
},
"contracts/B.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
},
"contracts/C.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
},
"contracts/D.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
},
"contracts/E.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
},
"contracts/UserRemappedImport.sol": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
}
},
"remappings": [
"remapped/=npm/@openzeppelin/[email protected]/access/",
"@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/"
]
}
}
}
Loading
Loading