* Add barebones EIP1820 support. * Update openzeppelin-test-helpers dependency to have ERC1820 support. * Add tests for ERC1820. * Improve inline documentation. * Add changelog entry. * Update test-helpers, refactor tests to use new helpers. * Rename ERC1820 to ERC1820Implementer. * Improve implementer docstring. * Remove _implementsInterfaceForAddress. * update openzeppelin-test-helpers to 0.2.0 * Update contracts/drafts/ERC1820Implementer.sol Co-Authored-By: nventuro <nicolas.venturo@gmail.com> * Fix how solidity coverage is run to allow for free events. * Fix coverage testing script.
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
const { balance, ether } = require('openzeppelin-test-helpers');
|
|
|
|
const PullPaymentMock = artifacts.require('PullPaymentMock');
|
|
|
|
contract('PullPayment', function ([_, payer, payee1, payee2]) {
|
|
const amount = ether('17');
|
|
|
|
beforeEach(async function () {
|
|
this.contract = await PullPaymentMock.new({ value: amount });
|
|
});
|
|
|
|
it('can record an async payment correctly', async function () {
|
|
await this.contract.callTransfer(payee1, 100, { from: payer });
|
|
(await this.contract.payments(payee1)).should.be.bignumber.equal('100');
|
|
});
|
|
|
|
it('can add multiple balances on one account', async function () {
|
|
await this.contract.callTransfer(payee1, 200, { from: payer });
|
|
await this.contract.callTransfer(payee1, 300, { from: payer });
|
|
(await this.contract.payments(payee1)).should.be.bignumber.equal('500');
|
|
});
|
|
|
|
it('can add balances on multiple accounts', async function () {
|
|
await this.contract.callTransfer(payee1, 200, { from: payer });
|
|
await this.contract.callTransfer(payee2, 300, { from: payer });
|
|
|
|
(await this.contract.payments(payee1)).should.be.bignumber.equal('200');
|
|
|
|
(await this.contract.payments(payee2)).should.be.bignumber.equal('300');
|
|
});
|
|
|
|
it('can withdraw payment', async function () {
|
|
const balanceTracker = await balance.tracker(payee1);
|
|
|
|
await this.contract.callTransfer(payee1, amount, { from: payer });
|
|
(await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
|
|
|
|
await this.contract.withdrawPayments(payee1);
|
|
|
|
(await balanceTracker.delta()).should.be.bignumber.equal(amount);
|
|
(await this.contract.payments(payee1)).should.be.bignumber.equal('0');
|
|
});
|
|
});
|