Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance setStakingContract function #274

Merged
merged 2 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/ERC677BridgeTokenRewardable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract ERC677BridgeTokenRewardable is ERC677BridgeToken {

function setStakingContract(address _stakingContract) external onlyOwner {
require(AddressUtils.isContract(_stakingContract));
require(balanceOf(_stakingContract) == 0);
stakingContract = _stakingContract;
}

Expand Down
11 changes: 11 additions & 0 deletions test/poa20_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ async function testERC677BridgeToken(accounts, rewardable) {
await token.setStakingContract(ZERO_ADDRESS).should.be.rejectedWith(ERROR_MSG)
;(await token.stakingContract()).should.be.equal(ZERO_ADDRESS)
})

it('fail to set Staking contract address with non-zero balance', async () => {
const stakingContract = await StakingTest.new()
;(await token.stakingContract()).should.be.equal(ZERO_ADDRESS)

await token.mint(user, 1, { from: owner }).should.be.fulfilled
await token.transfer(stakingContract.address, 1, { from: user }).should.be.fulfilled

await token.setStakingContract(stakingContract.address).should.be.rejectedWith(ERROR_MSG)
;(await token.stakingContract()).should.be.equal(ZERO_ADDRESS)
})
})

describe('#mintReward', async () => {
Expand Down