Skip to content

Commit

Permalink
updated error
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinagill15 committed Aug 14, 2024
1 parent 7a9c7a9 commit 8deb83f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/oft-evm/contracts/NativeOFTAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ abstract contract NativeOFTAdapter is OFTCore {
) public payable virtual override returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) {
// @dev Ensure the native funds in msg.value are enough to cover the fees and amount to send (with dust removed).
// TODO should we remove dust from _sendParam.amountLD here?
if (_fee.nativeFee + _removeDust(_sendParam.amountLD) != msg.value) {
revert NotEnoughNative(msg.value);
uint256 requiredMsgValue = _fee.nativeFee + _removeDust(_sendParam.amountLD);
if (msg.value != requiredMsgValue) {
revert InsufficientMessageValue(msg.value, requiredMsgValue);
}

return super.send(_sendParam, _fee, _refundAddress);
Expand Down
5 changes: 2 additions & 3 deletions packages/oft-evm/test/OFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,14 @@ contract OFTTest is TestHelperOz5 {
);

MessagingFee memory fee = dNativeOFTAdapter.quoteSend(sendParam, false);
uint256 msgValue = fee.nativeFee + sendParam.amountLD;

vm.prank(userD);
vm.expectRevert(
abi.encodeWithSelector(OAppSender.NotEnoughNative.selector, fee.nativeFee)
abi.encodeWithSelector(NativeOFTAdapter.InsufficientMessageValue.selector, fee.nativeFee, msgValue)
);
dNativeOFTAdapter.asNativeOFTAdapterMock().send{ value: fee.nativeFee}(sendParam, fee, userD);

uint256 msgValue = fee.nativeFee + sendParam.amountLD;

vm.prank(userD);
dNativeOFTAdapter.asNativeOFTAdapterMock().send{ value: msgValue }(sendParam, fee, userD);

Expand Down

0 comments on commit 8deb83f

Please sign in to comment.