Add missing checks and return values (#535)
This commit is contained in:
parent
2def0318bb
commit
d5fc8ab8d5
|
@ -2,6 +2,7 @@ pragma solidity 0.4.24;
|
|||
|
||||
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
|
||||
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
|
||||
import "openzeppelin-solidity/contracts/AddressUtils.sol";
|
||||
|
||||
/**
|
||||
* @title BaseMediatorFeeManager
|
||||
|
@ -32,8 +33,10 @@ contract BaseMediatorFeeManager is Ownable {
|
|||
* @param _owner address of the owner of the fee manager contract.
|
||||
* @param _fee the fee percentage amount.
|
||||
* @param _rewardAccountList list of addresses that will receive the fee rewards.
|
||||
* @param _mediatorContract address of the mediator contract used together with this fee manager.
|
||||
*/
|
||||
constructor(address _owner, uint256 _fee, address[] _rewardAccountList, address _mediatorContract) public {
|
||||
require(AddressUtils.isContract(_mediatorContract));
|
||||
require(_rewardAccountList.length > 0 && _rewardAccountList.length <= MAX_REWARD_ACCOUNTS);
|
||||
_transferOwnership(_owner);
|
||||
_setFee(_fee);
|
||||
|
|
|
@ -29,6 +29,7 @@ contract InterestReceiver is ERC677Receiver, Ownable, Claimable, TokenSwapper {
|
|||
*/
|
||||
constructor(address _owner, address _bridgeContract, address _receiverInXDai) public {
|
||||
require(AddressUtils.isContract(_bridgeContract));
|
||||
require(_receiverInXDai != address(0));
|
||||
_transferOwnership(_owner);
|
||||
bridgeContract = _bridgeContract;
|
||||
receiverInXDai = _receiverInXDai;
|
||||
|
@ -49,6 +50,7 @@ contract InterestReceiver is ERC677Receiver, Ownable, Claimable, TokenSwapper {
|
|||
* @param _receiverInXDai address of new receiver account in the xDai chain
|
||||
*/
|
||||
function setReceiverInXDai(address _receiverInXDai) external onlyOwner {
|
||||
require(_receiverInXDai != address(0));
|
||||
receiverInXDai = _receiverInXDai;
|
||||
}
|
||||
|
||||
|
@ -93,6 +95,7 @@ contract InterestReceiver is ERC677Receiver, Ownable, Claimable, TokenSwapper {
|
|||
daiToken().approve(address(bridgeContract), 0);
|
||||
emit RelayTokensFailed(receiverInXDai, finalDaiBalance);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,6 +98,7 @@ contract HomeMultiAMBErc20ToErc677 is BasicMultiAMBErc20ToErc677, HomeFeeManager
|
|||
) external onlyMediator {
|
||||
string memory name = _name;
|
||||
string memory symbol = _symbol;
|
||||
require(bytes(name).length > 0 || bytes(symbol).length > 0);
|
||||
if (bytes(name).length == 0) {
|
||||
name = symbol;
|
||||
} else if (bytes(symbol).length == 0) {
|
||||
|
|
|
@ -601,6 +601,15 @@ contract('ForeignAMBNativeToErc20', async accounts => {
|
|||
mediator.address,
|
||||
token.address
|
||||
).should.be.rejectedWith(ERROR_MSG)
|
||||
// invalid mediator contract address
|
||||
await ForeignFeeManagerAMBNativeToErc20.new(
|
||||
owner,
|
||||
fee,
|
||||
rewardAccountList,
|
||||
ZERO_ADDRESS,
|
||||
token.address
|
||||
).should.be.rejectedWith(ERROR_MSG)
|
||||
// invalid token address
|
||||
await ForeignFeeManagerAMBNativeToErc20.new(
|
||||
owner,
|
||||
fee,
|
||||
|
|
|
@ -1120,6 +1120,10 @@ contract('HomeAMBNativeToErc20', async accounts => {
|
|||
[...rewardAccountList, mediator.address],
|
||||
mediator.address
|
||||
).should.be.rejectedWith(ERROR_MSG)
|
||||
// invalid mediator contract
|
||||
await HomeFeeManagerAMBNativeToErc20.new(owner, fee, rewardAccountList, ZERO_ADDRESS).should.be.rejectedWith(
|
||||
ERROR_MSG
|
||||
)
|
||||
await HomeFeeManagerAMBNativeToErc20.new(owner, fee, rewardAccountList, mediator.address)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1598,6 +1598,7 @@ contract('ForeignBridge_ERC20_to_Native', async accounts => {
|
|||
})
|
||||
|
||||
it('should update bridge contract address', async () => {
|
||||
await interestRecipient.setReceiverInXDai(ZERO_ADDRESS, { from: receiverOwner }).should.be.rejected
|
||||
await interestRecipient.setReceiverInXDai(accounts[8], { from: receiverOwner }).should.be.fulfilled
|
||||
expect(await interestRecipient.receiverInXDai()).to.be.equal(accounts[8])
|
||||
})
|
||||
|
|
|
@ -419,6 +419,34 @@ contract('HomeMultiAMBErc20ToErc677', async accounts => {
|
|||
expect(await homeToken.decimals()).to.be.bignumber.equal('18')
|
||||
})
|
||||
|
||||
it('should not register new token with empty name and empty symbol', async () => {
|
||||
const data1 = await contract.contract.methods
|
||||
.deployAndHandleBridgedTokens(accounts[0], '', '', 18, user, oneEther.toString(10))
|
||||
.encodeABI()
|
||||
await ambBridgeContract.executeMessageCall(
|
||||
contract.address,
|
||||
otherSideMediator.address,
|
||||
data1,
|
||||
exampleMessageId,
|
||||
2000000
|
||||
).should.be.fulfilled
|
||||
|
||||
expect(await ambBridgeContract.messageCallStatus(exampleMessageId)).to.be.equal(false)
|
||||
|
||||
const data2 = await contract.contract.methods
|
||||
.deployAndHandleBridgedTokens(accounts[1], 'TEST', '', 18, user, oneEther.toString(10))
|
||||
.encodeABI()
|
||||
await ambBridgeContract.executeMessageCall(
|
||||
contract.address,
|
||||
otherSideMediator.address,
|
||||
data2,
|
||||
otherMessageId,
|
||||
2000000
|
||||
).should.be.fulfilled
|
||||
|
||||
expect(await ambBridgeContract.messageCallStatus(otherMessageId)).to.be.equal(true)
|
||||
})
|
||||
|
||||
for (const decimals of [3, 18, 20]) {
|
||||
it(`should initialize limits according to decimals = ${decimals}`, async () => {
|
||||
const f1 = toBN(`1${'0'.repeat(decimals)}`)
|
||||
|
|
Loading…
Reference in New Issue