Skip to content

Commit 994e676

Browse files
committed
big clear-out: remove hh truffle ';use Ganache'
1 parent f9889b0 commit 994e676

File tree

9 files changed

+93
-60
lines changed

9 files changed

+93
-60
lines changed

deployment/deploy/30-deploy-RegisterDeployedStakingModules.js

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const func = async function () {
3535
//TODO: 2 options:
3636
// [x] - register directly (e.g. for the testnet) create tx for multisig
3737
// [ ] - create tx for multisig or SIP
38-
log("hre.network.live", hre.network.live);
3938
if (stakingRegisterModuleWithMultisig() && hre.network.live) {
4039
const iStakingModulesProxy = new ethers.utils.Interface(proxyDeployment.abi);
4140
const data = iStakingModulesProxy.encodeFunctionData("addModules", [moduleAddressList]);

hardhat-ganache-tests.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//TODO: remove this legacy config for tests using truffle ganache as a workaround before hh
2+
// added instant blocks advance
13
const { default: Ganache } = require("ganache-core");
24
const { task } = require("hardhat/config");
35

hardhat.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ module.exports = {
166166
},
167167
mocha: {
168168
timeout: 800000,
169-
grep: "^(?!.*; using Ganache).*",
170169
},
171170
namedAccounts: {
172171
deployer: 0,

hardhat/helpers.js

Whitespace-only changes.

hardhat/tasks/tasks.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
hre = require("hardhat");
2+
const { task } = require("hardhat/config");
3+
4+
const { ethers } = hre;
5+
// This is a sample Hardhat task. To learn how to create your own go to
6+
// https://hardhat.org/guides/create-task.html
7+
/// this is for use with ethers.js
8+
task("accounts", "Prints the list of accounts", async () => {
9+
const accounts = await ethers.getSigners();
10+
11+
for (const account of accounts.address) {
12+
const wallet = ethers.Wallet.fromMnemonic(
13+
"test test test test test test test test test test test junk",
14+
"m/44'/60'/0'/0"
15+
);
16+
17+
console.log(account);
18+
}
19+
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"lint-js": "eslint . --ext .js",
7979
"prettier": "prettier --write .",
8080
"prettier-check": "prettier --check .",
81-
"test": "echo Executing pure Hardhat test cases ... && npx hardhat test && echo Executing test cases using Ganache ... && npx hardhat --config hardhat-ganache-tests.config.js --network ganache test",
81+
"test": "npx hardhat test",
8282
"uml": "npx sol2uml ./contracts -o UML.svg",
8383
"generate-types": "npx typechain --target=web3-v1 'abi/**/*.json' && npx typechain --target=ethers-v5 'abi/**/*.json'",
8484
"compile": "npx hardhat compile",

tests/Governance/GovernorAlpha/QueueTest.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
const { expectRevert, BN } = require("@openzeppelin/test-helpers");
11+
const { mine } = require("@nomicfoundation/hardhat-network-helpers");
1112

1213
const {
1314
etherMantissa,
@@ -16,6 +17,7 @@ const {
1617
increaseTime,
1718
} = require("../../Utils/Ethereum");
1819
const { deployAndGetIStaking } = require("../../Utils/initializer");
20+
const { ethers } = require("hardhat");
1921

2022
const GovernorAlpha = artifacts.require("GovernorAlphaMockup");
2123
const Timelock = artifacts.require("TimelockHarness");
@@ -92,9 +94,11 @@ contract("GovernorAlpha#queue/1", (accounts) => {
9294
);
9395
});
9496

95-
it("reverts on queueing overlapping actions in different proposals, works if waiting; using Ganache", async () => {
97+
it("reverts on queueing overlapping actions in different proposals, works if waiting", async () => {
9698
await enfranchise(token, staking, a2, QUORUM_VOTES);
97-
await mineBlock();
99+
//await mineBlock();
100+
101+
await mine();
98102

99103
const targets = [staking.address];
100104
const values = ["0"];
@@ -110,15 +114,20 @@ contract("GovernorAlpha#queue/1", (accounts) => {
110114

111115
await gov.castVote(proposalId1, true, { from: a1 });
112116
await gov.castVote(proposalId2, true, { from: a2 });
113-
await advanceBlocks(30);
114117

118+
await mine(30);
115119
await expectRevert(
116120
gov.queueProposals([proposalId1, proposalId2]),
117121
"GovernorAlpha::_queueOrRevert: proposal action already queued at eta"
118122
);
119123

120124
await gov.queue(proposalId1);
121-
await increaseTime(60);
125+
//await increaseTime(60);
126+
//blockTimestamp = new BigNumber((await ethers.provider.getBlock("latest")).timestamp);
127+
//setNextBlockTimestamp(blockTimestamp.plus(60).toNumber());
128+
await ethers.provider.send("evm_increaseTime", [60]);
129+
await mine();
130+
122131
await gov.queue(proposalId2);
123132
});
124133
});

tests/vesting/FourYearVesting.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const { expect } = require("chai");
22
const { expectRevert, expectEvent, constants, BN } = require("@openzeppelin/test-helpers");
33
const { increaseTime, lastBlock } = require("../Utils/Ethereum");
44
const { deployAndGetIStaking, initializeStakingModulesAt } = require("../Utils/initializer");
5+
const hre = require("hardhat");
6+
const { ethers } = hre;
57

68
const StakingLogic = artifacts.require("IStaking");
79
const StakingProxy = artifacts.require("StakingProxy");
@@ -22,6 +24,11 @@ const TOTAL_SUPPLY = "10000000000000000000000000";
2224
const ONE_MILLON = "1000000000000000000000000";
2325
const ONE_ETHER = "1000000000000000000";
2426

27+
const increaseTimeEthers = async (time) => {
28+
await ethers.provider.send("evm_increaseTime", [time]);
29+
await ethers.provider.send("evm_mine");
30+
};
31+
2532
contract("FourYearVesting", (accounts) => {
2633
let root, a1, a2, a3;
2734
let token, staking, stakingLogic, stakingProxy, feeSharingProxy;
@@ -313,7 +320,7 @@ contract("FourYearVesting", (accounts) => {
313320
});
314321
});
315322

316-
describe("stakeTokens; using Ganache", () => {
323+
describe("stakeTokens", () => {
317324
// Check random scenarios
318325
let vesting;
319326
it("should stake 1,000,000 SOV with a duration of 156 weeks and a 4 week cliff", async () => {
@@ -377,8 +384,8 @@ contract("FourYearVesting", (accounts) => {
377384

378385
// negative cases
379386

380-
// start-10 to avoid coming to active checkpoint
381-
let periodFromKickoff = Math.floor((start - 10 - kickoffTS.toNumber()) / (2 * WEEK));
387+
// start-100 to avoid coming to active checkpoint
388+
let periodFromKickoff = Math.floor((start - 100 - kickoffTS.toNumber()) / (2 * WEEK));
382389
let startBuf = periodFromKickoff * 2 * WEEK + kickoffTS.toNumber();
383390
let userStakingCheckpoints = await staking.userStakingCheckpoints(
384391
vesting.address,
@@ -435,7 +442,7 @@ contract("FourYearVesting", (accounts) => {
435442
remainingStakeAmount = await vesting.remainingStakeAmount();
436443
}
437444

438-
await increaseTime(52 * WEEK);
445+
await increaseTimeEthers(52 * WEEK);
439446
await token.approve(vesting.address, amount);
440447
await expectRevert(vesting.stakeTokens(amount, 0), "create new vesting address");
441448
});
@@ -565,7 +572,7 @@ contract("FourYearVesting", (accounts) => {
565572
remainingStakeAmount = await vesting.remainingStakeAmount();
566573
assert.equal(remainingStakeAmount, 0);
567574

568-
let block = await web3.eth.getBlock("latest");
575+
let block = await ethers.provider.getBlock("latest");
569576
let timestamp = block.timestamp;
570577

571578
let start = timestamp + cliff;
@@ -625,7 +632,7 @@ contract("FourYearVesting", (accounts) => {
625632
let amountAfterStake = await token.balanceOf(root);
626633

627634
// time travel
628-
await increaseTime(104 * WEEK);
635+
await increaseTimeEthers(104 * WEEK);
629636

630637
// withdraw
631638
tx = await vesting.withdrawTokens(root);
@@ -675,7 +682,7 @@ contract("FourYearVesting", (accounts) => {
675682
let amountAfterStake = await token.balanceOf(root);
676683

677684
// time travel
678-
await increaseTime(34 * WEEK);
685+
await increaseTimeEthers(34 * WEEK);
679686

680687
// withdraw
681688
tx = await vesting.withdrawTokens(root);
@@ -712,7 +719,7 @@ contract("FourYearVesting", (accounts) => {
712719
let amountAfterStake = await token.balanceOf(root);
713720

714721
// time travel
715-
await increaseTime(20 * WEEK);
722+
await increaseTimeEthers(20 * WEEK);
716723
await token.approve(vesting.address, toStake);
717724
await expectRevert(vesting.stakeTokens(toStake, 0), "create new vesting address");
718725

@@ -760,7 +767,7 @@ contract("FourYearVesting", (accounts) => {
760767
let amountOld = await token.balanceOf(root);
761768

762769
// time travel
763-
await increaseTime(2 * WEEK);
770+
await increaseTimeEthers(2 * WEEK);
764771

765772
// withdraw
766773
tx = await vesting.withdrawTokens(a2, { from: a1 });
@@ -775,7 +782,7 @@ contract("FourYearVesting", (accounts) => {
775782
await expectRevert(vesting.withdrawTokens(root, { from: a3 }), "unauthorized");
776783

777784
await expectRevert(vesting.withdrawTokens(root, { from: root }), "unauthorized");
778-
await increaseTime(30 * WEEK);
785+
await increaseTimeEthers(30 * WEEK);
779786
await expectRevert(vesting.withdrawTokens(root, { from: a2 }), "unauthorized");
780787
});
781788

@@ -1013,7 +1020,7 @@ contract("FourYearVesting", (accounts) => {
10131020
});
10141021

10151022
it("should extend duration of first 5 staking periods", async () => {
1016-
await increaseTime(20 * WEEK);
1023+
await increaseTimeEthers(20 * WEEK);
10171024
tx = await vesting.extendStaking();
10181025
data = await staking.getStakes.call(vesting.address);
10191026
expect(data.stakes[0]).to.be.bignumber.equal(data.stakes[15]);
@@ -1024,7 +1031,7 @@ contract("FourYearVesting", (accounts) => {
10241031
});
10251032

10261033
it("should extend duration of next 5 staking periods", async () => {
1027-
await increaseTime(20 * WEEK);
1034+
await increaseTimeEthers(20 * WEEK);
10281035
tx = await vesting.extendStaking();
10291036
data = await staking.getStakes.call(vesting.address);
10301037
expect(data.stakes[0]).to.be.bignumber.equal(data.stakes[15]);
@@ -1035,7 +1042,7 @@ contract("FourYearVesting", (accounts) => {
10351042
});
10361043

10371044
it("should extend duration of next 3 staking periods only", async () => {
1038-
await increaseTime(20 * WEEK);
1045+
await increaseTimeEthers(20 * WEEK);
10391046
tx = await vesting.extendStaking();
10401047
data = await staking.getStakes.call(vesting.address);
10411048
expect(data.stakes[0]).to.be.bignumber.equal(data.stakes[15]);
@@ -1053,7 +1060,7 @@ contract("FourYearVesting", (accounts) => {
10531060

10541061
it("should withdraw unlocked tokens for four year vesting after first year", async () => {
10551062
// time travel
1056-
await increaseTime(104 * WEEK);
1063+
await increaseTimeEthers(104 * WEEK);
10571064

10581065
// withdraw
10591066
tx = await vesting.withdrawTokens(root);
@@ -1124,7 +1131,7 @@ contract("FourYearVesting", (accounts) => {
11241131
expect(delegatee).equal(root);
11251132
}
11261133

1127-
await increaseTime(80 * WEEK);
1134+
await increaseTimeEthers(80 * WEEK);
11281135
let tx = await vesting.extendStaking();
11291136
// delegate
11301137
tx = await vesting.delegate(a1);

0 commit comments

Comments
 (0)