Skip to content

Commit d7fb7bc

Browse files
authored
Merge pull request #1096 from JoinColony/fix/streamingpayments
Fix streaming payment extension
2 parents ddea050 + bd66c9b commit d7fb7bc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

contracts/extensions/StreamingPayments.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ contract StreamingPayments is ColonyExtensionMeta {
189189

190190
uint256 amountEntitledFromStart = getAmountEntitledFromStart(_id, _tokens[i]);
191191
uint256 amountSinceLastClaim = sub(amountEntitledFromStart, paymentToken.pseudoAmountClaimedFromStart);
192-
amountsToClaim[i] = getAmountClaimable(_id, _tokens[i], amountSinceLastClaim);
192+
amountsToClaim[i] = getAmountClaimable(domainFundingPotId, _tokens[i], amountSinceLastClaim);
193193
paymentToken.pseudoAmountClaimedFromStart = add(paymentToken.pseudoAmountClaimedFromStart, amountsToClaim[i]);
194194
anythingToClaim = anythingToClaim || amountsToClaim[i] > 0;
195195
}

test/extensions/streaming-payments.js

+16
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,22 @@ contract("Streaming Payments", (accounts) => {
289289
expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(2).subn(1)); // -1 for network fee
290290
});
291291

292+
it(`can claim a streaming payment correctly where the streaming payment id is not the same as the domain id
293+
or is a domain id that doesn't exist`, async () => {
294+
await fundColonyWithTokens(colony, token, WAD.muln(10));
295+
296+
await streamingPayments.create(1, UINT256_MAX, 1, UINT256_MAX, 1, 0, UINT256_MAX, SECONDS_PER_DAY, USER1, [token.address], [WAD]);
297+
const tx = await streamingPayments.create(1, UINT256_MAX, 1, UINT256_MAX, 1, 0, UINT256_MAX, SECONDS_PER_DAY, USER1, [token.address], [WAD]);
298+
const blockTime = await getBlockTime(tx.receipt.blockNumber);
299+
const streamingPaymentId = await streamingPayments.getNumStreamingPayments();
300+
301+
const balancePre = await token.balanceOf(USER1);
302+
const claimArgs = [1, UINT256_MAX, UINT256_MAX, UINT256_MAX, streamingPaymentId, [token.address]];
303+
await makeTxAtTimestamp(streamingPayments.claim, claimArgs, blockTime + SECONDS_PER_DAY * 2, this);
304+
const balancePost = await token.balanceOf(USER1);
305+
expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(2).subn(1)); // -1 for network fee
306+
});
307+
292308
it("cannot get more from a payment than should be able to", async () => {
293309
await fundColonyWithTokens(colony, token, WAD.muln(1));
294310

0 commit comments

Comments
 (0)