From f8b0cec15bef6f420da90b7b8732bc0897015dd5 Mon Sep 17 00:00:00 2001 From: Jakub Bogacz Date: Wed, 12 Sep 2018 17:49:00 +0200 Subject: [PATCH] Add unit test specific to Address utils (#1251) (#1316) (cherry picked from commit 7825caa1fdf8bec80ad43f4da15cf5ee4c9a8e3f) --- contracts/mocks/AddressImpl.sol | 15 +++++++++++++++ test/Address.test.js | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 contracts/mocks/AddressImpl.sol create mode 100644 test/Address.test.js diff --git a/contracts/mocks/AddressImpl.sol b/contracts/mocks/AddressImpl.sol new file mode 100644 index 000000000..b46fd06c3 --- /dev/null +++ b/contracts/mocks/AddressImpl.sol @@ -0,0 +1,15 @@ +pragma solidity ^0.4.24; + +import "../utils/Address.sol"; + + +contract AddressImpl { + function isContract(address account) + external + view + returns (bool) + { + return Address.isContract(account); + } + +} diff --git a/test/Address.test.js b/test/Address.test.js new file mode 100644 index 000000000..f41e57565 --- /dev/null +++ b/test/Address.test.js @@ -0,0 +1,20 @@ +const AddressImpl = artifacts.require('AddressImpl'); +const SimpleToken = artifacts.require('SimpleToken'); + +require('chai') + .should(); + +contract('Address', function ([_, anyone]) { + beforeEach(async function () { + this.mock = await AddressImpl.new(); + }); + + it('should return false for account address', async function () { + (await this.mock.isContract(anyone)).should.equal(false); + }); + + it('should return true for contract address', async function () { + const contract = await SimpleToken.new(); + (await this.mock.isContract(contract.address)).should.equal(true); + }); +});