Skip to content

Commit 1b04366

Browse files
committed
removed all uses of ganache
1 parent d69e4b0 commit 1b04366

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

.github/workflows/call.deploy-dry-run.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
network:
77
required: true
88
type: string
9-
network-id:
10-
required: true
11-
type: string
129
provider-url:
1310
required: true
1411
type: string
@@ -28,8 +25,11 @@ jobs:
2825
yarn install --frozen-lockfile
2926
yarn build-for-contracts-dev
3027
31-
- name: Start ganache
32-
run: npx ganache --port 47545 --mnemonic --fork.url ${{ github.event.inputs.provider-url }} --network-id ${{ github.event.inputs.network-id }} --chain.chainId ${{ github.event.inputs.network-id }}
28+
- name: Start hardhat node
29+
run: |
30+
cd ${{ env.ethereum-contracts-working-directory }}
31+
npx hardhat node --port 47545 --fork ${{ github.event.inputs.provider-url }} &
32+
sleep 5
3333
3434
- name: Deploy framework
3535
run: |

packages/ethereum-contracts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Run the test suite for core contracts:
355355
yarn run-hardhat test testsuites/superfluid-core.js
356356
```
357357

358-
The `pretest` script starts a ganache instance with deterministic accounts in the background, the `posttest` script stops it.
358+
The `pretest` script starts a local dev chain with deterministic accounts in the background, the `posttest` script stops it.
359359
When running tests with `yarn test`, those get executed automatically (see [npm docs](https://docs.npmjs.com/cli/v7/using-npm/scripts#pre--post-scripts)).
360360
> NOTE: You don't need to run the `pretest` and `posttest` scripts when running hardhat tests, but you do when running tests with truffle.
361361

packages/ethereum-contracts/ops-scripts/libs/getConfig.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ module.exports = function getConfig(chainId) {
1111
// this is a fake forwarder address, it is to test the deployment script
1212
trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"],
1313
},
14-
5777: {
15-
// for local testing (external ganache)
16-
// this is a fake forwarder address, it is to test the deployment script
17-
trustedForwarders: ["0x3075b4dc7085C48A14A5A39BBa68F58B19545971"],
18-
},
1914
6777: {
2015
// for coverage testing
2116
// this is a fake forwarder address, it is to test the deployment script

packages/ethereum-contracts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"async": "^3.2.6",
2323
"csv-writer": "^1.6.0",
2424
"ethers": "^5.7.2",
25-
"ganache-time-traveler": "^1.0.16",
2625
"mochawesome": "^7.1.3",
2726
"readline": "^1.3.0",
2827
"solidity-coverage": "^0.8.17",

packages/ethereum-contracts/test/TestEnvironment.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232

3333
const {web3tx, wad4human} = require("@decentral.ee/web3-helpers");
3434
const SuperfluidSDK = require("@superfluid-finance/js-sdk");
35-
const traveler = require("ganache-time-traveler");
3635

3736
const deployFramework = require("../ops-scripts/deploy-framework");
3837
const deploySuperToken = require("../ops-scripts/deploy-super-token");
@@ -161,6 +160,22 @@ export default class TestEnvironment {
161160
console.debug("popEvmSnapshot", JSON.stringify(this._evmSnapshots));
162161
}
163162

163+
/**
164+
* Advance time by specified seconds and mine a block (replaces ganache-time-traveler.advanceTimeAndBlock)
165+
*/
166+
async _advanceTimeAndBlock(seconds: number) {
167+
await network.provider.send("evm_increaseTime", [seconds]);
168+
await network.provider.send("evm_mine", []);
169+
}
170+
171+
/**
172+
* Set the next block's timestamp and mine a block (replaces ganache-time-traveler.advanceBlockAndSetTime)
173+
* Uses evm_mine with timestamp parameter, matching ganache-time-traveler behavior
174+
*/
175+
async _advanceBlockAndSetTime(timestamp: number) {
176+
await network.provider.send("evm_mine", [timestamp]);
177+
}
178+
164179
async useLastEvmSnapshot() {
165180
let oldEvmSnapshotId = "";
166181
const popped = this._evmSnapshots.pop();
@@ -171,10 +186,6 @@ export default class TestEnvironment {
171186
} = popped);
172187
}
173188
await this._revertToEvmSnapShot(oldEvmSnapshotId);
174-
// move the time to now
175-
await traveler.advanceBlockAndSetTime(
176-
parseInt((Date.now() / 1000).toString())
177-
);
178189
const newEvmSnapshotId = await this._takeEvmSnapshot();
179190
this._evmSnapshots.push({
180191
id: newEvmSnapshotId,
@@ -192,7 +203,7 @@ export default class TestEnvironment {
192203
const block1 = await ethers.provider.getBlock("latest");
193204
console.log("current block time", block1.timestamp);
194205
console.log(`time traveler going to the future +${jsNumTime}...`);
195-
await traveler.advanceTimeAndBlock(jsNumTime);
206+
await this._advanceTimeAndBlock(jsNumTime);
196207
const block2 = await ethers.provider.getBlock("latest");
197208
console.log("new block time", block2.timestamp);
198209
}

packages/ethereum-contracts/truffle-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ const E = (module.exports = {
171171
networks: {
172172
// Useful for testing. The `development` name is special - truffle uses it by default
173173
// if it's defined here and no other network is specified at the command line.
174-
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
175-
// tab if you use this network and you must also set the `host`, `port` and `network_id`
174+
// You should run a client in a separate terminal tab
175+
// if you use this network and you must also set the `host`, `port` and `network_id`
176176
// options below to some value.
177177

178178
//

0 commit comments

Comments
 (0)