Destructible.test.js 1.0 KB

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