-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple wrapper for address. (#1773)
* Updated code style to no more than120 characters per line. * Unify code comments style with Doxygen-style tags. * Fix the conflicts. * Add a return value in the contract ERC20Burnable. * A Add a wrapper function to change type of address to address payable. * U Modify Address utils. * A Add test case for Address. * U Modify code style in ERC20Burnable. * Add changelog entry. * Improved dev docs.
- Loading branch information
Showing
4 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
require('openzeppelin-test-helpers'); | ||
const { constants } = require('openzeppelin-test-helpers'); | ||
|
||
const AddressImpl = artifacts.require('AddressImpl'); | ||
const SimpleToken = artifacts.require('SimpleToken'); | ||
|
||
contract('Address', function ([_, other]) { | ||
const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'; | ||
|
||
beforeEach(async function () { | ||
this.mock = await AddressImpl.new(); | ||
}); | ||
|
||
it('should return false for account address', async function () { | ||
(await this.mock.isContract(other)).should.equal(false); | ||
describe('isContract', function () { | ||
it('should return false for account address', async function () { | ||
(await this.mock.isContract(other)).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); | ||
}); | ||
}); | ||
|
||
it('should return true for contract address', async function () { | ||
const contract = await SimpleToken.new(); | ||
(await this.mock.isContract(contract.address)).should.equal(true); | ||
describe('toPayable', function () { | ||
it('should return a payable address when the account is the zero address', async function () { | ||
(await this.mock.toPayable(constants.ZERO_ADDRESS)).should.equal(constants.ZERO_ADDRESS); | ||
}); | ||
|
||
it('should return a payable address when the account is an arbitrary address', async function () { | ||
(await this.mock.toPayable(other)).should.equal(other); | ||
}); | ||
|
||
it('should return a payable address when the account is the all ones address', async function () { | ||
(await this.mock.toPayable(ALL_ONES_ADDRESS)).should.equal(ALL_ONES_ADDRESS); | ||
}); | ||
}); | ||
}); |