22pragma solidity ^ 0.8.13 ;
33
44import {Test} from "forge-std/Test.sol " ;
5+ import {ExecutorMessages} from "../src/libraries/ExecutorMessages.sol " ;
6+ import {RelayInstructions} from "../src/libraries/RelayInstructions.sol " ;
57import {Executor} from "../src/Executor.sol " ;
8+ import {ExecutorQuoter} from "../src/ExecutorQuoter.sol " ;
69import {ExecutorQuoterRouter} from "../src/ExecutorQuoterRouter.sol " ;
710
811contract ExecutorQuoterRouterTest is Test {
912 Executor public executor;
13+ ExecutorQuoter public executorQuoter;
1014 ExecutorQuoterRouter public executorQuoterRouter;
15+ address public testQuoter;
16+ uint256 public testQuoterPk;
17+ ExecutorQuoter.Update[] public updates;
18+ ExecutorQuoter.Update[] public chainInfoUpdates;
1119
1220 uint16 constant OUR_CHAIN = 10002 ;
1321 bytes32 constant UPDATE_IMPLEMENTATION = 0x000000000000000000000000aaa039ee238299b23cb4f9cd40775589efa962fd ;
@@ -16,9 +24,45 @@ contract ExecutorQuoterRouterTest is Test {
1624 bytes32 constant BAD_SENDER_ADDRESS = 0x0000000000000000000000007FA9385bE102ac3EAc297483Dd6233D62b3e1490 ;
1725 uint64 constant EXPIRY = 1762880900 ;
1826
27+ uint16 constant DST_CHAIN = 10003 ;
28+ bytes32 constant DST_ADDR = bytes32 (0 );
29+
30+ function packUint64 (uint64 a , uint64 b , uint64 c , uint64 d ) public pure returns (bytes32 ) {
31+ return bytes32 ((uint256 (d) << 192 ) | (uint256 (c) << 128 ) | (uint256 (b) << 64 ) | uint256 (a));
32+ }
33+
1934 function setUp () public {
2035 executor = new Executor (OUR_CHAIN);
36+ (testQuoter, testQuoterPk) = makeAddrAndKey ("test " );
37+ executorQuoter = new ExecutorQuoter (testQuoter, testQuoter, 18 , bytes32 (uint256 (uint160 (testQuoter))));
2138 executorQuoterRouter = new ExecutorQuoterRouter (address (executor));
39+ vm.startPrank (testQuoter);
40+ executorQuoterRouter.updateQuoterContract (
41+ makeAndSignGovernance (
42+ OUR_CHAIN,
43+ testQuoter,
44+ bytes32 (uint256 (uint160 (address (executorQuoter)))),
45+ bytes32 (uint256 (uint160 (testQuoter))),
46+ testQuoterPk
47+ )
48+ );
49+ ExecutorQuoter.Update memory chainInfoUpdate;
50+ chainInfoUpdate.chainId = 10003 ;
51+ chainInfoUpdate.update = 0x0000000000000000000000000000000000000000000000000000000000121201 ;
52+ chainInfoUpdates.push (chainInfoUpdate);
53+ executorQuoter.chainInfoUpdate (chainInfoUpdates);
54+ ExecutorQuoter.OnChainQuoteBody memory quote1;
55+ quote1.baseFee = 27971 ;
56+ quote1.dstGasPrice = 100000000 ;
57+ quote1.srcPrice = 35751300000000 ;
58+ quote1.dstPrice = 35751300000000 ;
59+ ExecutorQuoter.Update memory update1;
60+ update1.chainId = 10003 ;
61+ update1.update = packUint64 (quote1.baseFee, quote1.dstGasPrice, quote1.srcPrice, quote1.dstPrice);
62+ updates.push (update1);
63+ // store first so the gas metric is on a non-zero slot
64+ executorQuoter.quoteUpdate (updates);
65+ vm.stopPrank ();
2266 }
2367
2468 function makeAndSignGovernance (
@@ -93,4 +137,26 @@ contract ExecutorQuoterRouterTest is Test {
93137 makeAndSignGovernance (OUR_CHAIN, alice, UPDATE_IMPLEMENTATION, SENDER_ADDRESS, bobPk)
94138 );
95139 }
140+
141+ function test_quoteExecution () public view {
142+ executorQuoterRouter.quoteExecution (
143+ DST_CHAIN,
144+ DST_ADDR,
145+ testQuoter,
146+ testQuoter,
147+ ExecutorMessages.makeVAAv1Request (OUR_CHAIN, bytes32 (uint256 (uint160 (address (this )))), 1 ),
148+ RelayInstructions.encodeGas (250000 , 0 )
149+ );
150+ }
151+
152+ function test_requestExecution () public payable {
153+ executorQuoterRouter.requestExecution {value: 27797100000000 }(
154+ DST_CHAIN,
155+ DST_ADDR,
156+ testQuoter,
157+ testQuoter,
158+ ExecutorMessages.makeVAAv1Request (OUR_CHAIN, bytes32 (uint256 (uint160 (address (this )))), 1 ),
159+ RelayInstructions.encodeGas (250000 , 0 )
160+ );
161+ }
96162}
0 commit comments