-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for
dao token new
(#904)
- Loading branch information
1 parent
23bddf0
commit 0574c8b
Showing
11 changed files
with
1,840 additions
and
14,754 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 @@ | ||
const execa = require('execa') | ||
|
||
// execa('npx', ['ganache-cli'], { | ||
execa('npx', ['aragen', 'start'], { | ||
stdout: process.stdout | ||
}) | ||
.catch(() => 'Cannot set up the devchain') |
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,5 @@ | ||
const killProcessOnPort = require('kill-port') | ||
|
||
killProcessOnPort('8545') | ||
.then(() => 'Process killed on 8545') | ||
.catch(() => 'Cannot kill the process on 8545') |
19 changes: 19 additions & 0 deletions
19
packages/aragon-cli/test/integration/snapshots/token.test.js.md
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,13 @@ | ||
import Web3 from 'web3' | ||
|
||
export const isValidTxHash = txHash => /^0x([A-Fa-f0-9]{64})$/.test(txHash) | ||
export const isAddress = Web3.utils.isAddress | ||
|
||
export const getLocalWeb3 = async () => { | ||
const web3 = new Web3( | ||
new Web3.providers.HttpProvider(`http://localhost:8545`) | ||
) | ||
const connected = await web3.eth.net.isListening() | ||
if (!connected) throw new Error('Web3 connection failed') | ||
return web3 | ||
} |
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,39 @@ | ||
import test from 'ava' | ||
import sinon from 'sinon' | ||
import * as tokenLib from '../../src/lib/token' | ||
import { isAddress, isValidTxHash, getLocalWeb3 } from './test-utils' | ||
|
||
test.beforeEach(async t => { | ||
const web3 = await getLocalWeb3() | ||
const accounts = await web3.eth.getAccounts() | ||
|
||
t.context = { | ||
web3, | ||
accounts, | ||
} | ||
}) | ||
|
||
test.afterEach.always(() => { | ||
sinon.restore() | ||
}) | ||
|
||
test('deployMiniMeTokenFactory: should deploy the contract with the right args', async t => { | ||
t.plan(5) | ||
// arrange | ||
const { web3, accounts } = t.context | ||
// act | ||
const result = await tokenLib.deployMiniMeTokenFactory( | ||
web3, | ||
accounts[0], | ||
21, | ||
() => {} | ||
) | ||
// assert | ||
t.true(isValidTxHash(result.txHash)) | ||
t.true(isAddress(result.address)) | ||
|
||
const tx = await web3.eth.getTransaction(result.txHash) | ||
t.snapshot(tx.input, 'the MiniMeTokenFactory bytecode is correct') | ||
t.snapshot(tx.gasPrice, 'the transaction gas price is correct') | ||
t.snapshot(tx.gas, 'the transaction gas is correct') | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.