From b206cda25c3c986b0fb9b1713d9449ae7a71c496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= <95722332+sirarthurmoney@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:48:54 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9B=F0=9F=91=B7=E2=80=8D=E2=99=82?= =?UTF-8?q?=EF=B8=8F:=20Adding=20checkWire=20task=20(#151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ján Jakub Naništa --- .changeset/healthy-beans-sneeze.md | 7 + .github/ISSUE_TEMPLATE/bug_report.md | 17 +- .../src/constants/tasks.ts | 1 + .../src/tasks/oapp/checkWire.ts | 57 ++++++ .../src/tasks/oapp/index.ts | 1 + .../src/tasks/oapp/wire.ts | 35 +--- .../src/utils/taskHelpers.ts | 44 +++- packages/ua-devtools/src/oapp/check.ts | 13 ++ packages/ua-devtools/src/oapp/config.ts | 2 +- packages/ua-devtools/src/oapp/index.ts | 1 + packages/ua-devtools/src/oapp/types.ts | 6 + .../test/oapp/check.test.ts | 189 ++++++++++++++++++ .../test/oapp/config.test.ts | 3 +- .../test/task/oapp/checkWire.test.ts | 41 ++++ 14 files changed, 372 insertions(+), 45 deletions(-) create mode 100644 .changeset/healthy-beans-sneeze.md create mode 100644 packages/ua-devtools-evm-hardhat/src/tasks/oapp/checkWire.ts create mode 100644 packages/ua-devtools/src/oapp/check.ts create mode 100644 tests/ua-devtools-evm-hardhat-test/test/oapp/check.test.ts create mode 100644 tests/ua-devtools-evm-hardhat-test/test/task/oapp/checkWire.test.ts diff --git a/.changeset/healthy-beans-sneeze.md b/.changeset/healthy-beans-sneeze.md new file mode 100644 index 000000000..8ec8b0db5 --- /dev/null +++ b/.changeset/healthy-beans-sneeze.md @@ -0,0 +1,7 @@ +--- +"@layerzerolabs/ua-devtools-evm-hardhat-test": patch +"@layerzerolabs/ua-devtools-evm-hardhat": patch +"@layerzerolabs/ua-devtools": patch +--- + +Adding checkWire task diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5e01f82b9..6bba9620d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: 'bug: [bug summary]' +title: "bug: [bug summary]" labels: bug -assignees: '' - +assignees: "" --- **Describe the bug** @@ -12,8 +11,9 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Run '...' -4. See error +2. See error **Expected behavior** A clear and concise description of what you expected to happen. @@ -22,10 +22,11 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Environment (please complete the following information):** - - OS: [e.g. macOS] - - OS Version [e.g. 22] - - VM: [e.g. node, deno] - - VM Version: [e.g. 18.16.0] + +- OS: [e.g. macOS] +- OS Version [e.g. 22] +- VM: [e.g. node, deno] +- VM Version: [e.g. 18.16.0] **Additional context** Add any other context about the problem here. diff --git a/packages/ua-devtools-evm-hardhat/src/constants/tasks.ts b/packages/ua-devtools-evm-hardhat/src/constants/tasks.ts index b42de0672..6e6924bcd 100644 --- a/packages/ua-devtools-evm-hardhat/src/constants/tasks.ts +++ b/packages/ua-devtools-evm-hardhat/src/constants/tasks.ts @@ -1,3 +1,4 @@ export const TASK_LZ_WIRE_OAPP = 'lz:oapp:wire' export const TASK_LZ_GET_DEFAULT_CONFIG = 'lz:oapp:getDefaultConfig' export const TASK_LZ_GET_OAPP_CONFIG = 'lz:oapp:getOAppConfig' +export const TASK_LZ_CHECK_WIRE_OAPP = 'lz:oapp:checkWire' diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/checkWire.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/checkWire.ts new file mode 100644 index 000000000..49fdb1e9e --- /dev/null +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/checkWire.ts @@ -0,0 +1,57 @@ +import { ActionType } from 'hardhat/types' +import { task, types } from 'hardhat/config' +import { createLogger, setDefaultLogLevel } from '@layerzerolabs/io-devtools' +import { printRecords } from '@layerzerolabs/io-devtools/swag' +import { TASK_LZ_CHECK_WIRE_OAPP } from '@/constants/tasks' +import { printLogo } from '@layerzerolabs/io-devtools/swag' +import { OAppOmniGraph } from '@layerzerolabs/ua-devtools' +import { createConnectedContractFactory } from '@layerzerolabs/devtools-evm-hardhat' +import { createOAppFactory } from '@layerzerolabs/ua-devtools-evm' +import { checkOAppPeers } from '@layerzerolabs/ua-devtools' +import { validateAndTransformOappConfig } from '@/utils/taskHelpers' +import { getNetworkNameForEid } from '@layerzerolabs/devtools-evm-hardhat' +import { printBoolean } from '@layerzerolabs/io-devtools' + +interface TaskArgs { + oappConfig: string + logLevel?: string +} + +export const checkWire: ActionType = async ({ oappConfig: oappConfigPath, logLevel = 'info' }) => { + printLogo() + + // We'll set the global logging level to get as much info as needed + setDefaultLogLevel(logLevel) + + // And we'll create a logger for ourselves + const logger = createLogger() + const graph: OAppOmniGraph = await validateAndTransformOappConfig(oappConfigPath, logger) + + // At this point we are ready read data from the OApp + logger.verbose(`Reading peers from OApps`) + const contractFactory = createConnectedContractFactory() + const oAppFactory = createOAppFactory(contractFactory) + + try { + const peers = await checkOAppPeers(graph, oAppFactory) + + const formattedPeers = peers.map((peer) => ({ + 'From network': getNetworkNameForEid(peer.vector.from.eid), + 'To network': getNetworkNameForEid(peer.vector.to.eid), + Connected: printBoolean(peer.hasPeer), + })) + + printRecords(formattedPeers) + + return peers + } catch (error) { + throw new Error(`An error occurred while getting the OApp configuration: ${error}`) + } +} + +task( + TASK_LZ_CHECK_WIRE_OAPP, + 'outputs visual console table to show current state of oapp connections via configuration' +) + .addParam('oappConfig', 'Path to your LayerZero OApp config', './layerzero.config.js', types.string) + .setAction(checkWire) diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts index d3758fdad..d6e3694a4 100644 --- a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts @@ -1,3 +1,4 @@ import './wire' +import './checkWire' import './getDefaultConfig' import './getOAppConfig' diff --git a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/wire.ts b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/wire.ts index 895ac1a28..99657980c 100644 --- a/packages/ua-devtools-evm-hardhat/src/tasks/oapp/wire.ts +++ b/packages/ua-devtools-evm-hardhat/src/tasks/oapp/wire.ts @@ -3,25 +3,22 @@ import type { ActionType } from 'hardhat/types' import { TASK_LZ_WIRE_OAPP } from '@/constants/tasks' import { createLogger, - createConfigLoader, setDefaultLogLevel, promptToContinue, printJson, pluralizeNoun, printBoolean, } from '@layerzerolabs/io-devtools' -import { OAppOmniGraphHardhat, OAppOmniGraphHardhatSchema } from '@/oapp' import { OAppOmniGraph, configureOApp } from '@layerzerolabs/ua-devtools' import { createOAppFactory } from '@layerzerolabs/ua-devtools-evm' import { - OmniGraphBuilderHardhat, createConnectedContractFactory, createSignerFactory, formatOmniTransaction, } from '@layerzerolabs/devtools-evm-hardhat' import { createSignAndSend, OmniTransaction } from '@layerzerolabs/devtools' -import { resolve } from 'path' import { createProgressBar, printLogo, printRecords, render } from '@layerzerolabs/io-devtools/swag' +import { validateAndTransformOappConfig } from '@/utils/taskHelpers' interface TaskArgs { oappConfig: string @@ -40,35 +37,7 @@ const action: ActionType = async ({ oappConfig: oappConfigPath, logLev // And we'll create a logger for ourselves const logger = createLogger() - - // Now we create our config loader - const configLoader = createConfigLoader(OAppOmniGraphHardhatSchema) - - // At this point we have a correctly typed config in the hardhat format - const hardhatGraph: OAppOmniGraphHardhat = await configLoader(resolve(oappConfigPath)) - - // We'll also print out the whole config for verbose loggers - logger.verbose(`Config file '${oappConfigPath}' has correct structure`) - logger.debug(`The hardhat config is:\n\n${printJson(hardhatGraph)}`) - - // What we need to do now is transform the config from hardhat format to the generic format - // with addresses instead of contractNames - logger.verbose(`Transforming '${oappConfigPath}' from hardhat-specific format to generic format`) - let graph: OAppOmniGraph - try { - // The transformation is achieved using a builder that also validates the resulting graph - // (i.e. makes sure that all the contracts exist and connections are valid) - const builder = await OmniGraphBuilderHardhat.fromConfig(hardhatGraph) - - // We only need the graph so we throw away the builder - graph = builder.graph - } catch (error) { - throw new Error(`Config from file '${oappConfigPath}' is invalid: ${error}`) - } - - // Show more detailed logs to interested users - logger.verbose(`Transformed '${oappConfigPath}' from hardhat-specific format to generic format`) - logger.debug(`The resulting config is:\n\n${printJson(graph)}`) + const graph: OAppOmniGraph = await validateAndTransformOappConfig(oappConfigPath, logger) // At this point we are ready to create the list of transactions logger.verbose(`Creating a list of wiring transactions`) diff --git a/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts b/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts index cb1f9ae9b..29576d403 100644 --- a/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts +++ b/packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts @@ -1,7 +1,16 @@ import { Address } from '@layerzerolabs/devtools' import { Timeout, Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-devtools' -import { createConnectedContractFactory, getEidForNetworkName } from '@layerzerolabs/devtools-evm-hardhat' +import { + createConnectedContractFactory, + getEidForNetworkName, + OmniGraphBuilderHardhat, +} from '@layerzerolabs/devtools-evm-hardhat' +import { createConfigLoader, printJson } from '@layerzerolabs/io-devtools' import { createEndpointFactory } from '@layerzerolabs/protocol-devtools-evm' +import { OAppOmniGraphHardhat, OAppOmniGraphHardhatSchema } from '@/oapp' +import { resolve } from 'path' +import { OAppOmniGraph } from '@layerzerolabs/ua-devtools' +import { Logger } from '@layerzerolabs/io-devtools' export async function getSendConfig( localNetworkName: string, @@ -62,3 +71,36 @@ export async function getReceiveConfig( const receiveUlnConfig = await localReceiveUlnSDK.getUlnConfig(remoteEid) return [receiveLibrary, receiveUlnConfig, receiveLibraryTimeout] } + +export async function validateAndTransformOappConfig(oappConfigPath: string, logger: Logger): Promise { + // Now we create our config loader + const configLoader = createConfigLoader(OAppOmniGraphHardhatSchema) + + // At this point we have a correctly typed config in the hardhat format + const hardhatGraph: OAppOmniGraphHardhat = await configLoader(resolve(oappConfigPath)) + + // We'll also print out the whole config for verbose loggers + logger.verbose(`Config file '${oappConfigPath}' has correct structure`) + logger.debug(`The hardhat config is:\n\n${printJson(hardhatGraph)}`) + + // What we need to do now is transform the config from hardhat format to the generic format + // with addresses instead of contractNames + logger.verbose(`Transforming '${oappConfigPath}' from hardhat-specific format to generic format`) + let graph: OAppOmniGraph + try { + // The transformation is achieved using a builder that also validates the resulting graph + // (i.e. makes sure that all the contracts exist and connections are valid) + const builder = await OmniGraphBuilderHardhat.fromConfig(hardhatGraph) + + // We only need the graph so we throw away the builder + graph = builder.graph + } catch (error) { + throw new Error(`Config from file '${oappConfigPath}' is invalid: ${error}`) + } + + // Show more detailed logs to interested users + logger.verbose(`Transformed '${oappConfigPath}' from hardhat-specific format to generic format`) + logger.debug(`The resulting config is:\n\n${printJson(graph)}`) + + return graph +} diff --git a/packages/ua-devtools/src/oapp/check.ts b/packages/ua-devtools/src/oapp/check.ts new file mode 100644 index 000000000..c22304d92 --- /dev/null +++ b/packages/ua-devtools/src/oapp/check.ts @@ -0,0 +1,13 @@ +import { OAppFactory, OAppOmniGraph, OAppPeers } from '@/oapp/types' + +export type OAppRead = (graph: OAppOmniGraph, createSdk: OAppFactory) => Promise + +export const checkOAppPeers: OAppRead = async (graph, createSdk): Promise => { + return await Promise.all( + graph.connections.map(async ({ vector }): Promise => { + const sdk = await createSdk(vector.from) + const hasPeer = await sdk.hasPeer(vector.to.eid, vector.to.address) + return { vector: vector, hasPeer } + }) + ) +} diff --git a/packages/ua-devtools/src/oapp/config.ts b/packages/ua-devtools/src/oapp/config.ts index 983ec2f4c..51517d7c1 100644 --- a/packages/ua-devtools/src/oapp/config.ts +++ b/packages/ua-devtools/src/oapp/config.ts @@ -1,5 +1,5 @@ import { flattenTransactions, type OmniTransaction } from '@layerzerolabs/devtools' -import type { OAppFactory, OAppOmniGraph } from './types' +import { OAppFactory, OAppOmniGraph } from './types' import { createModuleLogger, printBoolean } from '@layerzerolabs/io-devtools' import { formatOmniVector, isDeepEqual } from '@layerzerolabs/devtools' import { Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-devtools' diff --git a/packages/ua-devtools/src/oapp/index.ts b/packages/ua-devtools/src/oapp/index.ts index 1273e8646..038ec9e82 100644 --- a/packages/ua-devtools/src/oapp/index.ts +++ b/packages/ua-devtools/src/oapp/index.ts @@ -1,3 +1,4 @@ +export * from './check' export * from './config' export * from './schema' export * from './types' diff --git a/packages/ua-devtools/src/oapp/types.ts b/packages/ua-devtools/src/oapp/types.ts index 25a2874fd..837914cd7 100644 --- a/packages/ua-devtools/src/oapp/types.ts +++ b/packages/ua-devtools/src/oapp/types.ts @@ -8,6 +8,7 @@ import type { OmniGraph, OmniPoint, OmniTransaction, + OmniVector, } from '@layerzerolabs/devtools' import type { Uln302ExecutorConfig, Uln302UlnConfig } from '@layerzerolabs/protocol-devtools' @@ -40,6 +41,11 @@ export interface OAppEdgeConfig { receiveConfig?: OAppReceiveConfig } +export interface OAppPeers { + vector: OmniVector + hasPeer: boolean +} + export type OAppOmniGraph = OmniGraph export type OAppFactory = Factory<[TOmniPoint], TOApp> diff --git a/tests/ua-devtools-evm-hardhat-test/test/oapp/check.test.ts b/tests/ua-devtools-evm-hardhat-test/test/oapp/check.test.ts new file mode 100644 index 000000000..4c9d46f1a --- /dev/null +++ b/tests/ua-devtools-evm-hardhat-test/test/oapp/check.test.ts @@ -0,0 +1,189 @@ +import 'hardhat' +import { OAppOmniGraph } from '@layerzerolabs/ua-devtools' +import { createOAppFactory } from '@layerzerolabs/ua-devtools-evm' +import { createConnectedContractFactory, createSignerFactory } from '@layerzerolabs/devtools-evm-hardhat' +import { EndpointId } from '@layerzerolabs/lz-definitions' +import { deployOAppFixture } from '../__utils__/oapp' +import { setupDefaultEndpoint } from '../__utils__/endpoint' +import { checkOAppPeers } from '@layerzerolabs/ua-devtools' +import { omniContractToPoint } from '@layerzerolabs/devtools-evm' +describe('oapp/check', () => { + const ethPointHardhat = { eid: EndpointId.ETHEREUM_V2_MAINNET, contractName: 'DefaultOApp' } + const avaxPointHardhat = { eid: EndpointId.AVALANCHE_V2_MAINNET, contractName: 'DefaultOApp' } + + // This is the OApp config that we want to use against our contracts + beforeEach(async () => { + await deployOAppFixture() + await setupDefaultEndpoint() + }) + + describe('checkOAppPeers', () => { + it('should return an empty array with an empty config', async () => { + const graph: OAppOmniGraph = { + contracts: [], + connections: [], + } + const contractFactory = createConnectedContractFactory() + const sdkFactory = createOAppFactory(contractFactory) + const oAppPeers = await checkOAppPeers(graph, sdkFactory) + + expect(oAppPeers).toEqual([]) + }) + + it('should return falsy values for non connected peers', async () => { + const contractFactory = createConnectedContractFactory() + + const ethContract = await contractFactory(ethPointHardhat) + const avaxContract = await contractFactory(avaxPointHardhat) + + const ethPoint = omniContractToPoint(ethContract) + const avaxPoint = omniContractToPoint(avaxContract) + + const graph: OAppOmniGraph = { + contracts: [ + { + point: ethPoint, + }, + { + point: avaxPoint, + }, + ], + connections: [ + { + vector: { from: ethPoint, to: avaxPoint }, + config: undefined, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + config: undefined, + }, + ], + } + const sdkFactory = createOAppFactory(contractFactory) + const oAppPeers = await checkOAppPeers(graph, sdkFactory) + + expect(oAppPeers).toEqual([ + { + vector: { from: ethPoint, to: avaxPoint }, + hasPeer: false, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + hasPeer: false, + }, + ]) + }) + + it('should return one truthy value for connected peers', async () => { + const contractFactory = createConnectedContractFactory() + const sdkFactory = createOAppFactory(contractFactory) + + const ethContract = await contractFactory(ethPointHardhat) + const avaxContract = await contractFactory(avaxPointHardhat) + + const ethPoint = omniContractToPoint(ethContract) + const avaxPoint = omniContractToPoint(avaxContract) + + const graph: OAppOmniGraph = { + contracts: [ + { + point: ethPoint, + }, + { + point: avaxPoint, + }, + ], + connections: [ + { + vector: { from: ethPoint, to: avaxPoint }, + config: undefined, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + config: undefined, + }, + ], + } + + { + const signerFactory = createSignerFactory() + const ethSigner = await signerFactory(ethContract.eid) + const ethOAppSdk = await sdkFactory(ethPoint) + const ethSetPeerTx = await ethOAppSdk.setPeer(avaxPoint.eid, avaxPoint.address) + await ethSigner.signAndSend(ethSetPeerTx) + } + + const oAppPeers = await checkOAppPeers(graph, sdkFactory) + + expect(oAppPeers).toEqual([ + { + vector: { from: ethPoint, to: avaxPoint }, + hasPeer: true, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + hasPeer: false, + }, + ]) + }) + + it('should return all truthy values for connected peers', async () => { + const contractFactory = createConnectedContractFactory() + const sdkFactory = createOAppFactory(contractFactory) + + const ethContract = await contractFactory(ethPointHardhat) + const avaxContract = await contractFactory(avaxPointHardhat) + + const ethPoint = omniContractToPoint(ethContract) + const avaxPoint = omniContractToPoint(avaxContract) + + const graph: OAppOmniGraph = { + contracts: [ + { + point: ethPoint, + }, + { + point: avaxPoint, + }, + ], + connections: [ + { + vector: { from: ethPoint, to: avaxPoint }, + config: undefined, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + config: undefined, + }, + ], + } + + { + const signerFactory = createSignerFactory() + + const ethSigner = await signerFactory(ethContract.eid) + const ethOAppSdk = await sdkFactory(ethPoint) + const ethSetPeerTx = await ethOAppSdk.setPeer(avaxPoint.eid, avaxPoint.address) + await ethSigner.signAndSend(ethSetPeerTx) + + const avaxSigner = await signerFactory(avaxContract.eid) + const avaxOAppSdk = await sdkFactory(avaxPoint) + const avaxSetPeerTx = await avaxOAppSdk.setPeer(ethPoint.eid, ethPoint.address) + await avaxSigner.signAndSend(avaxSetPeerTx) + } + + const oAppPeers = await checkOAppPeers(graph, sdkFactory) + + expect(oAppPeers).toEqual([ + { + vector: { from: ethPoint, to: avaxPoint }, + hasPeer: true, + }, + { + vector: { from: avaxPoint, to: ethPoint }, + hasPeer: true, + }, + ]) + }) + }) +}) diff --git a/tests/ua-devtools-evm-hardhat-test/test/oapp/config.test.ts b/tests/ua-devtools-evm-hardhat-test/test/oapp/config.test.ts index 71c08c784..7de5103b6 100644 --- a/tests/ua-devtools-evm-hardhat-test/test/oapp/config.test.ts +++ b/tests/ua-devtools-evm-hardhat-test/test/oapp/config.test.ts @@ -1,5 +1,5 @@ import 'hardhat' -import { configureOApp } from '@layerzerolabs/ua-devtools' +import { configureOApp, OAppEdgeConfig } from '@layerzerolabs/ua-devtools' import { createOAppFactory } from '@layerzerolabs/ua-devtools-evm' import { createConnectedContractFactory, @@ -22,7 +22,6 @@ import { ethSendUln2_Opt2, setupDefaultEndpoint, } from '../__utils__/endpoint' -import { OAppEdgeConfig } from '@layerzerolabs/ua-devtools' import { OmniTransaction } from '@layerzerolabs/devtools' export type OAppTestConfig = { diff --git a/tests/ua-devtools-evm-hardhat-test/test/task/oapp/checkWire.test.ts b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/checkWire.test.ts new file mode 100644 index 000000000..db5e74153 --- /dev/null +++ b/tests/ua-devtools-evm-hardhat-test/test/task/oapp/checkWire.test.ts @@ -0,0 +1,41 @@ +import hre from 'hardhat' +import { resolve } from 'path' +import { isFile } from '@layerzerolabs/io-devtools' +import { deployOAppFixture } from '../../__utils__/oapp' +import { TASK_LZ_CHECK_WIRE_OAPP, TASK_LZ_WIRE_OAPP } from '@layerzerolabs/ua-devtools-evm-hardhat' + +describe('task: checkWire', () => { + const CONFIGS_BASE_DIR = resolve(__dirname, '__data__', 'configs') + const configPathFixture = (fileName: string): string => { + const path = resolve(CONFIGS_BASE_DIR, fileName) + expect(isFile(path)).toBeTruthy() + return path + } + + beforeEach(async () => { + await deployOAppFixture() + }) + + it('should show no chains are connected', async () => { + const oappConfig = configPathFixture('valid.config.connected.js') + const result = await hre.run(TASK_LZ_CHECK_WIRE_OAPP, { oappConfig }) + const expectPoint = { eid: expect.any(Number), address: expect.any(String) } + const expectVector = { from: expectPoint, to: expectPoint } + expect(result).toEqual([ + { vector: expectVector, hasPeer: false }, + { vector: expectVector, hasPeer: false }, + ]) + }) + + it('should show both chains are connected after running wire', async () => { + const oappConfig = configPathFixture('valid.config.connected.js') + await hre.run(TASK_LZ_WIRE_OAPP, { oappConfig, ci: true }) + const result = await hre.run(TASK_LZ_CHECK_WIRE_OAPP, { oappConfig }) + const expectPoint = { eid: expect.any(Number), address: expect.any(String) } + const expectVector = { from: expectPoint, to: expectPoint } + expect(result).toEqual([ + { vector: expectVector, hasPeer: true }, + { vector: expectVector, hasPeer: true }, + ]) + }) +})