Update docs

This commit is contained in:
github-actions
2022-06-29 09:01:40 +00:00
parent 0627757030
commit 1722dabc84
141 changed files with 14658 additions and 6699 deletions

View File

@ -62,10 +62,11 @@ contract('PaymentSplitter', function (accounts) {
await Promise.all(this.payees.map(async (payee, index) => {
expect(await this.contract.payee(index)).to.equal(payee);
expect(await this.contract.released(payee)).to.be.bignumber.equal('0');
expect(await this.contract.releasable(payee)).to.be.bignumber.equal('0');
}));
});
describe('accepts payments', async function () {
describe('accepts payments', function () {
it('Ether', async function () {
await send.ether(owner, this.contract.address, amount);
@ -79,7 +80,7 @@ contract('PaymentSplitter', function (accounts) {
});
});
describe('shares', async function () {
describe('shares', function () {
it('stores shares if address is payee', async function () {
expect(await this.contract.shares(payee1)).to.be.bignumber.not.equal('0');
});
@ -89,8 +90,8 @@ contract('PaymentSplitter', function (accounts) {
});
});
describe('release', async function () {
describe('Ether', async function () {
describe('release', function () {
describe('Ether', function () {
it('reverts if no funds to claim', async function () {
await expectRevert(this.contract.release(payee1),
'PaymentSplitter: account is not due payment',
@ -104,7 +105,7 @@ contract('PaymentSplitter', function (accounts) {
});
});
describe('Token', async function () {
describe('Token', function () {
it('reverts if no funds to claim', async function () {
await expectRevert(this.contract.release(this.token.address, payee1),
'PaymentSplitter: account is not due payment',
@ -119,7 +120,27 @@ contract('PaymentSplitter', function (accounts) {
});
});
describe('distributes funds to payees', async function () {
describe('tracks releasable and released', function () {
it('Ether', async function () {
await send.ether(payer1, this.contract.address, amount);
const payment = amount.divn(10);
expect(await this.contract.releasable(payee2)).to.be.bignumber.equal(payment);
await this.contract.release(payee2);
expect(await this.contract.releasable(payee2)).to.be.bignumber.equal('0');
expect(await this.contract.released(payee2)).to.be.bignumber.equal(payment);
});
it('Token', async function () {
await this.token.transfer(this.contract.address, amount, { from: owner });
const payment = amount.divn(10);
expect(await this.contract.releasable(this.token.address, payee2, {})).to.be.bignumber.equal(payment);
await this.contract.release(this.token.address, payee2);
expect(await this.contract.releasable(this.token.address, payee2, {})).to.be.bignumber.equal('0');
expect(await this.contract.released(this.token.address, payee2)).to.be.bignumber.equal(payment);
});
});
describe('distributes funds to payees', function () {
it('Ether', async function () {
await send.ether(payer1, this.contract.address, amount);
@ -130,22 +151,22 @@ contract('PaymentSplitter', function (accounts) {
// distribute to payees
const tracker1 = await balance.tracker(payee1);
const { logs: logs1 } = await this.contract.release(payee1);
const receipt1 = await this.contract.release(payee1);
const profit1 = await tracker1.delta();
expect(profit1).to.be.bignumber.equal(ether('0.20'));
expectEvent.inLogs(logs1, 'PaymentReleased', { to: payee1, amount: profit1 });
expectEvent(receipt1, 'PaymentReleased', { to: payee1, amount: profit1 });
const tracker2 = await balance.tracker(payee2);
const { logs: logs2 } = await this.contract.release(payee2);
const receipt2 = await this.contract.release(payee2);
const profit2 = await tracker2.delta();
expect(profit2).to.be.bignumber.equal(ether('0.10'));
expectEvent.inLogs(logs2, 'PaymentReleased', { to: payee2, amount: profit2 });
expectEvent(receipt2, 'PaymentReleased', { to: payee2, amount: profit2 });
const tracker3 = await balance.tracker(payee3);
const { logs: logs3 } = await this.contract.release(payee3);
const receipt3 = await this.contract.release(payee3);
const profit3 = await tracker3.delta();
expect(profit3).to.be.bignumber.equal(ether('0.70'));
expectEvent.inLogs(logs3, 'PaymentReleased', { to: payee3, amount: profit3 });
expectEvent(receipt3, 'PaymentReleased', { to: payee3, amount: profit3 });
// end balance should be zero
expect(await balance.current(this.contract.address)).to.be.bignumber.equal('0');