Skip to content

Add: empty aggregates test & Admin routes#302

Merged
Ivshti merged 7 commits intoadexAI:masterfrom
samparsky:fix-admin-check
Jul 8, 2020
Merged

Add: empty aggregates test & Admin routes#302
Ivshti merged 7 commits intoadexAI:masterfrom
samparsky:fix-admin-check

Conversation

@samparsky
Copy link
Contributor

@samparsky samparsky commented Jul 8, 2020

Fixes #300
Fixes #286
Fixes #285

@samparsky samparsky changed the title Add: empty aggregates test & fix Add: empty aggregates test & Admin routes Jul 8, 2020
t.end()
})

tape('validatorWorker: does not apply empty aggr', async function(t) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ivshti here is the test that checks for that the validatorWorker doesn't apply an empty aggr

})

tape('/validator-messages: reject Accounting/NewState messages with empty balances', async function(
t
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here we test that the sentry never accepts newstate/accounting messages with empty balances

@samparsky samparsky requested a review from Ivshti July 8, 2020 15:14
Copy link
Contributor

@Ivshti Ivshti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except a few comments

remark for the future: please use separate commits for separate changes

adapters/lib.js Outdated
}
// we split to remove space JSON.stringify adds
// between keys
const formattedSpec = JSON.stringify(channel.spec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do this, since it will remove the spaces in the strings too

just count it as it is...despite the spaces

.split(' ')
.join('')
// we use buffer instead of string length to cater for
// non utf8 strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍

async function adminAnalytics(req) {
const { channels, earner } = req.query
if (!channels) throw new Error('please provide channels query param')
return analytics(req, channels.split('+'), earner)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two schools of thought here

you either pass multiple channels by doing ?channelId=..&channelId=... in which case express will give you an array for channel ID

or you handle it manually as you do here...

I'm fine with either - I like this one more, so this is good 👍

events: [
{
type: constants.eventTypes.update_targeting,
targetingRules: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can set this to an empty array, so that it doesn't distract from the main purpose of the test

also, did you test what happens if we comment out the fix (if (eventReducer.isEmpty(aggr)) { return })?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i did it produces the a new Accounting state

@Ivshti Ivshti merged commit 6050600 into adexAI:master Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't persist empty Event Aggregates JSON size limit of channel spec analytics: admin key

2 participants