Destructible.test.js 1.1 KB

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