Destructible.test.js 1.0 KB

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