Files
openzeppelin-contracts/test/ownership/HasNoTokens.test.js
Nicolás Venturo 4544df47da All tests now use account names, and dont use accounts[0] (except ERC… (#1137)
* All tests now use account names, and dont use accounts[0] (except ERC721)

* Added account names to some missing contracts.
2018-08-02 16:55:31 -03:00

40 lines
1.4 KiB
JavaScript

const { expectThrow } = require('../helpers/expectThrow');
const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock');
contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
let hasNoTokens = null;
let token = null;
beforeEach(async () => {
// Create contract and token
hasNoTokens = await HasNoTokens.new({ from: owner });
token = await ERC223TokenMock.new(initialAccount, 100);
// Force token into contract
await token.transfer(hasNoTokens.address, 10, { from: initialAccount });
const startBalance = await token.balanceOf(hasNoTokens.address);
assert.equal(startBalance, 10);
});
it('should not accept ERC223 tokens', async function () {
await expectThrow(token.transferERC223(hasNoTokens.address, 10, ''));
});
it('should allow owner to reclaim tokens', async function () {
const ownerStartBalance = await token.balanceOf(owner);
await hasNoTokens.reclaimToken(token.address, { from: owner });
const ownerFinalBalance = await token.balanceOf(owner);
const finalBalance = await token.balanceOf(hasNoTokens.address);
assert.equal(finalBalance, 0);
assert.equal(ownerFinalBalance - ownerStartBalance, 10);
});
it('should allow only owner to reclaim tokens', async function () {
await expectThrow(
hasNoTokens.reclaimToken(token.address, { from: anyone })
);
});
});