Skip to content

Commit

Permalink
fix tests and silence error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonator committed Jun 12, 2024
1 parent e61d475 commit 5c2108c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
12 changes: 6 additions & 6 deletions packages/bridge/src/__tests__/mock-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const MockChains: Chain[] = [
},
explorers: [
{
tx_page: "https://www.mintscan.io/cosmos/txs/${txHash}",
tx_page: "https://www.mintscan.io/osmosis/txs/{txHash}",
},
],
features: [
Expand Down Expand Up @@ -115,7 +115,7 @@ export const MockChains: Chain[] = [
},
explorers: [
{
tx_page: "https://www.mintscan.io/osmosis/txs/${txHash}",
tx_page: "https://www.mintscan.io/cosmos/txs/{txHash}",
},
],
features: ["ibc-go", "ibc-transfer"],
Expand Down Expand Up @@ -178,7 +178,7 @@ export const MockChains: Chain[] = [
},
explorers: [
{
tx_page: "https://www.mintscan.io/juno/txs/${txHash}",
tx_page: "https://www.mintscan.io/juno/txs/{txHash}",
},
],
features: ["ibc-transfer", "ibc-go", "cosmwasm", "wasmd_0.24+"],
Expand Down Expand Up @@ -233,7 +233,7 @@ export const MockChains: Chain[] = [
},
explorers: [
{
tx_page: "https://explorer.injective.network/transaction/${txHash}",
tx_page: "https://explorer.injective.network/transaction/{txHash}",
},
],
features: ["ibc-transfer", "ibc-go", "eth-address-gen", "eth-key-sign"],
Expand Down Expand Up @@ -290,7 +290,7 @@ export const MockChains: Chain[] = [
explorers: [
{
tx_page:
"https://secretnodes.com/secret/chains/secret-4/transactions/${txHash}",
"https://secretnodes.com/secret/chains/secret-4/transactions/{txHash}",
},
],
features: [
Expand Down Expand Up @@ -351,7 +351,7 @@ export const MockChains: Chain[] = [
},
explorers: [
{
tx_page: "https://axelarscan.io/tx/${txHash}",
tx_page: "https://axelarscan.io/tx/{txHash}",
},
],
features: ["ibc-transfer", "ibc-go", "axelar-evm-bridge"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jest.mock("@osmosis-labs/utils", () => ({
}),
}));

// silence console errors
jest.spyOn(console, "error").mockImplementation(() => {});

describe("AxelarTransferStatusProvider", () => {
let provider: AxelarTransferStatusProvider;
const mockReceiver: TransferStatusReceiver = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,6 @@ describe("IBCTransferStatusProvider", () => {

const url = provider.makeExplorerUrl(params);

expect(url).toBe(`https://www.mintscan.io/osmosis-1/txs/ABC123`);
expect(url).toBe(`https://www.mintscan.io/osmosis/txs/ABC123`);
});
});
46 changes: 23 additions & 23 deletions packages/bridge/src/skip/__tests__/skip-transfer-status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { server } from "../../__tests__/msw";
import { BridgeEnvironment, TransferStatusReceiver } from "../../interface";
import { SkipTransferStatusProvider } from "../transfer-status";

jest.mock("@osmosis-labs/utils", () => {
const originalModule = jest.requireActual("@osmosis-labs/utils");
return {
...originalModule,
poll: jest.fn(({ fn, validate }) => {
const pollFn = async () => {
const result = await fn();
if (validate(result)) {
return result;
}
};
return pollFn();
}),
};
});
jest.mock("@osmosis-labs/utils", () => ({
...jest.requireActual("@osmosis-labs/utils"),
poll: jest.fn(({ fn, validate }) => {
const pollFn = async () => {
const result = await fn();
if (validate(result)) {
return result;
}
};
return pollFn();
}),
}));

// silence console errors
jest.spyOn(console, "error").mockImplementation(() => {});

describe("SkipTransferStatusProvider", () => {
let provider: SkipTransferStatusProvider;
Expand Down Expand Up @@ -54,12 +54,12 @@ describe("SkipTransferStatusProvider", () => {
})
);

await provider.trackTxStatus(
JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 })
);
const params = JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 });

await provider.trackTxStatus(params);

expect(mockReceiver.receiveNewTxStatus).toHaveBeenCalledWith(
`Skip${JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 })}`,
`Skip${params}`,
"success",
undefined
);
Expand All @@ -72,12 +72,12 @@ describe("SkipTransferStatusProvider", () => {
})
);

await provider.trackTxStatus(
JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 })
);
const params = JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 });

await provider.trackTxStatus(params);

expect(mockReceiver.receiveNewTxStatus).toHaveBeenCalledWith(
`Skip${JSON.stringify({ sendTxHash: "testTxHash", fromChainId: 1 })}`,
`Skip${params}`,
"failed",
undefined
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jest.mock("@osmosis-labs/utils", () => {
};
});

// silence console errors
jest.spyOn(console, "error").mockImplementation(() => {});

describe("SquidTransferStatusProvider", () => {
let provider: SquidTransferStatusProvider;
const mockReceiver: TransferStatusReceiver = {
Expand Down

0 comments on commit 5c2108c

Please sign in to comment.