chore: sync submodule state (parent ref update)
Made-with: Cursor
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Test, console} from "forge-std/Test.sol";
|
||||
import {Test} from "forge-std/Test.sol";
|
||||
import {BridgeEscrowVault} from "../../../contracts/bridge/interop/BridgeEscrowVault.sol";
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
contract MockERC20 is ERC20 {
|
||||
@@ -52,9 +51,9 @@ contract BridgeEscrowVaultTest is Test {
|
||||
bytes32 nonce = keccak256("test-nonce");
|
||||
bytes memory destinationData = abi.encodePacked(address(0x100));
|
||||
|
||||
vm.expectEmit(true, true, true, true);
|
||||
vm.expectEmit(false, true, true, true); // skip transferId (unknown until deposit)
|
||||
emit Deposit(
|
||||
bytes32(0), // Will be set by contract
|
||||
bytes32(0),
|
||||
user,
|
||||
address(0),
|
||||
1 ether,
|
||||
@@ -124,7 +123,11 @@ contract BridgeEscrowVaultTest is Test {
|
||||
// Fast forward time
|
||||
vm.warp(block.timestamp + 3601);
|
||||
|
||||
// Create refund request with HSM signature
|
||||
// Use a known test account for HSM signing (vm.sign requires private key, not address)
|
||||
uint256 hsmPk = 4;
|
||||
address signer = vm.addr(hsmPk);
|
||||
|
||||
// Create refund request with HSM signature (EIP-712)
|
||||
bytes32 structHash = keccak256(
|
||||
abi.encode(
|
||||
keccak256("RefundRequest(bytes32 transferId,uint256 deadline)"),
|
||||
@@ -144,7 +147,7 @@ contract BridgeEscrowVaultTest is Test {
|
||||
);
|
||||
|
||||
bytes32 hash = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
|
||||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(uint256(uint160(hsmSigner)), hash);
|
||||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(hsmPk, hash);
|
||||
bytes memory signature = abi.encodePacked(r, s, v);
|
||||
|
||||
vm.startPrank(refundOperator);
|
||||
@@ -154,7 +157,7 @@ contract BridgeEscrowVaultTest is Test {
|
||||
deadline: block.timestamp + 3600,
|
||||
hsmSignature: signature
|
||||
}),
|
||||
hsmSigner
|
||||
signer
|
||||
);
|
||||
|
||||
vault.executeRefund(transferId);
|
||||
|
||||
@@ -49,6 +49,8 @@ contract BridgeRegistryTest is Test {
|
||||
allowedDestinations[1] = 10; // Optimism
|
||||
|
||||
vm.startPrank(registrar);
|
||||
registry.registerDestination(137, "Polygon", 128, 3600, 10, address(0x200));
|
||||
registry.registerDestination(10, "Optimism", 1, 3600, 10, address(0x200));
|
||||
registry.registerToken(
|
||||
token,
|
||||
1 ether, // minAmount
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Test, console} from "forge-std/Test.sol";
|
||||
import {Test} from "forge-std/Test.sol";
|
||||
import {BridgeEscrowVault} from "../../../contracts/bridge/interop/BridgeEscrowVault.sol";
|
||||
import {BridgeRegistry} from "../../../contracts/bridge/interop/BridgeRegistry.sol";
|
||||
import {wXRP} from "../../../contracts/bridge/interop/wXRP.sol";
|
||||
@@ -19,11 +19,17 @@ contract BridgeIntegrationTest is Test {
|
||||
address public operator = address(0x2);
|
||||
address public user = address(0x5);
|
||||
address public hsmSigner = address(0x4);
|
||||
address public attestor1 = address(0x10);
|
||||
address public attestor2 = address(0x11);
|
||||
address public attestor3 = address(0x12);
|
||||
uint256 public attestor1Pk = 0x10;
|
||||
uint256 public attestor2Pk = 0x11;
|
||||
uint256 public attestor3Pk = 0x12;
|
||||
address public attestor1;
|
||||
address public attestor2;
|
||||
address public attestor3;
|
||||
|
||||
function setUp() public {
|
||||
attestor1 = vm.addr(attestor1Pk);
|
||||
attestor2 = vm.addr(attestor2Pk);
|
||||
attestor3 = vm.addr(attestor3Pk);
|
||||
vm.startPrank(admin);
|
||||
|
||||
// Deploy registry
|
||||
@@ -130,15 +136,17 @@ contract BridgeIntegrationTest is Test {
|
||||
bytes32 transferId = keccak256("test-attestation");
|
||||
bytes32 proofHash = keccak256("proof-data");
|
||||
|
||||
uint256 deadline = block.timestamp + 3600;
|
||||
|
||||
// Attestor 1 submits attestation
|
||||
vm.startPrank(attestor1);
|
||||
bytes memory sig1 = _signAttestation(attestor1, transferId, proofHash);
|
||||
bytes memory sig1 = _signAttestation(attestor1Pk, transferId, proofHash, 1, deadline);
|
||||
verifier.submitAttestation(
|
||||
BridgeVerifier.Attestation({
|
||||
transferId: transferId,
|
||||
proofHash: proofHash,
|
||||
nonce: 1,
|
||||
deadline: block.timestamp + 3600,
|
||||
deadline: deadline,
|
||||
signature: sig1
|
||||
})
|
||||
);
|
||||
@@ -146,13 +154,13 @@ contract BridgeIntegrationTest is Test {
|
||||
|
||||
// Attestor 2 submits attestation
|
||||
vm.startPrank(attestor2);
|
||||
bytes memory sig2 = _signAttestation(attestor2, transferId, proofHash);
|
||||
bytes memory sig2 = _signAttestation(attestor2Pk, transferId, proofHash, 2, deadline);
|
||||
verifier.submitAttestation(
|
||||
BridgeVerifier.Attestation({
|
||||
transferId: transferId,
|
||||
proofHash: proofHash,
|
||||
nonce: 2,
|
||||
deadline: block.timestamp + 3600,
|
||||
deadline: deadline,
|
||||
signature: sig2
|
||||
})
|
||||
);
|
||||
@@ -165,12 +173,23 @@ contract BridgeIntegrationTest is Test {
|
||||
}
|
||||
|
||||
function _signAttestation(
|
||||
address signer,
|
||||
uint256 signerPk,
|
||||
bytes32 transferId,
|
||||
bytes32 proofHash
|
||||
bytes32 proofHash,
|
||||
uint256 nonce,
|
||||
uint256 deadline
|
||||
) internal view returns (bytes memory) {
|
||||
bytes32 hash = keccak256(abi.encodePacked(transferId, proofHash, block.timestamp));
|
||||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(uint256(uint160(signer)), hash);
|
||||
bytes32 typeHash = keccak256("Attestation(bytes32 transferId,bytes32 proofHash,uint256 nonce,uint256 deadline)");
|
||||
bytes32 structHash = keccak256(abi.encode(typeHash, transferId, proofHash, nonce, deadline));
|
||||
bytes32 domainSeparator = keccak256(abi.encode(
|
||||
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
|
||||
keccak256(bytes("BridgeVerifier")),
|
||||
keccak256(bytes("1")),
|
||||
block.chainid,
|
||||
address(verifier)
|
||||
));
|
||||
bytes32 hash = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
|
||||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPk, hash);
|
||||
return abi.encodePacked(r, s, v);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user