From 7c308ef261e2ed255c9f7b2d41107edb5d2af5b9 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 10 Apr 2019 15:42:16 -0400 Subject: [PATCH] add ipfs hash to removeCOntributor function and add test --- contracts/Meritocracy.sol | 4 +++- test/Meritocracy_spec.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/contracts/Meritocracy.sol b/contracts/Meritocracy.sol index a2e9538..fe0d8f9 100644 --- a/contracts/Meritocracy.sol +++ b/contracts/Meritocracy.sol @@ -226,7 +226,7 @@ contract Meritocracy { // Remove Contributor from Registry // Note: Should not be easy to remove multiple contributors in one tx // 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 uint256 registryLength = registry.length - 1; // Requirements @@ -237,6 +237,8 @@ contract Meritocracy { registry[idx] = registry[registryLength]; registry.pop(); delete contributors[c]; // TODO check if this works + // Set new IPFS hash for the list + contributorListIPFSHash = _contributorListIPFSHash; emit ContributorRemoved(c); } diff --git a/test/Meritocracy_spec.js b/test/Meritocracy_spec.js index d9ca502..4351d7b 100644 --- a/test/Meritocracy_spec.js +++ b/test/Meritocracy_spec.js @@ -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 withdraw before and after @@ -128,7 +140,6 @@ contract("Meritocracy", function () { // TODO withdraw after forfeitAllocations // TODO setMaxContributors smaller than max - // TODO removeContributors // TODO setMaxContributors again // TODO addContributors // TODO changeOwner