Destructible.test.js 981 B

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