Destructible.test.js 1.1 KB

123456789101112131415161718192021222324
  1. import { ethGetBalance } from '../helpers/web3';
  2. const Destructible = artifacts.require('Destructible');
  3. require('../helpers/transactionMined.js');
  4. contract('Destructible', function (accounts) {
  5. it('should send balance to owner after destruction', async function () {
  6. let destructible = await Destructible.new({ from: accounts[0], value: web3.toWei('10', 'ether') });
  7. let owner = await destructible.owner();
  8. let initBalance = await ethGetBalance(owner);
  9. await destructible.destroy({ from: owner });
  10. let newBalance = await ethGetBalance(owner);
  11. assert.isTrue(newBalance > initBalance);
  12. });
  13. it('should send balance to recepient after destruction', async function () {
  14. let destructible = await Destructible.new({ from: accounts[0], value: web3.toWei('10', 'ether') });
  15. let owner = await destructible.owner();
  16. let initBalance = await ethGetBalance(accounts[1]);
  17. await destructible.destroyAndSend(accounts[1], { from: owner });
  18. let newBalance = await ethGetBalance(accounts[1]);
  19. assert.isTrue(newBalance.greaterThan(initBalance));
  20. });
  21. });