mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openzeppelin-contracts/test/ownership/HasNoTokens.test.js

47 lines
1.5 KiB

const { expectThrow } = require('../helpers/expectThrow');
const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock');
8 years ago
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
8 years ago
let hasNoTokens = null;
let token = null;
beforeEach(async () => {
// Create contract and token
hasNoTokens = await HasNoTokens.new({ from: owner });
token = await ERC223TokenMock.new(initialAccount, 100);
8 years ago
// Force token into contract
await token.transfer(hasNoTokens.address, 10, { from: initialAccount });
(await token.balanceOf(hasNoTokens.address)).should.be.bignumber.equal(10);
8 years ago
});
it('should not accept ERC223 tokens', async function () {
await expectThrow(token.transferERC223(hasNoTokens.address, 10, '', { from: initialAccount }));
8 years ago
});
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);
ownerFinalBalance.sub(ownerStartBalance).should.be.bignumber.equal(10);
(await token.balanceOf(hasNoTokens.address)).should.be.bignumber.equal(0);
8 years ago
});
it('should allow only owner to reclaim tokens', async function () {
8 years ago
await expectThrow(
hasNoTokens.reclaimToken(token.address, { from: anyone })
8 years ago
);
});
});