Skip to content

Commit

Permalink
fix: integration.js conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
samparsky committed Jul 25, 2019
1 parent b782978 commit 69632df
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
23 changes: 23 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,29 @@ tape('health works correctly', async function(t) {
t.end()
})

tape('deny non-creator from sending creator only events', async function(t) {
const evs = [
[{ type: 'UPDATE_IMPRESSION_PRICE', price: '3' }],
genEvents(1, null, 'PAY', null, null, null),
[{ type: 'PAUSE_CHANNEL' }],
genEvents(1, null, 'CLOSE')
]

await Promise.all(
evs.map(async ev => {
const result = await postEvents(
leaderUrl,
dummyVals.channel.id,
ev,
dummyVals.auth.leader
).then(res => res.json())
t.equal(result.success, false, 'should fail to post creator only events')
t.equal(result.statusCode, 403, 'should have a unauthorized status')
})
)
t.end()
})

tape('should update publisher balance with PAY event', async function(t) {
const channel = {
...dummyVals.channel,
Expand Down
5 changes: 2 additions & 3 deletions test/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ function postEvents(url, channelId, events, auth = dummyVals.auth.creator, heade
return fetchPost(`${url}/channel/${channelId}/events`, auth, { events }, headers)
}

function genEvents(n, pubName, type, adUnit, earners, outputs, stats) {
function genEvents(n, pubName, type, adUnit, earners, outputs) {
const events = []
let ev = {
type: type || 'IMPRESSION',
publisher: pubName || defaultPubName,
...stats
publisher: pubName || defaultPubName
}
if (type === 'IMPRESSION_WITH_COMMISSION') {
ev = {
Expand Down
2 changes: 1 addition & 1 deletion test/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else
./test/scripts/ethereum.sh

# Run integration & prune tests
./test/routes.js && ./test/ethereum_adapter.js && ./test/channel.js &&./test/integration.js && ./test/access.js && DB_MONGO_NAME=$LEAD_MONGO ./test/prune.js
./test/routes.js && ./test/ethereum_adapter.js && ./test/channel.js && ./test/integration.js && ./test/access.js && DB_MONGO_NAME=$LEAD_MONGO ./test/prune.js

fi

Expand Down

0 comments on commit 69632df

Please sign in to comment.