Skip to content

Commit

Permalink
Add integration tests for dao token new (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwhisperer committed Nov 19, 2019
1 parent 23bddf0 commit 0574c8b
Show file tree
Hide file tree
Showing 11 changed files with 1,840 additions and 14,754 deletions.
14,954 changes: 1,129 additions & 13,825 deletions packages/aragon-cli/npm-shrinkwrap.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion packages/aragon-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"build:watch": "npm run build -- -- --watch",
"lint": "eslint src test",
"lint:fix": "npm run lint -- --fix",
"pretest": "node scripts/setup-integration-tests.js & sleep 5",
"posttest": "node scripts/teardown-integration-tests.js",
"test": "ava --verbose",
"test:watch": "ava --watch",
"test:coverage": "nyc --all --reporter text --reporter text-summary --reporter lcovonly npm run test"
Expand Down Expand Up @@ -112,6 +114,7 @@
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"kill-port": "^1.6.0",
"nyc": "^14.1.1",
"prettier": "^1.15.3",
"proxyquire": "^2.1.0",
Expand Down Expand Up @@ -161,7 +164,9 @@
],
"env": {
"test": {
"plugins": [ "istanbul" ]
"plugins": [
"istanbul"
]
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions packages/aragon-cli/scripts/setup-integration-tests.js
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')
5 changes: 5 additions & 0 deletions packages/aragon-cli/scripts/teardown-integration-tests.js
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 packages/aragon-cli/test/integration/snapshots/token.test.js.md

Large diffs are not rendered by default.

Binary file not shown.
13 changes: 13 additions & 0 deletions packages/aragon-cli/test/integration/test-utils.js
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
}
39 changes: 39 additions & 0 deletions packages/aragon-cli/test/integration/token.test.js
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')
})
6 changes: 3 additions & 3 deletions packages/cli-utils/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0574c8b

Please sign in to comment.