Skip to content

Commit

Permalink
Marked MockTBTCVault functions virtual (#785)
Browse files Browse the repository at this point in the history
This allows projects using `MockTBTCVault` for tests of
`AbstractTBTCDepositor`-based contracts to inject custom logic, such as
minting of tBTC token. This logic is not important for tests of
`AbstractTBTCDepositor` but is usually important for tests of derived
contracts.
  • Loading branch information
lukasz-zimnoch authored Feb 14, 2024
2 parents d26bbdd + 15fe832 commit b9fa855
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion solidity/contracts/integrator/AbstractTBTCDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ abstract contract AbstractTBTCDepositor {
}

/// @notice Finalizes a deposit by calculating the amount of TBTC minted
/// for the deposit
/// for the deposit.
/// @param depositKey Deposit key identifying the deposit.
/// @return initialDepositAmount Amount of funding transaction deposit. In
/// TBTC token decimals precision.
Expand Down
15 changes: 13 additions & 2 deletions solidity/contracts/test/TestTBTCDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "../integrator/AbstractTBTCDepositor.sol";
import "../integrator/IBridge.sol";
import "../integrator/ITBTCVault.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract TestTBTCDepositor is AbstractTBTCDepositor {
event InitializeDepositReturned(uint256 depositKey);

Expand Down Expand Up @@ -168,7 +170,10 @@ contract MockTBTCVault is ITBTCVault {
return (request.requestedAt, request.finalizedAt);
}

function createOptimisticMintingRequest(uint256 depositKey) external {
/// @dev The function is virtual to allow other projects using this mock
/// for AbtractTBTCDepositor-based contract tests to add any custom
/// logic needed.
function createOptimisticMintingRequest(uint256 depositKey) public virtual {
require(
_requests[depositKey].requestedAt == 0,
"Request already exists"
Expand All @@ -177,7 +182,13 @@ contract MockTBTCVault is ITBTCVault {
_requests[depositKey].requestedAt = uint64(block.timestamp);
}

function finalizeOptimisticMintingRequest(uint256 depositKey) public {
/// @dev The function is virtual to allow other projects using this mock
/// for AbtractTBTCDepositor-based contract tests to add any custom
/// logic needed.
function finalizeOptimisticMintingRequest(uint256 depositKey)
public
virtual
{
require(
_requests[depositKey].requestedAt != 0,
"Request does not exist"
Expand Down

0 comments on commit b9fa855

Please sign in to comment.