Skip to content
Permalink
Browse files

Add project list

  • Loading branch information...
ilanolkies committed Mar 19, 2019
1 parent ebf0bfc commit 7904b9058babbe919280ddd5fb2692de027c3993
Showing with 18 additions and 5 deletions.
  1. +7 −4 contracts/DirectDonate.sol
  2. +11 −1 test/direct_donate.js
@@ -4,7 +4,7 @@ pragma solidity ^0.4.22;
contract DirectDonate {
address public owner;

uint public projectIndex;
string[] public projects;

modifier onlyOwner () {
require(msg.sender == owner);
@@ -13,10 +13,13 @@ contract DirectDonate {

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

function addProject () public {
projectIndex++;
function projectIndex () public view returns (uint) {
return projects.length;
}

function addProject (string projectName) public {
projects.push(projectName);
}
}
@@ -27,10 +27,20 @@ contract('DirectDonate', async (accounts) => {
it('should add a project', async () => {
const previousQuantity = await directDonate.projectIndex();

await directDonate.addProject();
await directDonate.addProject('');

const projectQuantity = await directDonate.projectIndex();

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

it('should add and return the project', async () => {
const projectName = 'NewProject';

await directDonate.addProject(projectName);

const project = await directDonate.projects(0);

assert.equal(project, projectName);
});
});

0 comments on commit 7904b90

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