Skip to content

Commit

Permalink
Merge 7dc1e05 into 7cf134f
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Sep 10, 2019
2 parents 7cf134f + 7dc1e05 commit 124f7a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions contracts/AbstractConference.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ contract AbstractConference is Conference, GroupAdmin {
_totalAttended++;
}
}
// since maps can contain more bits than there are registrants, we cap the value!
totalAttended = _totalAttended < registered ? _totalAttended : registered;
require(_totalAttended <= registered, 'should not have more attendees than registered');
totalAttended = _totalAttended;

if (totalAttended > 0) {
payoutAmount = uint256(totalBalance()) / totalAttended;
Expand Down
6 changes: 3 additions & 3 deletions test/behaviors/conference.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ function shouldBehaveLikeConference () {
await conference.payoutAmount().should.eventually.eq(mulBN(deposit, 4))
})

it('correctly calculates total attended even if more 1 bits are set than there are registrations', async function() {
it('does not allow finalising with more attendees than registered', async function() {
// all attended
let n = toBN(0)
for (let i = 0; i < 256; i++) {
n = n.bincn(i)
}
await conference.finalize([n], {from:owner});
await conference.finalize([n], {from:owner}).should.be.rejected;

await conference.totalAttended().should.eventually.eq(4)
await conference.totalAttended().should.eventually.eq(0)
})

it('correctly updates attendee records', async function() {
Expand Down
2 changes: 1 addition & 1 deletion test/behaviors/stress.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const reportFinalize = async (participants, ctx) => {
// build bitmaps
const numRegistered = addresses.length;
let num = toBN(0);
for (let i = 0; i < 256; i++) {
for (let i = 0; i < numRegistered; i++) {
num = num.bincn(i)
}
const maps = [];
Expand Down

0 comments on commit 124f7a5

Please sign in to comment.