Remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner (#1254)

* remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner

* remove unused ERC223TokenMock

* remove Contactable

* remove TokenDestructible

* remove DeprecatedERC721

* inline Destructible#destroy in Bounty

* remove Destructible
This commit is contained in:
Francisco Giordano
2018-09-03 17:27:16 -03:00
committed by GitHub
parent 2441fd7d17
commit bd994a88de
18 changed files with 8 additions and 496 deletions

View File

@ -1,33 +0,0 @@
const DestructibleMock = artifacts.require('DestructibleMock');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('Destructible', function ([_, owner, recipient]) {
beforeEach(async function () {
this.destructible = await DestructibleMock.new({ from: owner });
await web3.eth.sendTransaction({
from: owner,
to: this.destructible.address,
value: web3.toWei('10', 'ether'),
});
});
it('should send balance to owner after destruction', async function () {
const initBalance = await ethGetBalance(owner);
await this.destructible.destroy({ from: owner });
const newBalance = await ethGetBalance(owner);
newBalance.should.be.bignumber.gt(initBalance);
});
it('should send balance to recepient after destruction', async function () {
const initBalance = await ethGetBalance(recipient);
await this.destructible.destroyAndSend(recipient, { from: owner });
const newBalance = await ethGetBalance(recipient);
newBalance.should.be.bignumber.gt(initBalance);
});
});

View File

@ -1,39 +0,0 @@
const { ethGetBalance } = require('../helpers/web3');
const TokenDestructible = artifacts.require('TokenDestructible');
const ERC20Mock = artifacts.require('ERC20Mock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('TokenDestructible', function ([_, owner]) {
let tokenDestructible;
beforeEach(async function () {
tokenDestructible = await TokenDestructible.new({
from: owner,
value: web3.toWei('10', 'ether'),
});
});
it('should send balance to owner after destruction', async function () {
const initBalance = await ethGetBalance(owner);
await tokenDestructible.destroy([], { from: owner });
const newBalance = await ethGetBalance(owner);
newBalance.should.be.bignumber.gt(initBalance);
});
it('should send tokens to owner after destruction', async function () {
const token = await ERC20Mock.new(tokenDestructible.address, 100);
(await token.balanceOf(tokenDestructible.address)).should.be.bignumber.equal(100);
(await token.balanceOf(owner)).should.be.bignumber.equal(0);
await tokenDestructible.destroy([token.address], { from: owner });
(await token.balanceOf(tokenDestructible.address)).should.be.bignumber.equal(0);
(await token.balanceOf(owner)).should.be.bignumber.equal(100);
});
});

View File

@ -1,25 +0,0 @@
const Contactable = artifacts.require('Contactable');
contract('Contactable', function () {
let contactable;
beforeEach(async function () {
contactable = await Contactable.new();
});
it('should have an empty contact info', async function () {
(await contactable.contactInformation()).should.equal('');
});
describe('after setting the contact information', function () {
const contactInfo = 'contact information';
beforeEach(async function () {
await contactable.setContactInformation(contactInfo);
});
it('should return the setted contact information', async function () {
(await contactable.contactInformation()).should.equal(contactInfo);
});
});
});

View File

@ -1,29 +0,0 @@
const { expectThrow } = require('../helpers/expectThrow');
const Ownable = artifacts.require('Ownable');
const HasNoContracts = artifacts.require('HasNoContracts');
contract('HasNoContracts', function ([_, owner, anyone]) {
let hasNoContracts = null;
let ownable = null;
beforeEach(async function () {
// Create contract and token
hasNoContracts = await HasNoContracts.new({ from: owner });
ownable = await Ownable.new({ from: owner });
// Force ownership into contract
await ownable.transferOwnership(hasNoContracts.address, { from: owner });
});
it('should allow owner to reclaim contracts', async function () {
await hasNoContracts.reclaimContract(ownable.address, { from: owner });
(await ownable.owner()).should.equal(owner);
});
it('should allow only owner to reclaim contracts', async function () {
await expectThrow(
hasNoContracts.reclaimContract(ownable.address, { from: anyone })
);
});
});

View File

@ -1,61 +0,0 @@
const { expectThrow } = require('../helpers/expectThrow');
const { ethSendTransaction, ethGetBalance } = require('../helpers/web3');
const HasNoEtherTest = artifacts.require('HasNoEtherTest');
const ForceEther = artifacts.require('ForceEther');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('HasNoEther', function ([_, owner, anyone]) {
const amount = web3.toWei('1', 'ether');
beforeEach(async function () {
this.hasNoEther = await HasNoEtherTest.new({ from: owner });
});
it('should not accept ether in constructor', async function () {
await expectThrow(HasNoEtherTest.new({ value: amount }));
});
it('should not accept ether', async function () {
await expectThrow(
ethSendTransaction({
from: owner,
to: this.hasNoEther.address,
value: amount,
}),
);
});
it('should allow owner to reclaim ether', async function () {
const startBalance = await ethGetBalance(this.hasNoEther.address);
startBalance.should.be.bignumber.equal(0);
// Force ether into it
const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(this.hasNoEther.address);
(await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(amount);
// Reclaim
const ownerStartBalance = await ethGetBalance(owner);
await this.hasNoEther.reclaimEther({ from: owner });
const ownerFinalBalance = await ethGetBalance(owner);
ownerFinalBalance.should.be.bignumber.gt(ownerStartBalance);
(await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(0);
});
it('should allow only owner to reclaim ether', async function () {
// Force ether into it
const forceEther = await ForceEther.new({ value: amount });
await forceEther.destroyAndSend(this.hasNoEther.address);
(await ethGetBalance(this.hasNoEther.address)).should.be.bignumber.equal(amount);
// Reclaim
await expectThrow(this.hasNoEther.reclaimEther({ from: anyone }));
});
});

View File

@ -1,46 +0,0 @@
const { expectThrow } = require('../helpers/expectThrow');
const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('HasNoTokens', function ([_, owner, initialAccount, anyone]) {
let hasNoTokens = null;
let token = null;
beforeEach(async function () {
// 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 });
(await token.balanceOf(hasNoTokens.address)).should.be.bignumber.equal(10);
});
it('should not accept ERC223 tokens', async function () {
await expectThrow(token.transferERC223(hasNoTokens.address, 10, '', { from: initialAccount }));
});
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);
});
it('should allow only owner to reclaim tokens', async function () {
await expectThrow(
hasNoTokens.reclaimToken(token.address, { from: anyone })
);
});
});