Address.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const { constants } = require('openzeppelin-test-helpers');
  2. const AddressImpl = artifacts.require('AddressImpl');
  3. const SimpleToken = artifacts.require('SimpleToken');
  4. contract('Address', function ([_, other]) {
  5. const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF';
  6. beforeEach(async function () {
  7. this.mock = await AddressImpl.new();
  8. });
  9. describe('isContract', function () {
  10. it('should return false for account address', async function () {
  11. (await this.mock.isContract(other)).should.equal(false);
  12. });
  13. it('should return true for contract address', async function () {
  14. const contract = await SimpleToken.new();
  15. (await this.mock.isContract(contract.address)).should.equal(true);
  16. });
  17. });
  18. describe('toPayable', function () {
  19. it('should return a payable address when the account is the zero address', async function () {
  20. (await this.mock.toPayable(constants.ZERO_ADDRESS)).should.equal(constants.ZERO_ADDRESS);
  21. });
  22. it('should return a payable address when the account is an arbitrary address', async function () {
  23. (await this.mock.toPayable(other)).should.equal(other);
  24. });
  25. it('should return a payable address when the account is the all ones address', async function () {
  26. (await this.mock.toPayable(ALL_ONES_ADDRESS)).should.equal(ALL_ONES_ADDRESS);
  27. });
  28. });
  29. });