Skip to content

Commit

Permalink
Unit tests for L1BitcoinDepositor contract
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-zimnoch committed Mar 8, 2024
1 parent d7c0955 commit 4616e6d
Show file tree
Hide file tree
Showing 3 changed files with 1,485 additions and 41 deletions.
16 changes: 15 additions & 1 deletion solidity/contracts/l2/L1BitcoinDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,21 @@ contract L1BitcoinDepositor is
? tx.gasprice
: maxGasPrice;

return (refund / gasPrice) - staticGas;
// Should not happen but check just in case of weird ReimbursementPool
// configuration.
if (gasPrice == 0) {
return 0;
}

uint256 gasSpent = (refund / gasPrice);

// Should not happen but check just in case of weird ReimbursementPool
// configuration.
if (staticGas > gasSpent) {
return 0;
}

return gasSpent - staticGas;
}

/// @notice Quotes the payment that must be attached to the `finalizeDeposit`
Expand Down
Loading

0 comments on commit 4616e6d

Please sign in to comment.