HasNoContracts.test.js 1.0 KB

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