Skip to content
Permalink
Browse files

Add project count

  • Loading branch information...
ilanolkies committed Mar 19, 2019
1 parent ea954ed commit ebf0bfcee8dbdaa7a724ea87e20307143718e97d
Showing with 28 additions and 0 deletions.
  1. +12 −0 contracts/DirectDonate.sol
  2. +16 −0 test/direct_donate.js
@@ -4,7 +4,19 @@ pragma solidity ^0.4.22;
contract DirectDonate {
address public owner;

uint public projectIndex;

modifier onlyOwner () {
require(msg.sender == owner);
_;
}

constructor() public {
owner = msg.sender;
projectIndex = 0;
}

function addProject () public {
projectIndex++;
}
}
@@ -17,4 +17,20 @@ contract('DirectDonate', async (accounts) => {

assert.equal(owner, accounts[0]);
});

it('should begin with no projects', async () => {
const projectQuantity = await directDonate.projectIndex();

assert.equal(projectQuantity, 0);
});

it('should add a project', async () => {
const previousQuantity = await directDonate.projectIndex();

await directDonate.addProject();

const projectQuantity = await directDonate.projectIndex();

assert.equal(projectQuantity, previousQuantity.toNumber() + 1);
});
});

0 comments on commit ebf0bfc

Please sign in to comment.
You can’t perform that action at this time.