@ -4,6 +4,7 @@ pragma solidity >=0.8.0;
import " forge-std/Test.sol " ;
import { TransparentUpgradeableProxy } from " @openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol " ;
import { TestPostDispatchHook } from " ../../contracts/test/TestPostDispatchHook.sol " ;
import { HypNativeScaled } from " ../../contracts/token/extensions/HypNativeScaled.sol " ;
import { HypERC20 } from " ../../contracts/token/HypERC20.sol " ;
import { HypNative } from " ../../contracts/token/HypNative.sol " ;
@ -14,6 +15,8 @@ contract HypNativeScaledTest is Test {
uint32 nativeDomain = 1 ;
uint32 synthDomain = 2 ;
address internal constant ALICE = address ( 0x1 ) ;
uint8 decimals = 9 ;
uint256 mintAmount = 123456789 ;
uint256 nativeDecimals = 18 ;
@ -149,7 +152,7 @@ contract HypNativeScaledTest is Test {
address recipient = address ( 0xdeadbeef ) ;
bytes32 bRecipient = TypeCasts . addressToBytes32 ( recipient ) ;
vm . assume ( nativeValue < address ( this ) . balanc e) ;
vm . deal ( address ( this ) , nativeValu e) ;
vm . expectEmit ( true , true , true , true ) ;
emit SentTransferRemote ( synthDomain , bRecipient , synthAmount ) ;
native . transferRemote { value : nativeValue } (
@ -161,6 +164,33 @@ contract HypNativeScaledTest is Test {
assertEq ( synth . balanceOf ( recipient ) , synthAmount ) ;
}
function testTransfer_withHookSpecified (
uint256 amount ,
bytes calldata metadata
) public {
vm . assume ( amount <= mintAmount ) ;
uint256 nativeValue = amount * ( 10 ** nativeDecimals ) ;
uint256 synthAmount = amount * ( 10 ** decimals ) ;
address recipient = address ( 0xdeadbeef ) ;
bytes32 bRecipient = TypeCasts . addressToBytes32 ( recipient ) ;
TestPostDispatchHook hook = new TestPostDispatchHook ( ) ;
vm . deal ( address ( this ) , nativeValue ) ;
vm . expectEmit ( true , true , true , true ) ;
emit SentTransferRemote ( synthDomain , bRecipient , synthAmount ) ;
native . transferRemote { value : nativeValue } (
synthDomain ,
bRecipient ,
nativeValue ,
metadata ,
address ( hook )
) ;
environment . processNextPendingMessageFromDestination ( ) ;
assertEq ( synth . balanceOf ( recipient ) , synthAmount ) ;
}
function test_transferRemote_reverts_whenAmountExceedsValue (
uint256 nativeValue
) public {
@ -174,5 +204,14 @@ contract HypNativeScaledTest is Test {
bRecipient ,
nativeValue + 1
) ;
vm . expectRevert ( " Native: amount exceeds msg.value " ) ;
native . transferRemote { value : nativeValue } (
synthDomain ,
bRecipient ,
nativeValue + 1 ,
bytes ( " " ) ,
address ( 0 )
) ;
}
}