Skip to content

Commit

Permalink
Merge pull request #1096 from JoinColony/fix/streamingpayments
Browse files Browse the repository at this point in the history
Fix streaming payment extension
  • Loading branch information
kronosapiens authored Oct 18, 2022
2 parents ddea050 + bd66c9b commit d7fb7bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/extensions/StreamingPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ contract StreamingPayments is ColonyExtensionMeta {

uint256 amountEntitledFromStart = getAmountEntitledFromStart(_id, _tokens[i]);
uint256 amountSinceLastClaim = sub(amountEntitledFromStart, paymentToken.pseudoAmountClaimedFromStart);
amountsToClaim[i] = getAmountClaimable(_id, _tokens[i], amountSinceLastClaim);
amountsToClaim[i] = getAmountClaimable(domainFundingPotId, _tokens[i], amountSinceLastClaim);
paymentToken.pseudoAmountClaimedFromStart = add(paymentToken.pseudoAmountClaimedFromStart, amountsToClaim[i]);
anythingToClaim = anythingToClaim || amountsToClaim[i] > 0;
}
Expand Down
16 changes: 16 additions & 0 deletions test/extensions/streaming-payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ contract("Streaming Payments", (accounts) => {
expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(2).subn(1)); // -1 for network fee
});

it(`can claim a streaming payment correctly where the streaming payment id is not the same as the domain id
or is a domain id that doesn't exist`, async () => {
await fundColonyWithTokens(colony, token, WAD.muln(10));

await streamingPayments.create(1, UINT256_MAX, 1, UINT256_MAX, 1, 0, UINT256_MAX, SECONDS_PER_DAY, USER1, [token.address], [WAD]);
const tx = await streamingPayments.create(1, UINT256_MAX, 1, UINT256_MAX, 1, 0, UINT256_MAX, SECONDS_PER_DAY, USER1, [token.address], [WAD]);
const blockTime = await getBlockTime(tx.receipt.blockNumber);
const streamingPaymentId = await streamingPayments.getNumStreamingPayments();

const balancePre = await token.balanceOf(USER1);
const claimArgs = [1, UINT256_MAX, UINT256_MAX, UINT256_MAX, streamingPaymentId, [token.address]];
await makeTxAtTimestamp(streamingPayments.claim, claimArgs, blockTime + SECONDS_PER_DAY * 2, this);
const balancePost = await token.balanceOf(USER1);
expect(balancePost.sub(balancePre)).to.eq.BN(WAD.muln(2).subn(1)); // -1 for network fee
});

it("cannot get more from a payment than should be able to", async () => {
await fundColonyWithTokens(colony, token, WAD.muln(1));

Expand Down

0 comments on commit d7fb7bc

Please sign in to comment.