Skip to content

Commit

Permalink
chore: check if router ceive ethers
Browse files Browse the repository at this point in the history
  • Loading branch information
wellitongervickas committed Nov 20, 2023
1 parent 6384584 commit dc63008
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions contracts/mocks/MockCCIPRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ contract MockCCIPRouter is IRouterClient {
uint64 /*destinationChainSelector*/,
Client.EVM2AnyMessage calldata /*message*/
) external payable returns (bytes32) {
/// @dev only for test purpose
payable(address(this)).transfer(msg.value);
return bytes32(0);
}

/// @dev only for test purpose
function balance() external view returns (uint256) {
return address(this).balance;
}

/// @dev only for test purpose
receive() external payable {}
}
11 changes: 9 additions & 2 deletions test/adapters/ccip/CCIPAdapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('CCIPAdapter', function () {
it('should send message to router', async function () {
const { mockBridgeAddress } = await loadFixture(deployMockBridgeFixture)

const { mockCCIPRouterAddress } = await loadFixture(
const { mockCCIPRouterAddress, mockCCIPRouter } = await loadFixture(
deployMockCCIPRouterFixture
)

Expand All @@ -234,13 +234,20 @@ describe('CCIPAdapter', function () {
0n // admin role
)

const expectedAmount = 200_000
await mockCCIPRouter.setFee(expectedAmount)

const payload = {
toChain: 80_001,
receiver: ethers.ZeroAddress,
data: '0x'
}

await expect(ccipAdapter.sendMessage(payload))
await expect(
ccipAdapter.sendMessage(payload, {
value: expectedAmount
})
)
.to.emit(ccipAdapter, 'MessageSent')
.withArgs(payload.toChain, payload.receiver, payload.data)
})
Expand Down

0 comments on commit dc63008

Please sign in to comment.