Skip to content

Commit

Permalink
add revert on transfer and transfer From
Browse files Browse the repository at this point in the history
  • Loading branch information
gfournieriExec committed Jun 10, 2024
1 parent 1b58543 commit 5efcfc4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions contracts/mocks/IexecPocoMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract IexecPocoMock is ERC20 {
bool public shouldRevertOnSponsorMatchOrdersBoost = false;
bool public shouldRevertOnClaim = false;
bool public shouldReturnTaskWithFailedStatus = false;
bool public shouldRevertOnTransfer = false;
bool public shouldRevertOnTransferFrom = false;

bytes32 public mockDealId = keccak256("deal");
uint256 public mockTaskIndex = 0;
Expand Down Expand Up @@ -92,6 +94,14 @@ contract IexecPocoMock is ERC20 {
shouldRevertOnSponsorMatchOrdersBoost = true;
}

function willRevertOnTransfer() external {
shouldRevertOnTransfer = true;
}

function willRevertOnTransferFrom() external {
shouldRevertOnTransferFrom = true;
}

/**
* Claim
*/
Expand Down Expand Up @@ -155,4 +165,25 @@ contract IexecPocoMock is ERC20 {
requestOrder.volume
);
}

/**
* Override transfer and transferFrom to mock revert case
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
if (shouldRevertOnTransfer) {
return !shouldRevertOnTransfer;
}
return super.transfer(recipient, amount);
}

function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
if (shouldRevertOnTransferFrom) {
return !shouldRevertOnTransferFrom;
}
return super.transferFrom(sender, recipient, amount);
}
}

0 comments on commit 5efcfc4

Please sign in to comment.