Files
openzeppelin-contracts/test/lifecycle/Destructible.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

28 lines
1.0 KiB
JavaScript

const DestructibleMock = artifacts.require('DestructibleMock');
const { ethGetBalance } = require('../helpers/web3');
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);
assert.isTrue(newBalance > 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);
assert.isTrue(newBalance.greaterThan(initBalance));
});
});