Skip to content

Commit 71ba229

Browse files
committed
Add test with chainlink CCIP simulator
1 parent b6ac90b commit 71ba229

File tree

58 files changed

+483
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+483
-368
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "lib/forge-std"]
88
path = lib/forge-std
99
url = https://github.com/foundry-rs/forge-std
10+
[submodule "lib/chainlink-local"]
11+
path = lib/chainlink-local
12+
url = https://github.com/smartcontractkit/chainlink-local

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
Please follow <https://changelog.md/> conventions.
44

5+
6+
7+
## 1.0.1 - 20240429
8+
9+
In the version 1.0.0, when fees are paid in native tokens, the function ccipSend from the CCIP router was called without the `value`argument.
10+
11+
Old version
12+
13+
**new version**
14+
15+
```solidity
16+
if(_paymentMethodId == 0){ // Native token
17+
messageId = router.ccipSend{value: fees}(_destinationChainSelector, message);
18+
} else{
19+
messageId = router.ccipSend(_destinationChainSelector, message);
20+
}
21+
```
22+
23+
24+
525
## 1.0.0 - 20240423
626

727
- 🎉 First release !

doc/test/coverage/bridge/CCIPBaseSender.sol.func-sort-c.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>
@@ -74,11 +74,11 @@
7474
</tr>
7575
<tr>
7676
<td class="coverFn"><a href="CCIPBaseSender.sol.gcov.html#113">CCIPBaseSender._buildEndSend</a></td>
77-
<td class="coverFnHi">12</td>
77+
<td class="coverFnHi">13</td>
7878
</tr>
7979
<tr>
8080
<td class="coverFn"><a href="CCIPBaseSender.sol.gcov.html#38">CCIPBaseSender.transferTokens</a></td>
81-
<td class="coverFnHi">12</td>
81+
<td class="coverFnHi">13</td>
8282
</tr>
8383
</table>
8484
<br>

doc/test/coverage/bridge/CCIPBaseSender.sol.func.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>
@@ -70,11 +70,11 @@
7070
</tr>
7171
<tr>
7272
<td class="coverFn"><a href="CCIPBaseSender.sol.gcov.html#113">CCIPBaseSender._buildEndSend</a></td>
73-
<td class="coverFnHi">12</td>
73+
<td class="coverFnHi">13</td>
7474
</tr>
7575
<tr>
7676
<td class="coverFn"><a href="CCIPBaseSender.sol.gcov.html#38">CCIPBaseSender.transferTokens</a></td>
77-
<td class="coverFnHi">12</td>
77+
<td class="coverFnHi">13</td>
7878
</tr>
7979
<tr>
8080
<td class="coverFn"><a href="CCIPBaseSender.sol.gcov.html#78">CCIPBaseSender.transferTokensBatch</a></td>

doc/test/coverage/bridge/CCIPBaseSender.sol.gcov.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>
@@ -120,18 +120,18 @@
120120
<a name="49"><span class="lineNum"> 49 </span> : : onlyAllowlistedDestinationChain(_destinationChainSelector)</a>
121121
<a name="50"><span class="lineNum"> 50 </span> : : returns (bytes32 messageId) </a>
122122
<a name="51"><span class="lineNum"> 51 </span> : : {</a>
123-
<a name="52"><span class="lineNum"> 52 </span> :<span class="lineCov"> 20 : Client.EVMTokenAmount[]</span></a>
124-
<a name="53"><span class="lineNum"> 53 </span> :<span class="lineCov"> 20 : memory tokenAmounts = new Client.EVMTokenAmount[](1);</span></a>
125-
<a name="54"><span class="lineNum"> 54 </span> :<span class="lineCov"> 30 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({</span></a>
123+
<a name="52"><span class="lineNum"> 52 </span> :<span class="lineCov"> 22 : Client.EVMTokenAmount[]</span></a>
124+
<a name="53"><span class="lineNum"> 53 </span> :<span class="lineCov"> 22 : memory tokenAmounts = new Client.EVMTokenAmount[](1);</span></a>
125+
<a name="54"><span class="lineNum"> 54 </span> :<span class="lineCov"> 33 : Client.EVMTokenAmount memory tokenAmount = Client.EVMTokenAmount({</span></a>
126126
<a name="55"><span class="lineNum"> 55 </span> : : token: _token,</a>
127127
<a name="56"><span class="lineNum"> 56 </span> : : amount: _amount</a>
128128
<a name="57"><span class="lineNum"> 57 </span> : : });</a>
129-
<a name="58"><span class="lineNum"> 58 </span> :<span class="lineCov"> 20 : tokenAmounts[0] = tokenAmount;</span></a>
130-
<a name="59"><span class="lineNum"> 59 </span> :<span class="lineCov"> 20 : uint256 fees;</span></a>
129+
<a name="58"><span class="lineNum"> 58 </span> :<span class="lineCov"> 22 : tokenAmounts[0] = tokenAmount;</span></a>
130+
<a name="59"><span class="lineNum"> 59 </span> :<span class="lineCov"> 22 : uint256 fees;</span></a>
131131
<a name="60"><span class="lineNum"> 60 </span> : : </a>
132-
<a name="61"><span class="lineNum"> 61 </span> :<span class="lineCov"> 20 : (fees, messageId) = _buildEndSend(_destinationChainSelector, _receiver, _paymentMethodId, tokenAmounts);</span></a>
132+
<a name="61"><span class="lineNum"> 61 </span> :<span class="lineCov"> 22 : (fees, messageId) = _buildEndSend(_destinationChainSelector, _receiver, _paymentMethodId, tokenAmounts);</span></a>
133133
<a name="62"><span class="lineNum"> 62 </span> : : </a>
134-
<a name="63"><span class="lineNum"> 63 </span> :<span class="lineCov"> 4 : emit TokenSingleTransferred(</span></a>
134+
<a name="63"><span class="lineNum"> 63 </span> :<span class="lineCov"> 6 : emit TokenSingleTransferred(</span></a>
135135
<a name="64"><span class="lineNum"> 64 </span> : : messageId,</a>
136136
<a name="65"><span class="lineNum"> 65 </span> : : _destinationChainSelector,</a>
137137
<a name="66"><span class="lineNum"> 66 </span> : : _receiver,</a>
@@ -185,20 +185,20 @@
185185
<a name="114"><span class="lineNum"> 114 </span> : : */</a>
186186
<a name="115"><span class="lineNum"> 115 </span> : : function _buildEndSend(uint64 _destinationChainSelector, address _receiver, uint256 _paymentMethodId, Client.EVMTokenAmount[] memory tokenAmounts) internal returns(uint256 fees, bytes32 messageId){</a>
187187
<a name="116"><span class="lineNum"> 116 </span> : : // Build the CCIP Message</a>
188-
<a name="117"><span class="lineNum"> 117 </span> :<span class="lineCov"> 36 : Client.EVM2AnyMessage memory message = CCIPSenderBuild._buildCCIPTransferMessage(_receiver, tokenAmounts, _paymentMethodId );</span></a>
188+
<a name="117"><span class="lineNum"> 117 </span> :<span class="lineCov"> 39 : Client.EVM2AnyMessage memory message = CCIPSenderBuild._buildCCIPTransferMessage(_receiver, tokenAmounts, _paymentMethodId );</span></a>
189189
<a name="118"><span class="lineNum"> 118 </span> : : // Initialize a router client instance to interact with cross-chain router</a>
190-
<a name="119"><span class="lineNum"> 119 </span> :<span class="lineCov"> 30 : IRouterClient router = IRouterClient(CCIPRouterManage.getRouter());</span></a>
190+
<a name="119"><span class="lineNum"> 119 </span> :<span class="lineCov"> 33 : IRouterClient router = IRouterClient(CCIPRouterManage.getRouter());</span></a>
191191
<a name="120"><span class="lineNum"> 120 </span> : : // CCIP Fees Management</a>
192-
<a name="121"><span class="lineNum"> 121 </span> :<span class="lineCov"> 20 : fees = CCIPSenderPayment._computeAndApproveFee(_destinationChainSelector, message, router, _paymentMethodId);</span></a>
193-
<a name="122"><span class="lineNum"> 122 </span> :<span class="lineCov"> 36 : for(uint256 i = 0; i &lt; tokenAmounts.length; ++i){</span></a>
192+
<a name="121"><span class="lineNum"> 121 </span> :<span class="lineCov"> 22 : fees = CCIPSenderPayment._computeAndApproveFee(_destinationChainSelector, message, router, _paymentMethodId);</span></a>
193+
<a name="122"><span class="lineNum"> 122 </span> :<span class="lineCov"> 41 : for(uint256 i = 0; i &lt; tokenAmounts.length; ++i){</span></a>
194194
<a name="123"><span class="lineNum"> 123 </span> : : // transfer tokens to the contract</a>
195-
<a name="124"><span class="lineNum"> 124 </span> :<span class="lineCov"> 20 : IERC20(tokenAmounts[i].token).safeTransferFrom(_msgSender(), address(this), tokenAmounts[i].amount);</span></a>
195+
<a name="124"><span class="lineNum"> 124 </span> :<span class="lineCov"> 22 : IERC20(tokenAmounts[i].token).safeTransferFrom(_msgSender(), address(this), tokenAmounts[i].amount);</span></a>
196196
<a name="125"><span class="lineNum"> 125 </span> : : // approve the Router to spend tokens on contract's behalf. It will spend the amount of the given token</a>
197-
<a name="126"><span class="lineNum"> 126 </span> :<span class="lineCov"> 12 : IERC20(tokenAmounts[i].token).safeIncreaseAllowance(address(router), tokenAmounts[i].amount);</span></a>
197+
<a name="126"><span class="lineNum"> 126 </span> :<span class="lineCov"> 14 : IERC20(tokenAmounts[i].token).safeIncreaseAllowance(address(router), tokenAmounts[i].amount);</span></a>
198198
<a name="127"><span class="lineNum"> 127 </span> : : }</a>
199199
<a name="128"><span class="lineNum"> 128 </span> : : // Send CCIP Message</a>
200-
<a name="129"><span class="lineNum"> 129 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov"> 8 : if(_paymentMethodId == 0){ // Native token</span></a>
201-
<a name="130"><span class="lineNum"> 130 </span> :<span class="lineCov"> 4 : messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); </span></a>
200+
<a name="129"><span class="lineNum"> 129 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov"> 10 : if(_paymentMethodId == 0){ // Native token</span></a>
201+
<a name="130"><span class="lineNum"> 130 </span> :<span class="lineCov"> 6 : messageId = router.ccipSend{value: fees}(_destinationChainSelector, message); </span></a>
202202
<a name="131"><span class="lineNum"> 131 </span> : : } else{</a>
203203
<a name="132"><span class="lineNum"> 132 </span> :<span class="lineCov"> 4 : messageId = router.ccipSend(_destinationChainSelector, message); </span></a>
204204
<a name="133"><span class="lineNum"> 133 </span> : : }</a>

doc/test/coverage/bridge/index-sort-b.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

doc/test/coverage/bridge/index-sort-f.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

doc/test/coverage/bridge/index-sort-l.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

doc/test/coverage/bridge/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func-sort-c.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">1</td>
@@ -70,7 +70,7 @@
7070
</tr>
7171
<tr>
7272
<td class="coverFn"><a href="CCIPAllowlistedChain.sol.gcov.html#36">CCIPAllowlistedChain.setAllowlistChain</a></td>
73-
<td class="coverFnHi">17</td>
73+
<td class="coverFnHi">18</td>
7474
</tr>
7575
</table>
7676
<br>

doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.func.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">1</td>
@@ -70,7 +70,7 @@
7070
</tr>
7171
<tr>
7272
<td class="coverFn"><a href="CCIPAllowlistedChain.sol.gcov.html#36">CCIPAllowlistedChain.setAllowlistChain</a></td>
73-
<td class="coverFnHi">17</td>
73+
<td class="coverFnHi">18</td>
7474
</tr>
7575
</table>
7676
<br>

doc/test/coverage/bridge/modules/configuration/CCIPAllowlistedChain.sol.gcov.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">1</td>
@@ -111,11 +111,11 @@
111111
<a name="40"><span class="lineNum"> 40 </span> : : bool allowedSourceChain,</a>
112112
<a name="41"><span class="lineNum"> 41 </span> : : bool allowedDestinationChain</a>
113113
<a name="42"><span class="lineNum"> 42 </span> : : ) external onlyRole(BRIDGE_ALLOWLISTED_CHAIN_MANAGER_ROLE) {</a>
114-
<a name="43"><span class="lineNum"> 43 </span> [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 15 times"> + </span>]:<span class="lineCov"> 30 : if(allowlistedSourceChains[_chainSelector] != allowedSourceChain){</span></a>
114+
<a name="43"><span class="lineNum"> 43 </span> [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 16 times"> + </span>]:<span class="lineCov"> 32 : if(allowlistedSourceChains[_chainSelector] != allowedSourceChain){</span></a>
115115
<a name="44"><span class="lineNum"> 44 </span> :<span class="lineCov"> 6 : allowlistedSourceChains[_chainSelector] = allowedSourceChain;</span></a>
116116
<a name="45"><span class="lineNum"> 45 </span> : : }</a>
117-
<a name="46"><span class="lineNum"> 46 </span> [<span class="branchCov" title="Branch 0 was taken 15 times"> + </span><span class="branchCov" title="Branch 1 was taken 15 times"> + </span>]:<span class="lineCov"> 30 : if( allowlistedDestinationChains[_chainSelector] != allowedDestinationChain){</span></a>
118-
<a name="47"><span class="lineNum"> 47 </span> :<span class="lineCov"> 30 : allowlistedDestinationChains[_chainSelector] = allowedDestinationChain;</span></a>
117+
<a name="46"><span class="lineNum"> 46 </span> [<span class="branchCov" title="Branch 0 was taken 16 times"> + </span><span class="branchCov" title="Branch 1 was taken 16 times"> + </span>]:<span class="lineCov"> 32 : if( allowlistedDestinationChains[_chainSelector] != allowedDestinationChain){</span></a>
118+
<a name="47"><span class="lineNum"> 47 </span> :<span class="lineCov"> 32 : allowlistedDestinationChains[_chainSelector] = allowedDestinationChain;</span></a>
119119
<a name="48"><span class="lineNum"> 48 </span> : : }</a>
120120
<a name="49"><span class="lineNum"> 49 </span> : : }</a>
121121
<a name="50"><span class="lineNum"> 50 </span> : : }</a>

doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func-sort-c.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

doc/test/coverage/bridge/modules/configuration/CCIPRouterManage.sol.func.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</tr>
3838
<tr>
3939
<td class="headerItem">Date:</td>
40-
<td class="headerValue">2024-04-26 14:53:42</td>
40+
<td class="headerValue">2024-04-30 10:51:06</td>
4141
<td></td>
4242
<td class="headerItem">Functions:</td>
4343
<td class="headerCovTableEntry">3</td>

0 commit comments

Comments
 (0)