HasNoContracts.test.js 1012 B

1234567891011121314151617181920212223242526272829303132
  1. const { expectThrow } = require('../helpers/expectThrow');
  2. const Ownable = artifacts.require('Ownable');
  3. const HasNoContracts = artifacts.require('HasNoContracts');
  4. contract('HasNoContracts', function (accounts) {
  5. let hasNoContracts = null;
  6. let ownable = null;
  7. beforeEach(async () => {
  8. // Create contract and token
  9. hasNoContracts = await HasNoContracts.new();
  10. ownable = await Ownable.new();
  11. // Force ownership into contract
  12. await ownable.transferOwnership(hasNoContracts.address);
  13. const owner = await ownable.owner();
  14. assert.equal(owner, hasNoContracts.address);
  15. });
  16. it('should allow owner to reclaim contracts', async function () {
  17. await hasNoContracts.reclaimContract(ownable.address);
  18. const owner = await ownable.owner();
  19. assert.equal(owner, accounts[0]);
  20. });
  21. it('should allow only owner to reclaim contracts', async function () {
  22. await expectThrow(
  23. hasNoContracts.reclaimContract(ownable.address, { from: accounts[1] }),
  24. );
  25. });
  26. });