Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Hardhat WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesgm committed Apr 7, 2021
1 parent d0b6e87 commit 9b41efd
Show file tree
Hide file tree
Showing 9 changed files with 1,559 additions and 8,024 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ chains/dev/*
*.gateway_history

# Backups
*.bak
*.bak

ethereum/artifacts
ethereum/cache
8 changes: 8 additions & 0 deletions ethereum/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require('@nomiclabs/hardhat-ethers');

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.1",
};
8 changes: 4 additions & 4 deletions ethereum/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ module.exports = {
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
testMatch: [
"**/tests/**/*test.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
Expand Down
19 changes: 9 additions & 10 deletions ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
"version": "1.0.0",
"main": "index.js",
"license": "GPL-3.0",
"dependencies": {
"@ethersproject/wallet": "^5.0.9",
"eth-saddle": "^0.1.23"
},
"dependencies": {},
"scripts": {
"postinstall": "cd node_modules/solidity-parser-antlr && yarn install && yarn build",
"compile": "npx saddle compile",
"test": "npx saddle compile && npx saddle test",
"coverage": "npx saddle compile --trace && npx saddle coverage && npx istanbul report --root=./coverage lcov json",
"console": "NODE_OPTIONS='--experimental-repl-await' npx saddle console",
"script": "npx saddle script"
},
"resolutions": {
"solidity-parser-antlr": "https://github.com/solidity-parser/parser.git",
"ganache-core": "=2.13.2"
},
"devDependencies": {
"@ethersproject/wallet": "^5.1.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"bignumber.js": "^9.0.1",
"chai": "^4.3.4",
"chalk": "^4.1.0",
"istanbul": "^0.4.5"
"ethers": "^5.1.0",
"hardhat": "^2.1.2",
"web3-eth-abi": "^1.3.5",
"web3-utils": "^1.3.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const { expect } = require("chai");
const {
e18,
fromNow,
sendRPC,
ETH_ZERO_ADDRESS
} = require('./utils');

describe('CashToken', () => {
describe.skip('CashToken', () => {
let proxyAdmin;
let cashImpl;
let proxy;
let cash;
let [root, admin, account1, account2, account3] = saddle.accounts;
let root, admin, account1, account2, account3;

let startCashIndex = e18(1);
let start = fromNow(0);
Expand All @@ -26,6 +27,7 @@ describe('CashToken', () => {
}

beforeEach(async () => {
[root, admin, account1, account2, account3] = await ethers.getSigners();
proxyAdmin = await deploy('ProxyAdmin', [], { from: root });
cashImpl = await deploy('CashToken', [admin], { from: root });
proxy = await deploy('TransparentUpgradeableProxy', [
Expand Down
30 changes: 26 additions & 4 deletions ethereum/tests/matchers_ext.js → ethereum/test/matchers_ext.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
const chai = require("chai");
const BigNumber = require("bignumber.js");

expect.extend({
function extend(object) {
Object.entries(object).forEach(([name, matcher]) => {
function wrap(fn) {
return function (right) {
var left = this._obj;
let res = fn(left, right);
if (res.pass) {
return new chai.Assertion(true).to.be.equal(true);
} else {
return new chai.Assertion("").to.be.equal(res.message);
}
}
}
console.log("Extending", name);
chai.Assertion.addMethod(name, wrap(matcher));
});
}

extend({
toMatchAddress(actual, expected) {
actual = actual.hasOwnProperty('address') ? actual.address : actual;
expected = expected.hasOwnProperty('address') ? expected.address : expected;

return {
pass: actual.toLowerCase() == expected.toLowerCase(),
message: () => `expected (${actual}) == (${expected})`
Expand All @@ -16,7 +38,7 @@ expect.extend({
}
});

expect.extend({
extend({
greaterThan(actual, expected) {
return {
pass: (new BigNumber(actual)).gt(new BigNumber(expected)),
Expand All @@ -25,7 +47,7 @@ expect.extend({
}
});

expect.extend({
extend({
toRevert(actual, msg='revert') {
return {
pass: !!actual['message'] && actual.message === `VM Exception while processing transaction: ${msg}`,
Expand All @@ -34,7 +56,7 @@ expect.extend({
}
});

expect.extend({
extend({
toBeWithinRange(received, floor, ceiling) {
const pass = received >= floor && received <= ceiling;
if (pass) {
Expand Down
Loading

0 comments on commit 9b41efd

Please sign in to comment.