Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrations tests #408

Merged
merged 8 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deployments/mainnet/arbitrum-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"guardian": "0x09ab10a9c3E6Eac1d18270a2322B6113F4C7f5E8",
"adapter": "0x85bAFcAdeA202258e3512FFBC3E2c9eE6Ad56365"
},
"integrations": {},
"deploymentBlock": 161607032,
"isTestnet": false,
"isDeterministicallyDeployed": true
}
}
6 changes: 5 additions & 1 deletion deployments/mainnet/base-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
"guardian": "0x427A1ce127b1775e4Cbd4F58ad468B9F832eA7e9",
"adapter": "0x30e34260b895CAE34A1cfB185271628c53311cF3"
},
"integrations": {
"cfg": "0x2b51E2Ec9551F9B87B321f63b805871f1c81ba97",
"verUSDC": "0x59aaF835D34b1E3dF2170e4872B785f11E2a964b"
},
"deploymentBlock": 17854405,
"isTestnet": false,
"isDeterministicallyDeployed": true
}
}
3 changes: 2 additions & 1 deletion deployments/mainnet/celo-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"guardian": "0x32043A41F4be198C4f6590312F7A7b91624Cab57",
"adapter": "0xE4e34083a49Df72E634121f32583c9eA59191cCA"
},
"integrations": {},
"deploymentBlock": 26965681,
"isTestnet": false,
"isDeterministicallyDeployed": false
}
}
5 changes: 4 additions & 1 deletion deployments/mainnet/ethereum-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"guardian": "0x09ab10a9c3E6Eac1d18270a2322B6113F4C7f5E8",
"adapter": "0x85bAFcAdeA202258e3512FFBC3E2c9eE6Ad56365"
},
"integrations": {
"cfg": "0xc221b7E65FfC80DE234bbB6667aBDd46593D34F0"
},
"deploymentBlock": 20432396,
"isTestnet": false,
"isDeterministicallyDeployed": true
}
}
99 changes: 73 additions & 26 deletions test/fork/Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {TrancheFactory} from "src/factories/TrancheFactory.sol";
import {ERC7540VaultFactory} from "src/factories/ERC7540VaultFactory.sol";
import {TransferProxyFactory} from "src/factories/TransferProxyFactory.sol";
import {Guardian} from "src/admin/Guardian.sol";
import {IAuth} from "src/interfaces/IAuth.sol";
import {IERC20Metadata} from "src/interfaces/IERC20.sol";
import "forge-std/Test.sol";
import "forge-std/StdJson.sol";

Expand All @@ -29,6 +31,10 @@ interface IAxelarContract {
function contractId() external view returns (bytes32);
}

interface IWrappedUSDC {
function memberlist() external view returns (address);
}

struct Deployment {
address root;
address guardian;
Expand Down Expand Up @@ -354,7 +360,7 @@ contract ForkTest is Test {
bool isTestnet = abi.decode(deployments[i].parseRaw(".isTestnet"), (bool));
if (!isTestnet) {
// Read deployment file
address adminSafe = _get(i, ".config.admin");
address adminSafe = _getAddress(i, ".config.admin");
address[] memory adminSigners =
abi.decode(deployments[i].parseRaw(".config.adminSigners"), (address[]));
_loadFork(i);
Expand Down Expand Up @@ -383,12 +389,12 @@ contract ForkTest is Test {
if (!isDeterministicallyDeployed) continue;

// Read deployment file
address root = _get(i, ".contracts.root");
address escrow = _get(i, ".contracts.escrow");
address routerEscrow = _get(i, ".contracts.routerEscrow");
address restrictionManager = _get(i, ".contracts.restrictionManager");
address trancheFactory = _get(i, ".contracts.trancheFactory");
address transferProxyFactory = _get(i, ".contracts.transferProxyFactory");
address root = _getAddress(i, ".contracts.root");
address escrow = _getAddress(i, ".contracts.escrow");
address routerEscrow = _getAddress(i, ".contracts.routerEscrow");
address restrictionManager = _getAddress(i, ".contracts.restrictionManager");
address trancheFactory = _getAddress(i, ".contracts.trancheFactory");
address transferProxyFactory = _getAddress(i, ".contracts.transferProxyFactory");
_loadFork(i);

bool isTestnet = abi.decode(deployments[i].parseRaw(".isTestnet"), (bool));
Expand Down Expand Up @@ -433,31 +439,72 @@ contract ForkTest is Test {
vm.selectFork(forkId);
}

function _get(uint256 id, string memory key) internal view returns (address) {
function _getAddress(uint256 id, string memory key) public view returns (address) {
try this._tryGetAddress(id, key) returns (address addr) {
return addr;
} catch {
return address(0);
}
}

function _tryGetAddress(uint256 id, string memory key) external view returns (address) {
return abi.decode(deployments[id].parseRaw(key), (address));
}

function _getUint256(uint256 id, string memory key) internal view returns (uint256) {
return abi.decode(deployments[id].parseRaw(key), (uint256));
}

function _parse(uint256 id) internal view returns (Deployment memory) {
return Deployment(
_get(id, ".contracts.root"),
_get(id, ".contracts.guardian"),
_get(id, ".contracts.restrictionManager"),
_get(id, ".contracts.investmentManager"),
_get(id, ".contracts.poolManager"),
_get(id, ".contracts.centrifugeRouter"),
payable(_get(id, ".contracts.gateway")),
_get(id, ".contracts.gasService"),
_get(id, ".contracts.escrow"),
_get(id, ".contracts.routerEscrow"),
_get(id, ".contracts.adapter"),
_get(id, ".contracts.trancheFactory"),
_get(id, ".contracts.erc7540VaultFactory"),
_get(id, ".contracts.transferProxyFactory"),
_get(id, ".config.deployer"),
_get(id, ".config.admin"),
_get(id, ".config.adapter.axelarGateway"),
_get(id, ".config.adapter.axelarGasService"),
_getAddress(id, ".contracts.root"),
_getAddress(id, ".contracts.guardian"),
_getAddress(id, ".contracts.restrictionManager"),
_getAddress(id, ".contracts.investmentManager"),
_getAddress(id, ".contracts.poolManager"),
_getAddress(id, ".contracts.centrifugeRouter"),
payable(_getAddress(id, ".contracts.gateway")),
_getAddress(id, ".contracts.gasService"),
_getAddress(id, ".contracts.escrow"),
_getAddress(id, ".contracts.routerEscrow"),
_getAddress(id, ".contracts.adapter"),
_getAddress(id, ".contracts.trancheFactory"),
_getAddress(id, ".contracts.erc7540VaultFactory"),
_getAddress(id, ".contracts.transferProxyFactory"),
_getAddress(id, ".config.deployer"),
_getAddress(id, ".config.admin"),
_getAddress(id, ".config.adapter.axelarGateway"),
_getAddress(id, ".config.adapter.axelarGasService"),
abi.decode(deployments[id].parseRaw(".isTestnet"), (bool))
);
}

function testIntegrations() public {
if (vm.envOr("FORK_TESTS", false)) {
for (uint256 i = 0; i < deployments.length; i++) {
uint256 chainId = _getUint256(i, ".chainId");
address cfg = _getAddress(i, ".integrations.cfg");
address verUSDC = _getAddress(i, ".integrations.verUSDC");
address root = _getAddress(i, ".contracts.root");
address admin = _getAddress(i, ".config.admin");
_loadFork(i);

if (verUSDC != address(0)) {
assertEq(IAuth(verUSDC).wards(root), 1);
assertEq(IAuth(IWrappedUSDC(verUSDC).memberlist()).wards(admin), 1);
}
if (cfg != address(0)) {
assertEq(IAuth(cfg).wards(root), 1);
assertEq(IERC20Metadata(cfg).decimals(), 18);
if (chainId == 1) {
assertEq(IERC20Metadata(cfg).name(), "Wrapped Centrifuge");
assertEq(IERC20Metadata(cfg).symbol(), "wCFG");
} else {
assertEq(IERC20Metadata(cfg).name(), "Centrifuge");
assertEq(IERC20Metadata(cfg).symbol(), "CFG");
}
}
}
}
}
}
Loading