Fix getProjectLevel bug

fixes issue #48
This commit is contained in:
perissology 2017-11-24 08:21:07 -08:00
parent 8f110300cb
commit 5df006a76f
2 changed files with 30 additions and 1 deletions

View File

@ -351,7 +351,7 @@ contract LiquidPledgingBase is Owned {
assert(m.adminType == PledgeAdminType.Project);
if (m.parentProject == 0) return(1);
PledgeAdmin storage parentNM = findAdmin(m.parentProject);
return getProjectLevel(parentNM);
return getProjectLevel(parentNM) + 1;
}
function isProjectCanceled(uint64 projectId) constant returns (bool) {

View File

@ -334,4 +334,33 @@ describe('LiquidPledging test', function () {
const nAdmins = await liquidPledging.numberOfPledgeAdmins();
assert.equal(nAdmins, utils.toDecimal(nAdminsBefore) + 1);
});
it('should throw if projectLevel > 20', async () => {
let nAdmins = await liquidPledging.numberOfPledgeAdmins();
await liquidPledging.addProject('ProjectLevel1', '', adminProject1, 0, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel2', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel3', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel4', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel5', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel6', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel7', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel8', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel9', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel10', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel11', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel12', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel13', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel14', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel15', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel16', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel17', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel18', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel19', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
await liquidPledging.addProject('ProjectLevel20', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
assertFail(async () => {
await liquidPledging.addProject('ProjectLevel21', '', adminProject1, ++nAdmins, 86400, 0, { from: adminProject1 });
});
})
});