Skip to content

Commit

Permalink
Add bridgesAllowedLength method check on setBlockRewardContract
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Oct 12, 2018
1 parent 00b4976 commit 339bd4a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions contracts/IBlockReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ interface IBlockReward {
function addExtraReceiver(uint256 _amount, address _receiver) external;
function mintedTotally() public view returns (uint256);
function mintedTotallyByBridge(address _bridge) public view returns(uint256);
function bridgesAllowedLength() external view returns(uint256);
}
4 changes: 4 additions & 0 deletions contracts/test/BlockReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ contract BlockReward is IBlockReward {
function () external payable {
}

function bridgesAllowedLength() external view returns(uint256) {
return 3;
}

function addExtraReceiver(uint256 _amount, address _receiver) external {
require(_amount > 0);
require(_receiver != address(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge {
}

function setBlockRewardContract(address _blockReward) public onlyOwner {
require(_blockReward != address(0) && isContract(_blockReward));
require(_blockReward != address(0) && isContract(_blockReward) && (IBlockReward(_blockReward).bridgesAllowedLength() != 0));
addressStorage[keccak256(abi.encodePacked("blockRewardContract"))] = _blockReward;
}

Expand Down
3 changes: 3 additions & 0 deletions test/erc_to_native/home_bridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ contract('HomeBridge_ERC20_to_Native', async (accounts) => {
const notAContract = accounts[5]
await homeContract.setBlockRewardContract(notAContract).should.be.rejectedWith(ERROR_MSG)
secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract())

await homeContract.setBlockRewardContract(validatorContract.address).should.be.rejectedWith(ERROR_MSG)
secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract())
})

it('cant set maxPerTx > dailyLimit', async () => {
Expand Down

0 comments on commit 339bd4a

Please sign in to comment.