Skip to content

Commit 29e56bb

Browse files
authored
hardhat e2e tests (#1030)
* hardhat e2e tests * fix timeout * fix * add proxy test
1 parent 12cc4ed commit 29e56bb

16 files changed

+785
-88
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ lib
7474
## yarn cache
7575
**/.yarn/cache
7676
**/.yarn/install-state.gz
77+
78+
## openzeppelin cache
79+
**/.openzeppelin/

e2e-tests/e2e-hardhat/.eslintrc.js

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,4 @@
11
module.exports = {
2-
env: {
3-
node: true,
4-
},
5-
parser: '@typescript-eslint/parser',
6-
plugins: [
7-
'@typescript-eslint',
8-
'import',
9-
'sort-imports-es6-autofix',
10-
],
11-
extends: [
12-
'eslint:recommended',
13-
'plugin:@typescript-eslint/recommended',
14-
'plugin:import/recommended',
15-
'plugin:import/typescript',
16-
],
17-
rules: {
18-
indent: [2, 2, { SwitchCase: 1 }],
19-
quotes: [2, 'single'],
20-
semi: [1, 'always'],
21-
'no-trailing-spaces': [2],
22-
'quote-props': [2, 'as-needed'],
23-
'eol-last': [2, 'always'],
24-
'object-curly-spacing': [2, 'always'],
25-
'comma-dangle': [2, {
26-
arrays: 'always-multiline',
27-
objects: 'always-multiline',
28-
imports: 'always-multiline',
29-
exports: 'always-multiline',
30-
functions: 'only-multiline',
31-
}],
32-
33-
/* ---------- turn off ---------- */
34-
'@typescript-eslint/no-extra-semi': 0,
35-
'@typescript-eslint/no-use-before-define': 0,
36-
'@typescript-eslint/explicit-member-accessibility': 0,
37-
'@typescript-eslint/naming-convention': 0,
38-
'@typescript-eslint/no-explicit-any': 0, // any is sometimes unavoidable
39-
'@typescript-eslint/consistent-type-definitions': 0, // can use Type and Interface
40-
'@typescript-eslint/explicit-function-return-type': 0, // type inference on return type is useful
41-
'@typescript-eslint/no-parameter-properties': 0,
42-
'@typescript-eslint/typedef': 0,
43-
'no-unused-expressions': 0, // short ciucuit if
44-
'max-lines': 0,
45-
'@typescript-eslint/no-empty-function': 'off',
46-
'@typescript-eslint/explicit-module-boundary-types': 'off',
47-
'sort-imports-es6-autofix/sort-imports-es6': 'warn',
48-
'@typescript-eslint/ban-ts-comment': 'off',
49-
'no-useless-escape': 'off',
50-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
51-
'import/no-named-as-default-member': 'off',
52-
'import/no-named-as-default': 'off',
53-
'@typescript-eslint/no-non-null-assertion': 'off',
54-
'@typescript-eslint/no-unused-vars': [
55-
'warn',
56-
{
57-
argsIgnorePattern: '^_',
58-
varsIgnorePattern: '^_',
59-
caughtErrorsIgnorePattern: '^_',
60-
},
61-
],
62-
},
2+
root: true,
3+
extends: ['../../.eslintrc.js'],
634
};
-514 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pragma solidity =0.8.20;
2+
3+
contract Echo{
4+
string public echo;
5+
uint echoCount;
6+
7+
event NewEcho(string message, uint count);
8+
9+
constructor() {
10+
echo = "Deployed successfully!";
11+
}
12+
13+
function scream(string memory message) public returns(string memory){
14+
echo = message;
15+
echoCount += 1;
16+
emit NewEcho(message, echoCount);
17+
return message;
18+
}
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pragma solidity =0.8.20;
2+
3+
import "hardhat/console.sol";
4+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5+
6+
contract Greeter is Initializable {
7+
string private greeting;
8+
9+
function initialize(string memory _greeting) public initializer {
10+
console.log("Deploying a Greeter with greeting:", _greeting);
11+
greeting = _greeting;
12+
}
13+
14+
function greet() public view returns (string memory) {
15+
return greeting;
16+
}
17+
18+
function setGreeting(string memory _greeting) public {
19+
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
20+
greeting = _greeting;
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pragma solidity =0.8.20;
2+
3+
import "hardhat/console.sol";
4+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5+
import "./Greeter.sol";
6+
7+
contract GreeterV2 is Greeter {
8+
string private greeting;
9+
10+
function setGreetingV2(string memory _greeting) public {
11+
string memory newGreeting = string(abi.encodePacked(_greeting, " - V2"));
12+
console.log("<V2> Changing greeting from '%s' to '%s'", greeting, newGreeting);
13+
setGreeting(newGreeting);
14+
}
15+
}

e2e-tests/e2e-hardhat/contracts/HelloWorld.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity =0.8.9;
1+
pragma solidity =0.8.20;
22

33
contract HelloWorld{
44
string public helloWorld = 'Hello World!';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma solidity =0.8.20;
2+
3+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
4+
5+
contract Token is ERC20 {
6+
constructor(uint256 _initialBalance) ERC20("Token", "TKN") public {
7+
_mint(msg.sender, _initialBalance);
8+
}
9+
}

e2e-tests/e2e-hardhat/hardhat.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import '@nomicfoundation/hardhat-toolbox';
2+
import '@openzeppelin/hardhat-upgrades';
23
import { HardhatUserConfig } from 'hardhat/config';
34

45
const config: HardhatUserConfig = {
5-
solidity: '0.8.9',
6+
solidity: '0.8.20',
67
networks: {
78
acalaFork: {
89
chainId: 787,
@@ -14,7 +15,7 @@ const config: HardhatUserConfig = {
1415
},
1516
},
1617
mocha: {
17-
timeout: 100000,
18+
timeout: 30 * 60 * 1000, // 30 min
1819
},
1920
};
2021

e2e-tests/e2e-hardhat/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "hardhat compile",
99
"lint": "eslint .",
10-
"clean": "rm -rf artifacts/ cache/ typechain-types/",
10+
"clean": "rm -rf artifacts/ cache/ typechain-types/ .openzeppelin/",
1111
"test": "hardhat test",
1212
"test:acalaFork": "hardhat test --network acalaFork"
1313
},
@@ -17,6 +17,9 @@
1717
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
1818
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
1919
"@nomicfoundation/hardhat-verify": "^2.0.0",
20+
"@openzeppelin/contracts": "^4.9.0",
21+
"@openzeppelin/contracts-upgradeable": "5.0.1",
22+
"@openzeppelin/hardhat-upgrades": "3.0.0",
2023
"@typechain/ethers-v6": "^0.5.0",
2124
"@typechain/hardhat": "^9.0.0",
2225
"@types/chai": "^4.2.0",

0 commit comments

Comments
 (0)