add ipfs hash to removeCOntributor function and add test

This commit is contained in:
Jonathan Rainville 2019-04-10 15:42:16 -04:00
parent 5d069afb06
commit 7c308ef261
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
2 changed files with 15 additions and 2 deletions

View File

@ -226,7 +226,7 @@ contract Meritocracy {
// Remove Contributor from Registry // Remove Contributor from Registry
// Note: Should not be easy to remove multiple contributors in one tx // Note: Should not be easy to remove multiple contributors in one tx
// WARN: Changed to idx, client can do loop by enumerating registry // WARN: Changed to idx, client can do loop by enumerating registry
function removeContributor(uint256 idx) external onlyAdmin { // address _contributor function removeContributor(uint256 idx, string calldata _contributorListIPFSHash) external onlyAdmin { // address _contributor
// Locals // Locals
uint256 registryLength = registry.length - 1; uint256 registryLength = registry.length - 1;
// Requirements // Requirements
@ -237,6 +237,8 @@ contract Meritocracy {
registry[idx] = registry[registryLength]; registry[idx] = registry[registryLength];
registry.pop(); registry.pop();
delete contributors[c]; // TODO check if this works delete contributors[c]; // TODO check if this works
// Set new IPFS hash for the list
contributorListIPFSHash = _contributorListIPFSHash;
emit ContributorRemoved(c); emit ContributorRemoved(c);
} }

View File

@ -120,6 +120,18 @@ contract("Meritocracy", function () {
} }
}); });
describe('removeContributor', () => {
it('removes with normal values', async () => {
let oldRegistry = await Meritocracy.methods.getRegistry().call();
let result = await Meritocracy.methods.removeContributor(1, IPFS_HASH).send({from: owner});
let registry = await Meritocracy.methods.getRegistry().call();
assert.strictEqual(registry.length, oldRegistry.length - 1);
})
})
// TODO award // TODO award
// TODO withdraw before and after // TODO withdraw before and after
@ -128,7 +140,6 @@ contract("Meritocracy", function () {
// TODO withdraw after forfeitAllocations // TODO withdraw after forfeitAllocations
// TODO setMaxContributors smaller than max // TODO setMaxContributors smaller than max
// TODO removeContributors
// TODO setMaxContributors again // TODO setMaxContributors again
// TODO addContributors // TODO addContributors
// TODO changeOwner // TODO changeOwner