hoodquidity/packages/contracts/lib/openzeppelin-contracts/test/utils/draft-InteroperableAddress.t.sol
Денис Зефиров dba2811447 Hoodquidity: liquidity campaigns for Robinhood Chain stock token markets
Full build: Vite/React acid-terminal frontend (BEARER design system,
Panchang/Sentient/Fragment Mono, neon layer, palette audit script),
HoodquidityVaults Foundry contracts (single+dual deposits via Chainlink-style
feeds, hybrid exit, 10% platform fee, boost, Genesis LP), Reown AppKit wallet
connect with Robinhood Chain testnet (46630), live data from Dexscreener and
onchain reads, partner portal, design-sync setup for claude.ai/design.

Deploy: static via Forgejo Actions platform, BUILD_DIR=apps/web/dist (.env).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 08:32:28 +04:00

99 lines
3.8 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Test} from "forge-std/Test.sol";
import {InteroperableAddress} from "../../contracts/utils/draft-InteroperableAddress.sol";
contract InteroperableAddressTest is Test {
using InteroperableAddress for bytes;
function testFormatParse(bytes2 chainType, bytes calldata chainReference, bytes calldata addr) public view {
vm.assume(chainReference.length > 0 || addr.length > 0);
{
(bytes2 chainType_, bytes memory chainReference_, bytes memory addr_) = InteroperableAddress
.formatV1(chainType, chainReference, addr)
.parseV1();
assertEq(chainType, chainType_);
assertEq(chainReference, chainReference_);
assertEq(addr, addr_);
}
{
(bool success, bytes2 chainType_, bytes memory chainReference_, bytes memory addr_) = InteroperableAddress
.formatV1(chainType, chainReference, addr)
.tryParseV1();
assertTrue(success);
assertEq(chainType, chainType_);
assertEq(chainReference, chainReference_);
assertEq(addr, addr_);
}
{
(bytes2 chainType_, bytes memory chainReference_, bytes memory addr_) = this.parseV1Calldata(
InteroperableAddress.formatV1(chainType, chainReference, addr)
);
assertEq(chainType, chainType_);
assertEq(chainReference, chainReference_);
assertEq(addr, addr_);
}
{
(bool success, bytes2 chainType_, bytes memory chainReference_, bytes memory addr_) = this
.tryParseV1Calldata(InteroperableAddress.formatV1(chainType, chainReference, addr));
assertTrue(success);
assertEq(chainType, chainType_);
assertEq(chainReference, chainReference_);
assertEq(addr, addr_);
}
}
function testFormatParseEVM(uint256 chainid, address addr) public view {
{
(uint256 chainid_, address addr_) = InteroperableAddress.formatEvmV1(chainid, addr).parseEvmV1();
assertEq(chainid, chainid_);
assertEq(addr, addr_);
}
{
(bool success, uint256 chainid_, address addr_) = InteroperableAddress
.formatEvmV1(chainid, addr)
.tryParseEvmV1();
assertTrue(success);
assertEq(chainid, chainid_);
assertEq(addr, addr_);
}
{
(uint256 chainid_, address addr_) = this.parseEvmV1Calldata(
InteroperableAddress.formatEvmV1(chainid, addr)
);
assertEq(chainid, chainid_);
assertEq(addr, addr_);
}
{
(bool success, uint256 chainid_, address addr_) = this.tryParseEvmV1Calldata(
InteroperableAddress.formatEvmV1(chainid, addr)
);
assertTrue(success);
assertEq(chainid, chainid_);
assertEq(addr, addr_);
}
}
function parseV1Calldata(
bytes calldata self
) external pure returns (bytes2 chainType, bytes calldata chainReference, bytes calldata addr) {
return self.parseV1Calldata();
}
function tryParseV1Calldata(
bytes calldata self
) external pure returns (bool success, bytes2 chainType, bytes calldata chainReference, bytes calldata addr) {
return self.tryParseV1Calldata();
}
function parseEvmV1Calldata(bytes calldata self) external pure returns (uint256 chainid, address addr) {
return self.parseEvmV1Calldata();
}
function tryParseEvmV1Calldata(
bytes calldata self
) external pure returns (bool success, uint256 chainid, address addr) {
return self.tryParseEvmV1Calldata();
}
}