Skip to content

Commit

Permalink
fix plugin unit test to take config not teller addr
Browse files Browse the repository at this point in the history
  • Loading branch information
luketchang committed Sep 11, 2023
1 parent 3eaa2d7 commit 6255d00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/op-request-plugins/test/plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "mocha";
import { expect } from "chai";
import { Erc20Plugin, WstethAdapterPlugin } from "../src";
import { Erc20Plugin, UniswapV3Plugin, WstethAdapterPlugin } from "../src";
import {
newOpRequestBuilder,
NocturneSigner,
Expand All @@ -12,7 +12,7 @@ import { ethers } from "ethers";
import ERC20_ABI from "../src/abis/ERC20.json";
import { WstethAdapter__factory } from "@nocturne-xyz/contracts";
import {
DUMMY_CONTRACT_ADDR,
DUMMY_CONFIG,
WETH_ADDRESS,
WSTETH_ADAPTER_ADDRESS,
WSTETH_ADDRESS,
Expand All @@ -26,14 +26,15 @@ describe("OpRequestBuilder", () => {
const refundAddr = signer.generateRandomStealthAddress();

const provider = ethers.getDefaultProvider();
const builder = newOpRequestBuilder(provider, 1n, DUMMY_CONTRACT_ADDR);
const builder = newOpRequestBuilder(provider, 1n, DUMMY_CONFIG);
const recipient = ethers.utils.getAddress(
"0x1E2cD78882b12d3954a049Fd82FFD691565dC0A5"
);

const opRequest = await builder
.use(Erc20Plugin)
.use(WstethAdapterPlugin)
.use(UniswapV3Plugin)
.erc20Transfer(shitcoin.assetAddr, recipient, 100n)
.convertWethToWsteth(100n)
.refundAddr(refundAddr)
Expand Down Expand Up @@ -78,7 +79,7 @@ describe("OpRequestBuilder", () => {
},
],
chainId: 1n,
tellerContract: DUMMY_CONTRACT_ADDR,
tellerContract: DUMMY_CONFIG.tellerAddress(),
deadline: 2n,
},
meta: {
Expand All @@ -101,4 +102,6 @@ describe("OpRequestBuilder", () => {

expect(opRequest).to.eql(expected);
});

// TODO: figure out how to unit test uniswap plugin if possible (network calls make it tough)
});
3 changes: 3 additions & 0 deletions packages/op-request-plugins/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { loadNocturneConfigBuiltin } from "@nocturne-xyz/config";
import { Asset, AssetTrait } from "@nocturne-xyz/core";
import { AssetType } from "@nocturne-xyz/core/src";
import { ethers } from "ethers";

export const DUMMY_CONFIG = loadNocturneConfigBuiltin("example-network");

export const WETH_ADDRESS = ethers.utils.getAddress(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
);
Expand Down

0 comments on commit 6255d00

Please sign in to comment.