cosmic-interchain-cli
Version:
A command-line utility for Cosmic Wire's interchain messaging protocol
71 lines • 4.27 kB
JavaScript
import { expect } from 'chai';
import { Wallet } from 'ethers';
import { TokenType, } from '@hyperlane-xyz/sdk';
import { readYamlOrJson, writeYamlOrJson } from '../utils/files.js';
import { ANVIL_KEY, REGISTRY_PATH, deployOrUseExistingCore, extendWarpConfig, getChainId, updateOwner, } from './commands/helpers.js';
import { hyperlaneWarpDeploy, readWarpConfig } from './commands/warp.js';
const CHAIN_NAME_2 = 'anvil2';
const CHAIN_NAME_3 = 'anvil3';
const BURN_ADDRESS = '0x0000000000000000000000000000000000000001';
const EXAMPLES_PATH = './examples';
const CORE_CONFIG_PATH = `${EXAMPLES_PATH}/core-config.yaml`;
const WARP_CONFIG_PATH_EXAMPLE = `${EXAMPLES_PATH}/warp-route-deployment.yaml`;
const TEMP_PATH = '/tmp'; // /temp gets removed at the end of all-test.sh
const WARP_CONFIG_PATH_2 = `${TEMP_PATH}/anvil2/warp-route-deployment-anvil2.yaml`;
const WARP_CORE_CONFIG_PATH_2 = `${REGISTRY_PATH}/deployments/warp_routes/ETH/anvil2-config.yaml`;
const TEST_TIMEOUT = 60000; // Long timeout since these tests can take a while
describe('WarpApply e2e tests', async function () {
let chain2Addresses = {};
this.timeout(TEST_TIMEOUT);
before(async function () {
await deployOrUseExistingCore(CHAIN_NAME_2, CORE_CONFIG_PATH, ANVIL_KEY);
chain2Addresses = await deployOrUseExistingCore(CHAIN_NAME_3, CORE_CONFIG_PATH, ANVIL_KEY);
// Create a new warp config using the example
const warpConfig = readYamlOrJson(WARP_CONFIG_PATH_EXAMPLE);
const anvil2Config = { anvil2: { ...warpConfig.anvil1 } };
writeYamlOrJson(WARP_CONFIG_PATH_2, anvil2Config);
});
beforeEach(async function () {
await hyperlaneWarpDeploy(WARP_CONFIG_PATH_2);
});
it('should burn owner address', async function () {
const warpConfigPath = `${TEMP_PATH}/warp-route-deployment-2.yaml`;
await updateOwner(BURN_ADDRESS, CHAIN_NAME_2, warpConfigPath, WARP_CORE_CONFIG_PATH_2);
const updatedWarpDeployConfig = await readWarpConfig(CHAIN_NAME_2, WARP_CORE_CONFIG_PATH_2, warpConfigPath);
expect(updatedWarpDeployConfig.anvil2.owner).to.equal(BURN_ADDRESS);
});
it('should not update the same owner', async () => {
const warpConfigPath = `${TEMP_PATH}/warp-route-deployment-2.yaml`;
await updateOwner(BURN_ADDRESS, CHAIN_NAME_2, warpConfigPath, WARP_CORE_CONFIG_PATH_2);
const { stdout } = await updateOwner(BURN_ADDRESS, CHAIN_NAME_2, warpConfigPath, WARP_CORE_CONFIG_PATH_2);
expect(stdout).to.include('Warp config on anvil2 is the same as target. No updates needed.');
});
it('should extend an existing warp route', async () => {
// Read existing config into a file
const warpConfigPath = `${TEMP_PATH}/warp-route-deployment-2.yaml`;
await readWarpConfig(CHAIN_NAME_2, WARP_CORE_CONFIG_PATH_2, warpConfigPath);
// Extend with new config
const config = {
decimals: 18,
mailbox: chain2Addresses.mailbox,
name: 'Ether',
owner: new Wallet(ANVIL_KEY).address,
symbol: 'ETH',
totalSupply: 0,
type: TokenType.native,
};
await extendWarpConfig(CHAIN_NAME_2, CHAIN_NAME_3, config, WARP_CORE_CONFIG_PATH_2, warpConfigPath);
const COMBINED_WARP_CORE_CONFIG_PATH = `${REGISTRY_PATH}/deployments/warp_routes/ETH/anvil2-anvil3-config.yaml`;
// Check that chain2 is enrolled in chain1
const updatedWarpDeployConfig1 = await readWarpConfig(CHAIN_NAME_2, COMBINED_WARP_CORE_CONFIG_PATH, warpConfigPath);
const chain2Id = await getChainId(CHAIN_NAME_3, ANVIL_KEY);
const remoteRouterKeys1 = Object.keys(updatedWarpDeployConfig1[CHAIN_NAME_2].remoteRouters);
expect(remoteRouterKeys1).to.include(chain2Id);
// Check that chain1 is enrolled in chain2
const updatedWarpDeployConfig2 = await readWarpConfig(CHAIN_NAME_3, COMBINED_WARP_CORE_CONFIG_PATH, warpConfigPath);
const chain1Id = await getChainId(CHAIN_NAME_2, ANVIL_KEY);
const remoteRouterKeys2 = Object.keys(updatedWarpDeployConfig2[CHAIN_NAME_3].remoteRouters);
expect(remoteRouterKeys2).to.include(chain1Id);
});
});
//# sourceMappingURL=warp-apply.e2e-test.js.map