Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Add TPL integration tests (#145)
Browse files Browse the repository at this point in the history
* Move vouching and token contracts tests to subdir

* Use babel presets

* Move assert event helper to lib

* Add TPL integration tests

* Use non-zero attribute ID
  • Loading branch information
facuspagnuolo authored and mergify[bot] committed Sep 28, 2018
1 parent edbd20f commit c5019dd
Show file tree
Hide file tree
Showing 11 changed files with 1,777 additions and 574 deletions.
2 changes: 2 additions & 0 deletions packages/lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { compareStorageLayouts } from './validations/Layout';
import { behaviors, helpers } from './test'
const assertions = helpers.assertions
const assertRevert = helpers.assertRevert
const assertEvent = helpers.assertEvent

// model objects
import Proxy from './proxy/Proxy'
Expand All @@ -39,6 +40,7 @@ export {
decodeLogs,
encodeCall,
assertRevert,
assertEvent,
assertions,
behaviors,
sendTransaction,
Expand Down
18 changes: 18 additions & 0 deletions packages/lib/src/test/helpers/assertEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function inLogs (logs, eventName, eventArgs = {}) {
const event = logs.find(e =>
e.event === eventName &&
Object.entries(eventArgs).every(([k, v]) => e.args[k] === v))

assert(!!event, `Expected to find ${eventName} with ${eventArgs} in ${logs}`)
return event
}

async function inTransaction (tx, eventName, eventArgs = {}) {
const { logs } = await tx;
return inLogs(logs, eventName, eventArgs);
}

export default {
inLogs,
inTransaction,
}
2 changes: 2 additions & 0 deletions packages/lib/src/test/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import assertions from './helpers/assertions'
import assertEvent from './helpers/assertEvent'
import assertRevert from './helpers/assertRevert'
import shouldBehaveLikeOwnable from './behaviors/Ownable'

const helpers = {
assertions,
assertRevert,
assertEvent,
}

const behaviors = {
Expand Down
10 changes: 10 additions & 0 deletions packages/vouching/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
["env", {
"targets": {
"node": "8.9"
}
}]
],
"plugins": ["transform-object-rest-spread"]
}
Loading

0 comments on commit c5019dd

Please sign in to comment.