passes ETH tests, not yet token tests
This commit is contained in:
parent
86e68f4c0e
commit
0b64ba637a
|
@ -15,7 +15,6 @@ contract StandardBounties {
|
|||
event BountyFulfilled(uint bountyId, address indexed fulfiller, uint256 indexed _fulfillmentId);
|
||||
event FulfillmentUpdated(uint _bountyId, uint _fulfillmentId);
|
||||
event FulfillmentAccepted(uint bountyId, address indexed fulfiller, uint256 indexed _fulfillmentId);
|
||||
event FulfillmentPaid(uint bountyId, address indexed fulfiller, uint256 indexed _fulfillmentId);
|
||||
event BountyKilled(uint bountyId, address indexed issuer);
|
||||
event ContributionAdded(uint bountyId, address indexed contributor, uint256 value);
|
||||
event DeadlineExtended(uint bountyId, uint newDeadline);
|
||||
|
@ -34,7 +33,6 @@ contract StandardBounties {
|
|||
|
||||
mapping(uint=>Fulfillment[]) fulfillments;
|
||||
mapping(uint=>uint) numAccepted;
|
||||
mapping(uint=>uint) numPaid;
|
||||
mapping(uint=>HumanStandardToken) tokenContracts;
|
||||
|
||||
/*
|
||||
|
@ -59,12 +57,10 @@ contract StandardBounties {
|
|||
address arbiter;
|
||||
bool paysTokens;
|
||||
BountyStages bountyStage;
|
||||
uint owedAmount;
|
||||
uint balance;
|
||||
}
|
||||
|
||||
struct Fulfillment {
|
||||
bool paid;
|
||||
bool accepted;
|
||||
address fulfiller;
|
||||
string data;
|
||||
|
@ -181,7 +177,7 @@ contract StandardBounties {
|
|||
validateNotTooManyBounties
|
||||
returns (uint)
|
||||
{
|
||||
bounties.push(Bounty(_issuer, _deadline, _data, _fulfillmentAmount, _arbiter, _paysTokens, BountyStages.Draft, 0, 0));
|
||||
bounties.push(Bounty(_issuer, _deadline, _data, _fulfillmentAmount, _arbiter, _paysTokens, BountyStages.Draft, 0));
|
||||
if (_paysTokens){
|
||||
tokenContracts[bounties.length - 1] = HumanStandardToken(_tokenContract);
|
||||
}
|
||||
|
@ -230,7 +226,6 @@ contract StandardBounties {
|
|||
_arbiter,
|
||||
_paysTokens,
|
||||
BountyStages.Active,
|
||||
0,
|
||||
_value));
|
||||
BountyIssued(bounties.length - 1);
|
||||
ContributionAdded(bounties.length - 1, msg.sender, _value);
|
||||
|
@ -278,8 +273,7 @@ contract StandardBounties {
|
|||
transferredAmountEqualsValue(_bountyId, _value)
|
||||
{
|
||||
bounties[_bountyId].balance += _value;
|
||||
require (bounties[_bountyId].balance >=
|
||||
(bounties[_bountyId].fulfillmentAmount + bounties[_bountyId].owedAmount));
|
||||
require (bounties[_bountyId].balance >= bounties[_bountyId].fulfillmentAmount);
|
||||
transitionToState(_bountyId, BountyStages.Active);
|
||||
|
||||
ContributionAdded(_bountyId, msg.sender, _value);
|
||||
|
@ -302,7 +296,7 @@ contract StandardBounties {
|
|||
isBeforeDeadline(_bountyId)
|
||||
notIssuerOrArbiter(_bountyId)
|
||||
{
|
||||
fulfillments[_bountyId].push(Fulfillment(false, false, msg.sender, _data));
|
||||
fulfillments[_bountyId].push(Fulfillment(false, msg.sender, _data));
|
||||
|
||||
BountyFulfilled(_bountyId, msg.sender, (fulfillments[_bountyId].length - 1));
|
||||
}
|
||||
|
@ -334,7 +328,7 @@ contract StandardBounties {
|
|||
}
|
||||
|
||||
modifier enoughFundsToPay(uint _bountyId) {
|
||||
require(bounties[_bountyId].balance >= (bounties[_bountyId].owedAmount + bounties[_bountyId].fulfillmentAmount));
|
||||
require(bounties[_bountyId].balance >= bounties[_bountyId].fulfillmentAmount);
|
||||
_;
|
||||
}
|
||||
|
||||
|
@ -351,38 +345,14 @@ contract StandardBounties {
|
|||
enoughFundsToPay(_bountyId)
|
||||
{
|
||||
fulfillments[_bountyId][_fulfillmentId].accepted = true;
|
||||
bounties[_bountyId].owedAmount += bounties[_bountyId].fulfillmentAmount;
|
||||
numAccepted[_bountyId]++;
|
||||
|
||||
FulfillmentAccepted(_bountyId, msg.sender, _fulfillmentId);
|
||||
}
|
||||
|
||||
modifier checkFulfillmentIsApprovedAndUnpaid(uint _bountyId, uint _fulfillmentId) {
|
||||
require(fulfillments[_bountyId][_fulfillmentId].accepted && !fulfillments[_bountyId][_fulfillmentId].paid);
|
||||
_;
|
||||
}
|
||||
|
||||
/// @dev fulfillmentPayment(): pay the fulfiller for their work
|
||||
/// @param _bountyId the index of the bounty
|
||||
/// @param _fulfillmentId the index of the fulfillment being accepted
|
||||
function fulfillmentPayment(uint _bountyId, uint _fulfillmentId)
|
||||
public
|
||||
validateBountyArrayIndex(_bountyId)
|
||||
validateFulfillmentArrayIndex(_bountyId, _fulfillmentId)
|
||||
onlyFulfiller(_bountyId, _fulfillmentId)
|
||||
checkFulfillmentIsApprovedAndUnpaid(_bountyId, _fulfillmentId)
|
||||
{
|
||||
fulfillments[_bountyId][_fulfillmentId].paid = true;
|
||||
numPaid[_bountyId]++;
|
||||
bounties[_bountyId].owedAmount -= bounties[_bountyId].fulfillmentAmount;
|
||||
bounties[_bountyId].balance -= bounties[_bountyId].fulfillmentAmount;
|
||||
|
||||
if (bounties[_bountyId].paysTokens){
|
||||
require(tokenContracts[_bountyId].transfer(fulfillments[_bountyId][_fulfillmentId].fulfiller, bounties[_bountyId].fulfillmentAmount));
|
||||
} else {
|
||||
fulfillments[_bountyId][_fulfillmentId].fulfiller.transfer(bounties[_bountyId].fulfillmentAmount);
|
||||
}
|
||||
FulfillmentPaid(_bountyId, msg.sender, _fulfillmentId);
|
||||
FulfillmentAccepted(_bountyId, msg.sender, _fulfillmentId);
|
||||
}
|
||||
|
||||
/// @dev killBounty(): drains the contract of it's remaining
|
||||
|
@ -395,13 +365,13 @@ contract StandardBounties {
|
|||
onlyIssuer(_bountyId)
|
||||
{
|
||||
transitionToState(_bountyId, BountyStages.Dead);
|
||||
uint difference = bounties[_bountyId].balance - bounties[_bountyId].owedAmount;
|
||||
bounties[_bountyId].balance = bounties[_bountyId].owedAmount;
|
||||
if (difference > 0){
|
||||
uint oldBalance = bounties[_bountyId].balance;
|
||||
bounties[_bountyId].balance = 0;
|
||||
if (bounties[_bountyId].balance > 0){
|
||||
if (bounties[_bountyId].paysTokens){
|
||||
require(tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, difference));
|
||||
require(tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, oldBalance));
|
||||
} else {
|
||||
bounties[_bountyId].issuer.transfer(difference);
|
||||
bounties[_bountyId].issuer.transfer(oldBalance);
|
||||
}
|
||||
}
|
||||
BountyKilled(_bountyId, msg.sender);
|
||||
|
@ -539,13 +509,8 @@ contract StandardBounties {
|
|||
transferredAmountEqualsValue(_bountyId, _value)
|
||||
{
|
||||
bounties[_bountyId].balance += _value;
|
||||
uint newOwedAmount = (bounties[_bountyId].owedAmount +
|
||||
((_newFulfillmentAmount - bounties[_bountyId].fulfillmentAmount)
|
||||
* (numAccepted[_bountyId] - numPaid[_bountyId])));
|
||||
require(bounties[_bountyId].balance >= newOwedAmount);
|
||||
bounties[_bountyId].owedAmount = newOwedAmount;
|
||||
require(bounties[_bountyId].balance >= _newFulfillmentAmount);
|
||||
bounties[_bountyId].fulfillmentAmount = _newFulfillmentAmount;
|
||||
ContributionAdded(_bountyId, msg.sender, _value);
|
||||
PayoutIncreased(_bountyId, _newFulfillmentAmount);
|
||||
}
|
||||
|
||||
|
@ -558,10 +523,9 @@ contract StandardBounties {
|
|||
constant
|
||||
validateBountyArrayIndex(_bountyId)
|
||||
validateFulfillmentArrayIndex(_bountyId, _fulfillmentId)
|
||||
returns (bool, bool, address, string)
|
||||
returns (bool, address, string)
|
||||
{
|
||||
return (fulfillments[_bountyId][_fulfillmentId].paid,
|
||||
fulfillments[_bountyId][_fulfillmentId].accepted,
|
||||
return (fulfillments[_bountyId][_fulfillmentId].accepted,
|
||||
fulfillments[_bountyId][_fulfillmentId].fulfiller,
|
||||
fulfillments[_bountyId][_fulfillmentId].data);
|
||||
}
|
||||
|
@ -573,14 +537,13 @@ contract StandardBounties {
|
|||
public
|
||||
constant
|
||||
validateBountyArrayIndex(_bountyId)
|
||||
returns (address, uint, uint, bool, uint, uint, uint)
|
||||
returns (address, uint, uint, bool, uint, uint)
|
||||
{
|
||||
return (bounties[_bountyId].issuer,
|
||||
bounties[_bountyId].deadline,
|
||||
bounties[_bountyId].fulfillmentAmount,
|
||||
bounties[_bountyId].paysTokens,
|
||||
uint(bounties[_bountyId].bountyStage),
|
||||
bounties[_bountyId].owedAmount,
|
||||
bounties[_bountyId].balance);
|
||||
}
|
||||
|
||||
|
|
|
@ -356,11 +356,9 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[0] === false);
|
||||
assert(fulfillment[1] === false);
|
||||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[0] === false);
|
||||
assert(fulfillment[1] === true);
|
||||
assert(fulfillment[0] === true);
|
||||
});
|
||||
it("[ETH] verifies that changing a fulfillment works", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
@ -377,10 +375,10 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[3] === "data");
|
||||
assert(fulfillment[2] === "data", ("err"+fulfillment[2]+"data"));
|
||||
await registry.updateFulfillment(0,0,"data2", {from: accounts[1]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[3] === "data2");
|
||||
assert(fulfillment[2] === "data2");
|
||||
});
|
||||
|
||||
it("[ETH] verifies that changing an accepted fulfillment fails", async () => {
|
||||
|
@ -448,9 +446,8 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
var bounty = await registry.getBounty(0);
|
||||
assert(bounty[6] == 0);
|
||||
assert(bounty[5] == 0);
|
||||
});
|
||||
it("[ETH] verifies that bounty fulfillment flow works to completion with several fulfillments", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
@ -473,69 +470,8 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
var bounty = await registry.getBounty(0);
|
||||
assert(bounty[6] == 0);
|
||||
});
|
||||
it("[ETH] verifies that claiming payment twice fails when balance is 0", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,1000, {from: accounts[0], value: 1000});
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
var bounty = await registry.getBounty(0);
|
||||
assert(bounty[6] == 0);
|
||||
try {
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
} catch (error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
it("[ETH] verifies that claiming payment twice fails when balance isn't 0", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,2000, {from: accounts[0], value: 2000});
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
var bounty = await registry.getBounty(0);
|
||||
assert(bounty[6] == 1000);
|
||||
try {
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
} catch (error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
assert(bounty[5] == 0);
|
||||
});
|
||||
it("[ETH] verifies that arbiter can't fulfill a bounty", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
@ -573,96 +509,7 @@ contract('StandardBounties', function(accounts) {
|
|||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
it("[ETH] verifies that killing bounty leaves the correct remaining amount for one payment", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,2000, {from: accounts[0], value: 2000});
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
await registry.fulfillBounty(0, "data3", {from: accounts[3]});
|
||||
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
let balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 2000);
|
||||
assert(balance == 2000);
|
||||
|
||||
await registry.killBounty(0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 0);
|
||||
assert(balance == 0);
|
||||
});
|
||||
it("[ETH] verifies that killing bounty leaves the correct remaining amount for several payments", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,3000, {from: accounts[0], value: 3000});
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
await registry.fulfillBounty(0, "data3", {from: accounts[3]});
|
||||
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
let balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 3000);
|
||||
assert(balance == 3000);
|
||||
|
||||
await registry.acceptFulfillment(0,2,{from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 2000);
|
||||
assert(bounty[6]== 3000);
|
||||
assert(balance == 3000);
|
||||
|
||||
await registry.killBounty(0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 2000);
|
||||
assert(bounty[6]== 2000);
|
||||
assert(balance == 2000);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
|
||||
await registry.fulfillmentPayment(0,2,{from: accounts[3]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 0);
|
||||
assert(balance == 0);
|
||||
});
|
||||
|
||||
it("[ETH] verifies that accepting too many bounties because of unpaid fulfillments isn't allowed", async () => {
|
||||
it("[ETH] verifies that accepting too many fulfillments isn't allowed", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
|
@ -680,52 +527,12 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.fulfillBounty(0, "data3", {from: accounts[3]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
let balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(balance == 1000);
|
||||
await registry.acceptFulfillment(0,2,{from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
try {
|
||||
await registry.acceptFulfillment(0,2,{from: accounts[0]});
|
||||
} catch (error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
it("[ETH] verifies that accepting too many bounties because of paid fulfillments isn't allowed", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,1000, {from: accounts[0], value: 1000});
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
await registry.fulfillBounty(0, "data3", {from: accounts[3]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
let balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 0);
|
||||
assert(balance == 0);
|
||||
try {
|
||||
await registry.acceptFulfillment(0,2,{from: accounts[0]});
|
||||
|
@ -733,39 +540,6 @@ contract('StandardBounties', function(accounts) {
|
|||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
it("[ETH] verifies that claiming payment for someone else's bounty fulfillment isn't allowed", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,1000, {from: accounts[0], value: 1000});
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
await registry.fulfillBounty(0, "data3", {from: accounts[3]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
let balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 0);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
await registry.acceptFulfillment(0,1,{from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[5]== 1000);
|
||||
assert(bounty[6]== 1000);
|
||||
assert(balance == 1000);
|
||||
try {
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[1]});
|
||||
} catch (error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
|
||||
it("[ETH] verifies that accepting an already accepted fulfillment fails", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
|
@ -785,44 +559,7 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[0] == false);
|
||||
assert(fulfillment[1] == true);
|
||||
|
||||
try {
|
||||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
|
||||
} catch (error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
});
|
||||
|
||||
it("[ETH] verifies that accepting a paid fulfillment fails", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,1000, {from: accounts[0], value: 1000});
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[2]});
|
||||
|
||||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
|
||||
let fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[0] == false);
|
||||
assert(fulfillment[1] == true);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
|
||||
fulfillment = await registry.getFulfillment(0,0);
|
||||
assert(fulfillment[0] == true);
|
||||
assert(fulfillment[1] == true);
|
||||
|
||||
try {
|
||||
await registry.acceptFulfillment(0,0,{from: accounts[0]});
|
||||
|
@ -1121,13 +858,11 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.killBounty(0,{from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
|
||||
try {
|
||||
await registry.activateBounty(0, 0, {from: accounts[0], value: 0});
|
||||
|
@ -1156,13 +891,11 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.killBounty(0,{from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
|
||||
try {
|
||||
await registry.activateBounty(0, 500, {from: accounts[0], value: 500});
|
||||
|
@ -1190,7 +923,6 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.killBounty(0,{from: accounts[0]});
|
||||
|
||||
|
@ -1219,33 +951,23 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
|
||||
await registry.increasePayout(0,2000, 0, {from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
|
||||
await registry.acceptFulfillment(0,0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 2000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 0);
|
||||
|
||||
|
||||
});
|
||||
it("[ETH] verifies that increasing a payout amount for an accepted fulfillment works", async () => {
|
||||
|
@ -1259,33 +981,24 @@ contract('StandardBounties', function(accounts) {
|
|||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,2000, {from: accounts[0], value: 2000});
|
||||
await registry.activateBounty(0,3000, {from: accounts[0], value: 3000});
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 3000);
|
||||
|
||||
await registry.acceptFulfillment(0,0, {from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
|
||||
await registry.increasePayout(0,2000, 0, {from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 0);
|
||||
|
||||
|
||||
});
|
||||
|
@ -1306,87 +1019,23 @@ contract('StandardBounties', function(accounts) {
|
|||
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 1000);
|
||||
assert(bounty[5] == 1000);
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 1000);
|
||||
assert(bounty[5] == 1000);
|
||||
|
||||
await registry.increasePayout(0,2000, 1000, {from: accounts[0], value: 1000});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
|
||||
await registry.acceptFulfillment(0,0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 2000);
|
||||
assert(bounty[6] == 2000);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 0);
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("[ETH] verifies that increasing a payout amount for several accepted fulfillments works", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
||||
await registry.issueBounty(accounts[0],
|
||||
2528821098,
|
||||
"data",
|
||||
1000,
|
||||
0x0,
|
||||
false,
|
||||
0x0,
|
||||
{from: accounts[0]});
|
||||
await registry.activateBounty(0,5000, {from: accounts[0], value: 5000});
|
||||
|
||||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
let bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 5000);
|
||||
|
||||
await registry.acceptFulfillment(0,0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 1000);
|
||||
assert(bounty[6] == 5000);
|
||||
|
||||
await registry.acceptFulfillment(0,1, {from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 1000);
|
||||
assert(bounty[5] == 2000);
|
||||
assert(bounty[6] == 5000);
|
||||
|
||||
await registry.increasePayout(0,2000, 0, {from: accounts[0]});
|
||||
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 4000);
|
||||
assert(bounty[6] == 5000);
|
||||
|
||||
await registry.fulfillmentPayment(0,0,{from: accounts[1]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 2000);
|
||||
assert(bounty[6] == 3000);
|
||||
|
||||
await registry.fulfillmentPayment(0,1,{from: accounts[2]});
|
||||
bounty = await registry.getBounty(0);
|
||||
assert(bounty[2] == 2000);
|
||||
assert(bounty[5] == 0);
|
||||
assert(bounty[6] == 1000);
|
||||
|
||||
|
||||
});
|
||||
|
@ -1415,9 +1064,6 @@ contract('StandardBounties', function(accounts) {
|
|||
} catch(error){
|
||||
return utils.ensureException(error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
it("[ETH] verifies that increasing the payout with a lower amount fails", async () => {
|
||||
let registry = await StandardBounties.new(accounts[0]);
|
||||
|
@ -1435,9 +1081,6 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.fulfillBounty(0, "data", {from: accounts[1]});
|
||||
await registry.fulfillBounty(0, "data2", {from: accounts[2]});
|
||||
|
||||
await registry.acceptFulfillment(0,0, {from: accounts[0]});
|
||||
await registry.acceptFulfillment(0,1, {from: accounts[0]});
|
||||
|
||||
try {
|
||||
await registry.increasePayout(0,900, 0, {from: accounts[0]});
|
||||
} catch(error){
|
||||
|
@ -1464,7 +1107,7 @@ contract('StandardBounties', function(accounts) {
|
|||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[3] == true);
|
||||
assert(bounty[6] == 0);
|
||||
assert(bounty[5] == 0);
|
||||
assert(balance == 0);
|
||||
|
||||
});
|
||||
|
@ -1483,14 +1126,14 @@ contract('StandardBounties', function(accounts) {
|
|||
await registry.contribute(0, 3000, {from: accounts[0], value: 3000});
|
||||
var bounty = await registry.getBounty(0);
|
||||
var balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[6] == 3000);
|
||||
assert(bounty[5] == 3000);
|
||||
assert(balance == 3000);
|
||||
|
||||
await registry.changeBountyPaysTokens(0, true, 0x0, {from: accounts[0]});
|
||||
bounty = await registry.getBounty(0);
|
||||
balance = await web3.eth.getBalance(registry.address);
|
||||
assert(bounty[3] == true);
|
||||
assert(bounty[6] == 0);
|
||||
assert(bounty[5] == 0);
|
||||
assert(balance == 0);
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue