Skip to content

Commit

Permalink
feat: add skeleton solidity test plugin
Browse files Browse the repository at this point in the history
This is based on the `@ignored/edr` version that comes from the Solidity
Test branch of EDR.

We create a skeleton `solidity-test` plugin, that leverages the
artifacts manager to find contracts and test contracts and pass them off
to the EDR Solidity Test Runner before displaying the results.
  • Loading branch information
kanej committed Sep 26, 2024
1 parent d2c2575 commit a71acb7
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 19 deletions.
66 changes: 66 additions & 0 deletions pnpm-lock.yaml

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

10 changes: 10 additions & 0 deletions v-next/example-project/contracts/Counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Counter {
uint public x;

function inc() public {
x++;
}
}
21 changes: 21 additions & 0 deletions v-next/example-project/contracts/Counter.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./Counter.sol";

contract CounterTest {
Counter counter;

function setUp() public {
counter = new Counter();
}

function testInitialValue() public view {
require(counter.x() == 0, "Initial value should be 0");
}

function testInc() public {
counter.inc();
require(counter.x() == 1, "Value after inc should be 1");
}
}
13 changes: 13 additions & 0 deletions v-next/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const ERROR_CATEGORIES: {
max: 999,
websiteTitle: "Network-helpers errors",
},
SOLIDITY_TESTS: {
min: 1000,
max: 1099,
websiteTitle: "Solidity tests errors",
},
};

export const ERRORS = {
Expand Down Expand Up @@ -685,4 +690,12 @@ This might be caused by using hardhat_reset and loadFixture calls in a testcase.
websiteDescription: "Error while reverting snapshot",
},
},
SOLIDITY_TESTS: {
BUILD_INFO_NOT_FOUND_FOR_CONTRACT: {
number: 1000,
messageTemplate: `Build info not found for contract {fqn}`,
websiteTitle: `Build info not found for contract`,
websiteDescription: `Build info not found for contract while compiling Solidity test contracts.`,
},
},
} as const;
1 change: 1 addition & 0 deletions v-next/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"typescript-eslint": "7.7.1"
},
"dependencies": {
"@ignored/edr": "0.6.2-alpha.0",
"@ignored/hardhat-vnext-build-system": "workspace:^3.0.0-next.2",
"@ignored/hardhat-vnext-errors": "workspace:^3.0.0-next.2",
"@ignored/hardhat-vnext-utils": "workspace:^3.0.0-next.2",
Expand Down
Loading

0 comments on commit a71acb7

Please sign in to comment.