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

Migrate test framework to Hardhat, cont. #1194

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"space-infix-ops": ["error"]
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},
"plugins": [
"no-only-tests"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ truffle-security-output.json
etherrouter-address.json
ganache-chain-db
colonyNetwork-*
artifacts/
cache/
.DS_Store
ganache-chain-db-2/
103 changes: 0 additions & 103 deletions contracts/testHelpers/TestExtensions.sol

This file was deleted.

32 changes: 32 additions & 0 deletions contracts/testHelpers/testExtensions/TestExtension0.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { TestExtensionBase } from "./TestExtensionBase.sol";

contract TestExtension0 is TestExtensionBase {
function identifier() public pure override returns (bytes32) {
return keccak256("TestExtension");
}

function version() public pure override returns (uint256) {
return 0;
}
}
36 changes: 36 additions & 0 deletions contracts/testHelpers/testExtensions/TestExtension1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { TestExtensionBase } from "./TestExtensionBase.sol";

contract TestExtension1 is TestExtensionBase {
function identifier() public pure override returns (bytes32) {
return keccak256("TestExtension");
}

function version() public pure override returns (uint256) {
return 1;
}

function receiveEther() external payable {} // solhint-disable-line no-empty-blocks

function foo() public notDeprecated {} // solhint-disable-line no-empty-blocks
}
32 changes: 32 additions & 0 deletions contracts/testHelpers/testExtensions/TestExtension2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { TestExtensionBase } from "./TestExtensionBase.sol";

contract TestExtension2 is TestExtensionBase {
function identifier() public pure override returns (bytes32) {
return keccak256("TestExtension");
}

function version() public pure override returns (uint256) {
return 2;
}
}
32 changes: 32 additions & 0 deletions contracts/testHelpers/testExtensions/TestExtension3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { TestExtensionBase } from "./TestExtensionBase.sol";

contract TestExtension3 is TestExtensionBase {
function identifier() public pure override returns (bytes32) {
return keccak256("TestExtension");
}

function version() public pure override returns (uint256) {
return 3;
}
}
41 changes: 41 additions & 0 deletions contracts/testHelpers/testExtensions/TestExtensionBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { ColonyExtensionMeta } from "./../../extensions/ColonyExtensionMeta.sol";
import { IColony } from "./../../colony/IColony.sol";

abstract contract TestExtensionBase is ColonyExtensionMeta {
function install(address _colony) public override auth {
require(address(colony) == address(0x0), "extension-already-installed");

colony = IColony(_colony);
}

function finishUpgrade() public override auth {} // solhint-disable-line no-empty-blocks

function deprecate(bool _deprecated) public override auth {
deprecated = _deprecated;
}

function uninstall() public override auth {
selfdestruct(payable(address(colony)));
}
}
40 changes: 40 additions & 0 deletions contracts/testHelpers/testExtensions/TestVotingToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
This file is part of The Colony Network.

The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/

pragma solidity 0.8.23;
pragma experimental ABIEncoderV2;

import { TestExtensionBase } from "./TestExtensionBase.sol";

contract TestVotingToken is TestExtensionBase {
function identifier() public pure override returns (bytes32) {
return keccak256("VotingToken");
}

function version() public pure override returns (uint256) {
return 1;
}

function lockToken() public returns (uint256) {
return colony.lockToken();
}

function unlockTokenForUser(address _user, uint256 _lockId) public {
colony.unlockTokenForUser(_user, _lockId);
}
}
25 changes: 25 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/* global config, task, runSuper */

const fs = require("fs");
const path = require("path");

require("@nomicfoundation/hardhat-ethers");
require("@nomiclabs/hardhat-truffle5");

task("compile", "Compile Colony contracts with pinned Token").setAction(async () => {
await runSuper();

const pinnedArtifacts = ["Token", "TokenAuthority", "MultiSigWallet"];
const artifactSrc = path.resolve(__dirname, "lib/colonyToken/build/contracts");
for (let i = 0; i < pinnedArtifacts.length; i += 1) {
const artifact = pinnedArtifacts[i];
const artifactDst = `${config.paths.artifacts}/colonyToken/${artifact}.sol`;

if (!fs.existsSync(artifactDst)) {
fs.mkdirSync(artifactDst, { recursive: true });
}
fs.copyFileSync(`${artifactSrc}/Pinned${artifact}.json`, `${artifactDst}/${artifact}.json`);
}
});

module.exports = {
defaultNetwork: "hardhat",
solidity: {
Expand All @@ -18,6 +42,7 @@ module.exports = {
chainId: 2656691,
throwOnCallFailures: false,
throwOnTransactionFailures: false,
allowBlocksWithSameTimestamp: true,
blockGasLimit: 6721975,
accounts: [
{ privateKey: "0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae", balance: "100000000000000000000" },
Expand Down
4 changes: 2 additions & 2 deletions helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const BN = require("bn.js");
const shortid = require("shortid");
const { ethers } = require("ethers");

const HASHZERO = ethers.constants.HashZero;
const ADDRESS_ZERO = ethers.constants.AddressZero;
const HASHZERO = ethers.ZeroHash;
const ADDRESS_ZERO = ethers.ZeroAddress;

const UINT256_MAX = new BN(0).notn(256);
const UINT128_MAX = new BN(0).notn(128);
Expand Down
Loading