feat: bridges, PMM, flash workflow, token-aggregation, and deployment docs
- CCIP/trustless bridge contracts, GRU tokens, DEX/PMM tests, reserve vault. - Token-aggregation service routes, planner, chain config, relay env templates. - Config snapshots and multi-chain deployment markdown updates. - gitignore services/btc-intake/dist/ (tsc output); do not track dist. Run forge build && forge test before deploy (large solc graph). Made-with: Cursor
This commit is contained in:
58
test/flash/CrossChainFlashVaultCreditReceiver.t.sol
Normal file
58
test/flash/CrossChainFlashVaultCreditReceiver.t.sol
Normal file
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Test} from "forge-std/Test.sol";
|
||||
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import {CrossChainFlashVaultCreditReceiver} from "../../contracts/flash/CrossChainFlashVaultCreditReceiver.sol";
|
||||
import {IRouterClient} from "../../contracts/ccip/IRouterClient.sol";
|
||||
|
||||
contract CreditMockToken is ERC20 {
|
||||
constructor() ERC20("Y", "Y") {}
|
||||
|
||||
function mint(address to, uint256 v) external {
|
||||
_mint(to, v);
|
||||
}
|
||||
}
|
||||
|
||||
contract CrossChainFlashVaultCreditReceiverTest is Test {
|
||||
CrossChainFlashVaultCreditReceiver internal recv;
|
||||
CreditMockToken internal token;
|
||||
address internal router;
|
||||
|
||||
function setUp() public {
|
||||
router = makeAddr("ccipRouterCredit");
|
||||
recv = new CrossChainFlashVaultCreditReceiver(router);
|
||||
token = new CreditMockToken();
|
||||
}
|
||||
|
||||
function _msg(address vault, uint256 amt, address tok) internal pure returns (IRouterClient.Any2EVMMessage memory m) {
|
||||
IRouterClient.TokenAmount[] memory amounts = new IRouterClient.TokenAmount[](1);
|
||||
amounts[0] = IRouterClient.TokenAmount({token: tok, amount: amt, amountType: IRouterClient.TokenAmountType.Fiat});
|
||||
m = IRouterClient.Any2EVMMessage({
|
||||
messageId: keccak256("credit-mid"),
|
||||
sourceChainSelector: 50,
|
||||
sender: abi.encode(address(0x222)),
|
||||
data: abi.encode(vault),
|
||||
tokenAmounts: amounts
|
||||
});
|
||||
}
|
||||
|
||||
function test_ccipReceive_creditsVault() public {
|
||||
address vaultAddr = address(0xF1A5);
|
||||
uint256 amt = 333e18;
|
||||
token.mint(address(recv), amt);
|
||||
|
||||
IRouterClient.Any2EVMMessage memory message = _msg(vaultAddr, amt, address(token));
|
||||
|
||||
vm.prank(router);
|
||||
recv.ccipReceive(message);
|
||||
|
||||
assertEq(token.balanceOf(vaultAddr), amt);
|
||||
}
|
||||
|
||||
function test_ccipReceive_revert_notRouter() public {
|
||||
IRouterClient.Any2EVMMessage memory message = _msg(address(0x1), 1, address(token));
|
||||
vm.expectRevert(CrossChainFlashVaultCreditReceiver.OnlyRouter.selector);
|
||||
recv.ccipReceive(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user