Browse Source

Add unit test specific to Address utils (#1251) (#1316)

Jakub Bogacz 7 years ago
parent
commit
7825caa1fd
2 changed files with 35 additions and 0 deletions
  1. 15 0
      contracts/mocks/AddressImpl.sol
  2. 20 0
      test/Address.test.js

+ 15 - 0
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); 
+  }
+  
+}

+ 20 - 0
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);
+  });
+});