From 3b1648319e908118497082841ddae6e3d61f9bad Mon Sep 17 00:00:00 2001 From: Jan Nanista Date: Mon, 20 Nov 2023 18:25:28 -0800 Subject: [PATCH] WIP --- packages/utils-evm/test/oapp.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 packages/utils-evm/test/oapp.test.ts diff --git a/packages/utils-evm/test/oapp.test.ts b/packages/utils-evm/test/oapp.test.ts new file mode 100644 index 000000000..a34ac4250 --- /dev/null +++ b/packages/utils-evm/test/oapp.test.ts @@ -0,0 +1,28 @@ +import { Contract } from "@ethersproject/contracts" +import { EndpointId } from "@layerzerolabs/lz-definitions" +import { expect } from "chai" +import { describe } from "mocha" +import sinon from "sinon" +import { createSetPeerConfigurable } from "../src/oapp" +import { isMisconfigured } from "../src/configurable" + +describe("oapp", () => { + describe("createSetPeerConfigurable", () => { + it("should return Configured if the current and desired values match", async () => { + const oapp = { + peers: sinon.stub().resolves("peer-not-set"), + setPeer: sinon.stub().resolves("okay"), + } + const configurable = createSetPeerConfigurable((_, endpointId) => `peer-on-${endpointId}`) + const state = await configurable(oapp as unknown as Contract, EndpointId.AAVEGOTCHI_TESTNET) + + expect(isMisconfigured(state)).to.be.true + expect(state.value).to.eql("peer-not-set") + expect(state.desiredValue).to.eql(`peer-on-${EndpointId.AAVEGOTCHI_TESTNET}`) + + const result = await state.configure?.() + + expect(result).to.eql("okay") + }) + }) +})