Cleanup of Ownership directory (#2120)
* Remove Ownable.isOwner. * Remove ownable behavior from tests * Make Escrow use Ownable instead of Secondary * Migrate GSNRecipientERC20Fee to Ownable * Remove Secondary * Move Ownable to access directory * Remove mentions of Secondary * Add changelog entry * Move Ownable tests to access * Remove unused mock
This commit is contained in:
@ -2,13 +2,13 @@ const { balance, ether, expectEvent, expectRevert } = require('@openzeppelin/tes
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
|
||||
const amount = ether('42');
|
||||
|
||||
describe('as an escrow', function () {
|
||||
describe('deposits', function () {
|
||||
it('can accept a single deposit', async function () {
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
|
||||
expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount);
|
||||
|
||||
@ -16,17 +16,17 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('can accept an empty deposit', async function () {
|
||||
await this.escrow.deposit(payee1, { from: primary, value: 0 });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: 0 });
|
||||
});
|
||||
|
||||
it('only the primary account can deposit', async function () {
|
||||
it('only the owner can deposit', async function () {
|
||||
await expectRevert(this.escrow.deposit(payee1, { from: payee2 }),
|
||||
'Secondary: caller is not the primary account'
|
||||
'Ownable: caller is not the owner'
|
||||
);
|
||||
});
|
||||
|
||||
it('emits a deposited event', async function () {
|
||||
const { logs } = await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
const { logs } = await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
expectEvent.inLogs(logs, 'Deposited', {
|
||||
payee: payee1,
|
||||
weiAmount: amount,
|
||||
@ -34,8 +34,8 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('can add multiple deposits on a single account', async function () {
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount.muln(2) });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount.muln(2) });
|
||||
|
||||
expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount.muln(3));
|
||||
|
||||
@ -43,8 +43,8 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('can track deposits to multiple accounts', async function () {
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
await this.escrow.deposit(payee2, { from: primary, value: amount.muln(2) });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.deposit(payee2, { from: owner, value: amount.muln(2) });
|
||||
|
||||
expect(await balance.current(this.escrow.address)).to.be.bignumber.equal(amount.muln(3));
|
||||
|
||||
@ -58,8 +58,8 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
it('can withdraw payments', async function () {
|
||||
const balanceTracker = await balance.tracker(payee1);
|
||||
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
await this.escrow.withdraw(payee1, { from: primary });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
await this.escrow.withdraw(payee1, { from: owner });
|
||||
|
||||
expect(await balanceTracker.delta()).to.be.bignumber.equal(amount);
|
||||
|
||||
@ -68,18 +68,18 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
|
||||
});
|
||||
|
||||
it('can do an empty withdrawal', async function () {
|
||||
await this.escrow.withdraw(payee1, { from: primary });
|
||||
await this.escrow.withdraw(payee1, { from: owner });
|
||||
});
|
||||
|
||||
it('only the primary account can withdraw', async function () {
|
||||
it('only the owner can withdraw', async function () {
|
||||
await expectRevert(this.escrow.withdraw(payee1, { from: payee1 }),
|
||||
'Secondary: caller is not the primary account'
|
||||
'Ownable: caller is not the owner'
|
||||
);
|
||||
});
|
||||
|
||||
it('emits a withdrawn event', async function () {
|
||||
await this.escrow.deposit(payee1, { from: primary, value: amount });
|
||||
const { logs } = await this.escrow.withdraw(payee1, { from: primary });
|
||||
await this.escrow.deposit(payee1, { from: owner, value: amount });
|
||||
const { logs } = await this.escrow.withdraw(payee1, { from: owner });
|
||||
expectEvent.inLogs(logs, 'Withdrawn', {
|
||||
payee: payee1,
|
||||
weiAmount: amount,
|
||||
|
||||
Reference in New Issue
Block a user