Destructible.js 1.0 KB

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