@@ -62,6 +62,8 @@ import {
62
62
import {WETH9} from "canonical-weth/WETH9.sol " ;
63
63
import {UD60x18, ud60x18, convert} from "prb/math/src/UD60x18.sol " ;
64
64
65
+ import {HelloWorld} from "./mocks/HelloWorld.sol " ;
66
+
65
67
contract GatewayV2Test is Test {
66
68
// Emitted when token minted/burnt/transfered
67
69
event Transfer (address indexed from , address indexed to , uint256 value );
@@ -86,6 +88,10 @@ contract GatewayV2Test is Test {
86
88
// tokenID for DOT
87
89
bytes32 public dotTokenID;
88
90
91
+ HelloWorld public helloWorld;
92
+
93
+ event SaidHello (string indexed message );
94
+
89
95
function setUp () public {
90
96
token = new WETH9 ();
91
97
AgentExecutor executor = new AgentExecutor ();
@@ -132,6 +138,8 @@ contract GatewayV2Test is Test {
132
138
token.deposit {value: 500 }();
133
139
134
140
dotTokenID = bytes32 (uint256 (1 ));
141
+
142
+ helloWorld = new HelloWorld ();
135
143
}
136
144
137
145
function recipientAddress32 () internal pure returns (MultiAddress memory ) {
@@ -172,6 +180,21 @@ contract GatewayV2Test is Test {
172
180
return commands;
173
181
}
174
182
183
+ function makeCallContractCommand (uint256 value ) public view returns (CommandV2[] memory ) {
184
+ bytes memory data = abi.encodeWithSignature ("sayHello(string) " , "World " );
185
+ CallContractParams memory params = CallContractParams ({
186
+ target: address (helloWorld),
187
+ data: data,
188
+ value: value
189
+ });
190
+ bytes memory payload = abi.encode (params);
191
+
192
+ CommandV2[] memory commands = new CommandV2 [](1 );
193
+ commands[0 ] =
194
+ CommandV2 ({kind: CommandKind.CallContract, gas: 500_000 , payload: payload});
195
+ return commands;
196
+ }
197
+
175
198
/**
176
199
* Message Verification
177
200
*/
@@ -289,4 +312,22 @@ contract GatewayV2Test is Test {
289
312
message, proof, makeMockProof (), relayerRewardAddress
290
313
);
291
314
}
315
+
316
+ function testAgentCallContractSuccess () public {
317
+ vm.expectEmit (true , false , false , true );
318
+ emit IGatewayV2.InboundMessageDispatched (1 , true , relayerRewardAddress);
319
+
320
+ vm.deal (assetHubAgent, 1 ether);
321
+ hoax (relayer, 1 ether);
322
+ IGatewayV2 (address (gateway)).v2_submit (
323
+ InboundMessageV2 ({
324
+ origin: Constants.ASSET_HUB_AGENT_ID,
325
+ nonce: 1 ,
326
+ commands: makeCallContractCommand (0.1 ether)
327
+ }),
328
+ proof,
329
+ makeMockProof (),
330
+ relayerRewardAddress
331
+ );
332
+ }
292
333
}
0 commit comments