@ -13,6 +13,8 @@ import {TestInterchainGasPaymaster} from "../contracts/test/TestInterchainGasPay
import { IPostDispatchHook } from " ../contracts/interfaces/hooks/IPostDispatchHook.sol " ;
import { CallLib , OwnableMulticall , InterchainAccountRouter } from " ../contracts/middleware/InterchainAccountRouter.sol " ;
import { InterchainAccountIsm } from " ../contracts/isms/routing/InterchainAccountIsm.sol " ;
import { AbstractPostDispatchHook } from " ../contracts/hooks/libs/AbstractPostDispatchHook.sol " ;
import { TestPostDispatchHook } from " ../contracts/test/TestPostDispatchHook.sol " ;
contract Callable {
mapping ( address => bytes32 ) public data ;
@ -108,10 +110,11 @@ contract InterchainAccountRouterTestBase is Test {
address owner = address ( this ) ;
originIcaRouter = deployProxiedIcaRouter (
environment . mailboxes ( origin ) ,
environment . igps ( destinatio n) ,
environment . igps ( origi n) ,
icaIsm ,
owner
) ;
destinationIcaRouter = deployProxiedIcaRouter (
environment . mailboxes ( destination ) ,
environment . igps ( destination ) ,
@ -392,6 +395,25 @@ contract InterchainAccountRouterTest is InterchainAccountRouterTestBase {
) ;
}
function test_quoteDispatch_differentHook ( ) public {
/ / arrange
TestPostDispatchHook testHook = new TestPostDispatchHook ( ) ;
originIcaRouter = deployProxiedIcaRouter (
environment . mailboxes ( origin ) ,
testHook ,
icaIsm ,
address ( this )
) ;
originIcaRouter . enrollRemoteRouterAndIsm (
destination ,
routerOverride ,
ismOverride
) ;
/ / assert
assertEq ( originIcaRouter . quoteGasPayment ( destination ) , 0 ) ;
}
function testFuzz_singleCallRemoteWithDefault (
bytes32 data ,
uint256 value
@ -444,6 +466,35 @@ contract InterchainAccountRouterTest is InterchainAccountRouterTestBase {
assertIgpPayment ( balanceBefore , balanceAfter , igp . getDefaultGasUsage ( ) ) ;
}
function testFuzz_callRemoteWithDefault_differentHook (
bytes32 data ,
uint256 value
) public {
/ / arrange
TestPostDispatchHook testHook = new TestPostDispatchHook ( ) ;
originIcaRouter = deployProxiedIcaRouter (
environment . mailboxes ( origin ) ,
testHook ,
icaIsm ,
address ( this )
) ;
originIcaRouter . enrollRemoteRouterAndIsm (
destination ,
routerOverride ,
ismOverride
) ;
/ / assert
vm . expectCall (
address ( testHook ) ,
0 ,
abi . encodePacked ( AbstractPostDispatchHook . postDispatch . selector )
) ;
/ / act
originIcaRouter . callRemote ( destination , getCalls ( data , value ) ) ;
}
function testFuzz_overrideAndCallRemote (
bytes32 data ,
uint256 value
@ -558,6 +609,7 @@ contract InterchainAccountRouterTest is InterchainAccountRouterTestBase {
uint256 balanceAfter = address ( this ) . balance ;
assertRemoteCallReceived ( data , value ) ;
assertIgpPayment ( balanceBefore , balanceAfter , igp . getDefaultGasUsage ( ) ) ;
assertEq ( address ( originIcaRouter . hook ( ) ) , address ( 0 ) ) ;
}
function testFuzz_callRemoteWithOverrides_metadata (
@ -591,6 +643,38 @@ contract InterchainAccountRouterTest is InterchainAccountRouterTestBase {
assertIgpPayment ( balanceBefore , balanceAfter , gasLimit ) ;
}
function testFuzz_callRemoteWithOverrides_withHook (
bytes32 data ,
uint256 value
) public {
TestPostDispatchHook testHook = new TestPostDispatchHook ( ) ;
originIcaRouter = deployProxiedIcaRouter (
environment . mailboxes ( origin ) ,
testHook ,
icaIsm ,
address ( this )
) ;
originIcaRouter . enrollRemoteRouterAndIsm (
destination ,
routerOverride ,
ismOverride
) ;
vm . expectCall (
address ( testHook ) ,
0 ,
abi . encodePacked ( AbstractPostDispatchHook . postDispatch . selector )
) ;
originIcaRouter . callRemoteWithOverrides (
destination ,
routerOverride ,
ismOverride ,
getCalls ( data , value ) ,
new bytes ( 0 )
) ;
}
function testFuzz_callRemoteWithFailingIsmOverride (
bytes32 data ,
uint256 value