Destructible.test.js 1.1 KB

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