From 4401c68ddfef2828dc43277c54370c792913f01e Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 27 Nov 2023 16:01:59 -0800 Subject: [PATCH] chore: More explicit test for builder when deployments change --- .../test/builder.test.ts | 39 ++++++++++++++----- .../ua-utils/test/omnigraph/builder.test.ts | 8 +--- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/packages/ua-utils-evm-hardhat-test/test/builder.test.ts b/packages/ua-utils-evm-hardhat-test/test/builder.test.ts index 9457e5a18..d5311de57 100644 --- a/packages/ua-utils-evm-hardhat-test/test/builder.test.ts +++ b/packages/ua-utils-evm-hardhat-test/test/builder.test.ts @@ -3,7 +3,7 @@ import hre from 'hardhat' import { describe } from 'mocha' import { eidAndDeploymentToPoint, OmniGraphBuilderHardhat } from '@layerzerolabs/ua-utils-evm-hardhat' import { getNetworkRuntimeEnvironment } from '@layerzerolabs/utils-evm-hardhat' -import { OmniPoint } from '@layerzerolabs/ua-utils' +import { arePointsEqual, OmniPoint } from '@layerzerolabs/ua-utils' import assert from 'assert' describe('builder', () => { @@ -11,6 +11,9 @@ describe('builder', () => { const britneyEnv = await getNetworkRuntimeEnvironment('britney') const vengaboysEnv = await getNetworkRuntimeEnvironment('vengaboys') + assert(britneyEnv.network.config.endpointId, 'Missing endpointId on britney network') + assert(vengaboysEnv.network.config.endpointId, 'Missing endpointId on vengaboys network') + const britneyDeployment = await britneyEnv.deployments.get('DefaultOApp') const vengaboysDeployment = await vengaboysEnv.deployments.get('DefaultOApp') @@ -41,31 +44,49 @@ describe('builder', () => { const britneyEnv = await getNetworkRuntimeEnvironment('britney') const vengaboysEnv = await getNetworkRuntimeEnvironment('vengaboys') + assert(britneyEnv.network.config.endpointId, 'Missing endpointId on britney network') + assert(vengaboysEnv.network.config.endpointId, 'Missing endpointId on vengaboys network') + + const oldBritneyDeployment = await britneyEnv.deployments.get('DefaultOApp') + const oldVengaboysDeployment = await vengaboysEnv.deployments.get('DefaultOApp') + + const oldBritneyPoint: OmniPoint = eidAndDeploymentToPoint( + britneyEnv.network.config.endpointId, + oldBritneyDeployment + ) + const oldVengaboysPoint: OmniPoint = eidAndDeploymentToPoint( + vengaboysEnv.network.config.endpointId, + oldVengaboysDeployment + ) + + const oldBuilder = await OmniGraphBuilderHardhat.fromDeployedContract(hre, 'DefaultOApp') + const [_, deployer] = await britneyEnv.getUnnamedAccounts() assert(deployer, 'Missing deployer') - const britneyDeployment = await britneyEnv.deployments.deploy('DefaultOApp', { + const newBritneyDeployment = await britneyEnv.deployments.deploy('DefaultOApp', { from: deployer, skipIfAlreadyDeployed: false, }) - const vengaboysDeployment = await vengaboysEnv.deployments.get('DefaultOApp') - const britneyPoint: OmniPoint = eidAndDeploymentToPoint(britneyEnv.network.config.endpointId, britneyDeployment) - const vengaboysPoint: OmniPoint = eidAndDeploymentToPoint( - vengaboysEnv.network.config.endpointId, - vengaboysDeployment + const newBritneyPoint: OmniPoint = eidAndDeploymentToPoint( + britneyEnv.network.config.endpointId, + newBritneyDeployment ) + expect(arePointsEqual(newBritneyPoint, oldBritneyPoint)).to.be.false + const builder = await OmniGraphBuilderHardhat.fromDeployedContract(hre, 'DefaultOApp') + expect(oldBuilder.graph).not.to.eql(builder.graph) expect(builder.graph).to.eql({ contracts: [ { - point: vengaboysPoint, + point: oldVengaboysPoint, config: undefined, }, { - point: britneyPoint, + point: newBritneyPoint, config: undefined, }, ], diff --git a/packages/ua-utils/test/omnigraph/builder.test.ts b/packages/ua-utils/test/omnigraph/builder.test.ts index 3f6b36531..ed6ff01aa 100644 --- a/packages/ua-utils/test/omnigraph/builder.test.ts +++ b/packages/ua-utils/test/omnigraph/builder.test.ts @@ -1,11 +1,5 @@ import fc from 'fast-check' -import { - createNodeArbitrary, - createEdgeArbitrary, - pointArbitrary, - vectorArbitrary, - endpointArbitrary, -} from '../__utils__/arbitraries' +import { createNodeArbitrary, createEdgeArbitrary, pointArbitrary, vectorArbitrary } from '../__utils__/arbitraries' import { OmniGraphBuilder } from '@/omnigraph/builder' import { arePointsEqual, areVectorsEqual } from '@/omnigraph'