Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kickstart/ethereum/contracts/Campaign.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ contract Campaign {

function contribute() public payable {
require(msg.value > minimumContribution);
require(!approvers[msg.sender]);

approvers[msg.sender] = true;
approversCount++;
Expand Down
17 changes: 17 additions & 0 deletions kickstart/test/Campaign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ describe('Campaigns', () => {
assert(isContributor);
});

it('restrict people to contribute once', async () => {
await campaign.methods.contribute().send({
value: '200',
from: accounts[1]
});

try {
await campaign.methods.contribute().send({
value: '200',
from: accounts[1]
});
} catch (e) {
return;
}
assert(false);
});

it('requires a minimum contribution', async () => {
try {
await campaign.methods.contribute().send({
Expand Down