@ -113,6 +113,11 @@ contract HypERC4626CollateralTest is HypTokenTest {
_connectRouters ( domains , addresses ) ;
}
function testDisableInitializers ( ) public {
vm . expectRevert ( " Initializable: contract is already initialized " ) ;
remoteToken . initialize ( 0 , " " , " " , address ( 0 ) , address ( 0 ) , address ( 0 ) ) ;
}
function test_collateralDomain ( ) public view {
assertEq (
remoteRebasingToken . collateralDomain ( ) ,
@ -242,6 +247,108 @@ contract HypERC4626CollateralTest is HypTokenTest {
) ;
}
function testTransferFrom ( ) public {
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
assertEq ( remoteToken . balanceOf ( BOB ) , transferAmount ) ;
uint256 transferAmount2 = 50 e18 ;
vm . prank ( BOB ) ;
remoteToken . approve ( CAROL , transferAmount2 ) ;
vm . prank ( CAROL ) ;
bool success = remoteToken . transferFrom ( BOB , DANIEL , transferAmount2 ) ;
assertTrue ( success , " TransferFrom should succeed " ) ;
assertEq (
remoteToken . balanceOf ( BOB ) ,
transferAmount - transferAmount2 ,
" BOB ' s balance should decrease "
) ;
assertEq (
remoteToken . balanceOf ( DANIEL ) ,
transferAmount2 ,
" DANIEL ' s balance should increase "
) ;
assertEq (
remoteToken . allowance ( BOB , CAROL ) ,
0 ,
" Allowance should be zero after transfer "
) ;
}
event Transfer ( address indexed from , address indexed to , uint256 value ) ;
function testTransferEvent ( ) public {
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
assertEq ( remoteToken . balanceOf ( BOB ) , transferAmount ) ;
uint256 transferAmount2 = 50 e18 ;
vm . expectEmit ( true , true , false , true ) ;
emit Transfer ( BOB , CAROL , transferAmount2 ) ;
vm . prank ( BOB ) ;
remoteToken . transfer ( CAROL , transferAmount2 ) ;
assertEq (
remoteToken . balanceOf ( BOB ) ,
transferAmount - transferAmount2 ,
" BOB ' s balance should decrease "
) ;
assertEq (
remoteToken . balanceOf ( CAROL ) ,
transferAmount2 ,
" CAROL ' s balance should increase "
) ;
}
function testTotalShares ( ) public {
uint256 initialShares = remoteRebasingToken . totalShares ( ) ;
assertEq ( initialShares , 0 , " Initial shares should be zero " ) ;
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
uint256 sharesAfterTransfer = remoteRebasingToken . totalShares ( ) ;
assertEq (
sharesAfterTransfer ,
remoteRebasingToken . assetsToShares ( transferAmount ) ,
" Shares should match transferred amount converted to shares "
) ;
_accrueYield ( ) ;
localRebasingToken . rebase ( DESTINATION , bytes ( " " ) , address ( 0 ) ) ;
remoteMailbox . processNextInboundMessage ( ) ;
uint256 sharesAfterYield = remoteRebasingToken . totalShares ( ) ;
assertEq (
sharesAfterYield ,
sharesAfterTransfer ,
" Total shares should remain constant after yield accrual "
) ;
}
function testShareBalanceOf ( ) public {
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
uint256 bobShareBalance = remoteRebasingToken . shareBalanceOf ( BOB ) ;
assertEq (
bobShareBalance ,
remoteRebasingToken . assetsToShares ( transferAmount ) ,
" Bob ' s share balance should match transferred amount converted to shares "
) ;
_accrueYield ( ) ;
localRebasingToken . rebase ( DESTINATION , bytes ( " " ) , address ( 0 ) ) ;
remoteMailbox . processNextInboundMessage ( ) ;
uint256 bobShareBalanceAfterYield = remoteRebasingToken . shareBalanceOf (
BOB
) ;
assertEq (
bobShareBalanceAfterYield ,
bobShareBalance ,
" Bob ' s share balance should remain constant after yield accrual "
) ;
}
function testWithdrawalWithoutYield ( ) public {
uint256 bobPrimaryBefore = primaryToken . balanceOf ( BOB ) ;
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
@ -480,6 +587,32 @@ contract HypERC4626CollateralTest is HypTokenTest {
) ;
}
function testTotalSupply ( ) public {
uint256 initialSupply = remoteToken . totalSupply ( ) ;
assertEq ( initialSupply , 0 , " Initial supply should be zero " ) ;
_performRemoteTransferWithoutExpectation ( 0 , transferAmount ) ;
uint256 supplyAfterTransfer = remoteToken . totalSupply ( ) ;
assertEq (
supplyAfterTransfer ,
transferAmount ,
" Supply should match transferred amount "
) ;
_accrueYield ( ) ;
localRebasingToken . rebase ( DESTINATION , bytes ( " " ) , address ( 0 ) ) ;
remoteMailbox . processNextInboundMessage ( ) ;
uint256 supplyAfterYield = remoteToken . totalSupply ( ) ;
assertApproxEqRelDecimal (
supplyAfterYield ,
transferAmount + _discountedYield ( ) ,
1 e14 ,
0 ,
" Supply should include yield "
) ;
}
function testTransfer_withHookSpecified (
uint256 ,
bytes calldata