-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7beaf44
commit caf1d22
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const assert = require('assert') | ||
const { Terminal } = require('common/src/terminal') | ||
const storage = require('../../src/internal/storage') | ||
|
||
describe('active', function () { | ||
let activeNetwork | ||
const terminal = new Terminal() | ||
|
||
before('get the active network', async function () { | ||
activeNetwork = storage.readNetworks().activeNetwork | ||
}) | ||
|
||
describe('when calling active task', function () { | ||
before('call task', async function () { | ||
await terminal.run('npx hardhat net active') | ||
}) | ||
|
||
it('prints the active network', async function () { | ||
assert.ok( | ||
terminal.output.includes(`The active network is "${activeNetwork}"`), | ||
terminal.output, | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const assert = require('assert') | ||
const { Terminal } = require('common/src/terminal') | ||
const storage = require('../../src/internal/storage') | ||
|
||
describe('set', function () { | ||
const terminal = new Terminal() | ||
let activeNetwork | ||
|
||
before('read the active network', async function () { | ||
activeNetwork = storage.readNetworks().activeNetwork | ||
}) | ||
|
||
after('restore the active network', async function () { | ||
const networks = storage.readNetworks() | ||
networks.activeNetwork = activeNetwork | ||
storage.storeNetworks(networks) | ||
}) | ||
|
||
before('inject a dummy network', async function () { | ||
const networks = storage.readNetworks() | ||
networks.test__1 = { url: 'http://localhost:8545' } | ||
storage.storeNetworks(networks) | ||
}) | ||
|
||
after('remove dummy network', async function () { | ||
const networks = storage.readNetworks() | ||
if ('test__1' in networks) delete networks.test__1 | ||
storage.storeNetworks(networks) | ||
}) | ||
|
||
describe('when calling set', function () { | ||
before('call it', async function () { | ||
await terminal.run('npx hardhat net set --alias test__1', 1000) | ||
}) | ||
|
||
it('sets the active network', async function () { | ||
const networks = storage.readNetworks() | ||
assert.equal(networks.activeNetwork, 'test__1') | ||
}) | ||
|
||
// TODO: Test actually interacting with the set network | ||
// (Only tested manually so far) | ||
}) | ||
}) |