Add check on ErcToNative onFailedAffirmation method

This commit is contained in:
Gerardo Nardelli 2018-12-03 16:47:41 -03:00
parent 414e437b60
commit 12d0422ca0
2 changed files with 20 additions and 0 deletions

View File

@ -97,6 +97,10 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge {
}
function onFailedAffirmation(address _recipient, uint256 _value, bytes32 _txHash) internal {
address recipient;
uint256 value;
(recipient, value) = txAboveLimits(_txHash);
require(value == 0);
setOutOfLimitAmount(outOfLimitAmount().add(_value));
setTxAboveLimits(_recipient, _value, _txHash);
emit AmountLimitExceeded(_recipient, _value, _txHash);

View File

@ -400,6 +400,22 @@ contract('HomeBridge_ERC20_to_Native', async (accounts) => {
transactionHash
});
})
it('should fail if txHash already set as above of limits', async () => {
const recipient = accounts[5];
const value = oneEther;
const transactionHash = "0x806335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415";
const {logs} = await homeBridge.executeAffirmation(recipient, value, transactionHash, {from: authorities[0]}).should.be.fulfilled;
logs[0].event.should.be.equal("AmountLimitExceeded");
logs[0].args.should.be.deep.equal({
recipient,
value,
transactionHash
});
await homeBridge.executeAffirmation(recipient, value, transactionHash, {from: authorities[0]}).should.be.rejectedWith(ERROR_MSG)
await homeBridge.executeAffirmation(accounts[6], value, transactionHash, {from: authorities[0]}).should.be.rejectedWith(ERROR_MSG)
})
it('should not allow execute affirmation over daily foreign limit', async () => {
await blockRewardContract.sendTransaction({
from: accounts[2],