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

Fixes errors during remote contract gathering (#153) #166

Merged
merged 2 commits into from
Jan 30, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ test/hardhat-ethers-project/artifacts
test/hardhat-ethers-project/cache
test/hardhat-waffle-project/artifacts
test/hardhat-waffle-project/cache
test/hardhat-forked-project/artifacts
test/hardhat-forked-project/cache
dist/

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ethereum-waffle": "^3.2.1",
"ethers": "^5.0.0",
"ganache-cli": "^6.4.3",
"hardhat": "^2.11.0",
"hardhat": "^2.19.4",
"mocha": "7",
"prettier": "^1.17.0",
"source-map-support": "^0.5.12",
Expand Down
3 changes: 3 additions & 0 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ npx mocha test/ethers.ts --timeout 100000 --exit
# Waffle + HardhatEVM
npx mocha test/waffle.ts --timeout 100000 --exit

# Forked Network + HardhatEVM
npx mocha test/forked.ts --timeout 100000 --exit

# Ethers + Hardhat Node
start_hardhatevm
npx mocha test/hardhatevm.node.ts --timeout 100000 --exit
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async function getResolvedRemoteContracts(
provider: EGRAsyncApiProviderT,
remoteContracts: RemoteContract[] = []
) : Promise <RemoteContract[]> {
const { defualt : sha1 } = await import("sha1");
const { default : sha1 } = await import("sha1");
for (const contract of remoteContracts){
let code;
try {
Expand Down Expand Up @@ -187,7 +187,8 @@ subtask(TASK_TEST_RUN_MOCHA_TESTS).setAction(
const InternalReporterConfig = require('eth-gas-reporter/lib/config');

// Fetch data from gas and coin price providers
options = new InternalReporterConfig(options);
const originalOptions = options
options = new InternalReporterConfig(originalOptions);
await setGasAndPriceRates(options);

mochaConfig = hre.config.mocha || {};
Expand All @@ -211,7 +212,7 @@ subtask(TASK_TEST_RUN_MOCHA_TESTS).setAction(
const asyncProvider = new EGRAsyncApiProvider(hre.network.provider);
resolvedRemoteContracts = await getResolvedRemoteContracts(
asyncProvider,
options.remoteContracts
originalOptions.remoteContracts
);

mochaConfig.reporterOptions.provider = asyncProvider;
Expand Down
13 changes: 13 additions & 0 deletions test/forked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { TASK_TEST } from "hardhat/builtin-tasks/task-names";
// tslint:disable-next-line no-implicit-dependencies
import { assert } from "chai";

import { useEnvironment } from "./helpers";

describe("Forked Network", function() {
useEnvironment(__dirname + "/hardhat-forked-project");

it("default", async function() {
await this.env.run(TASK_TEST, { testFiles: [] });
});
});
281 changes: 281 additions & 0 deletions test/hardhat-forked-project/abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
export const ABI: any = {
wethABI: [
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "guy",
"type": "address"
},
{
"name": "wad",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "src",
"type": "address"
},
{
"name": "dst",
"type": "address"
},
{
"name": "wad",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "wad",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "dst",
"type": "address"
},
{
"name": "wad",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "deposit",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
},
{
"name": "",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "src",
"type": "address"
},
{
"indexed": true,
"name": "guy",
"type": "address"
},
{
"indexed": false,
"name": "wad",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "src",
"type": "address"
},
{
"indexed": true,
"name": "dst",
"type": "address"
},
{
"indexed": false,
"name": "wad",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "dst",
"type": "address"
},
{
"indexed": false,
"name": "wad",
"type": "uint256"
}
],
"name": "Deposit",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "src",
"type": "address"
},
{
"indexed": false,
"name": "wad",
"type": "uint256"
}
],
"name": "Withdrawal",
"type": "event"
}
]
}
Loading