Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid sinon import in exported lib files #3685

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions typescript/sdk/src/test/multiProviderStubs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sinon from 'sinon';

import { MultiProtocolProvider } from '../providers/MultiProtocolProvider.js';

/**
* Takes a MultiProtocolProvider instance and stubs it's get*Provider methods to
* return mock providers. More provider methods can be added her as needed.
* Note: callers should call `sandbox.restore()` after tests complete.
*/
export function stubMultiProtocolProvider(
multiProvider: MultiProtocolProvider,
): sinon.SinonSandbox {
const sandbox = sinon.createSandbox();
sandbox.stub(multiProvider, 'getEthersV5Provider').returns({
getBalance: async () => '100',
} as any);
sandbox.stub(multiProvider, 'getCosmJsProvider').returns({
getBalance: async () => ({ amount: '100' }),
} as any);
sandbox.stub(multiProvider, 'getCosmJsWasmProvider').returns({
getBalance: async () => ({ amount: '100' }),
queryContractSmart: async () => ({
type: { native: { fungible: { denom: 'denom' } } },
}),
} as any);
sandbox.stub(multiProvider, 'getSolanaWeb3Provider').returns({
getBalance: async () => '100',
getTokenAccountBalance: async () => ({ value: { amount: '100' } }),
} as any);
return sandbox;
}
30 changes: 0 additions & 30 deletions typescript/sdk/src/test/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BigNumber, ethers } from 'ethers';
import sinon from 'sinon';

import { Address, exclude, objMap } from '@hyperlane-xyz/utils';

Expand All @@ -10,7 +9,6 @@ import { IgpFactories } from '../gas/contracts.js';
import { IgpConfig } from '../gas/types.js';
import { HookType } from '../hook/types.js';
import { IsmType } from '../ism/types.js';
import { MultiProtocolProvider } from '../providers/MultiProtocolProvider.js';
import { RouterConfig } from '../router/types.js';
import { ChainMap, ChainName } from '../types.js';

Expand Down Expand Up @@ -91,31 +89,3 @@ export function testIgpConfig(
]),
);
}

/**
* Takes a MultiProtocolProvider instance and stubs it's get*Provider methods to
* return mock providers. More provider methods can be added her as needed.
* Note: callers should call `sandbox.restore()` after tests complete.
*/
export function stubMultiProtocolProvider(
multiProvider: MultiProtocolProvider,
): sinon.SinonSandbox {
const sandbox = sinon.createSandbox();
sandbox.stub(multiProvider, 'getEthersV5Provider').returns({
getBalance: async () => '100',
} as any);
sandbox.stub(multiProvider, 'getCosmJsProvider').returns({
getBalance: async () => ({ amount: '100' }),
} as any);
sandbox.stub(multiProvider, 'getCosmJsWasmProvider').returns({
getBalance: async () => ({ amount: '100' }),
queryContractSmart: async () => ({
type: { native: { fungible: { denom: 'denom' } } },
}),
} as any);
sandbox.stub(multiProvider, 'getSolanaWeb3Provider').returns({
getBalance: async () => '100',
getTokenAccountBalance: async () => ({ value: { amount: '100' } }),
} as any);
return sandbox;
}
2 changes: 1 addition & 1 deletion typescript/sdk/src/token/Token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
testSealevelChain,
} from '../consts/testChains.js';
import { MultiProtocolProvider } from '../providers/MultiProtocolProvider.js';
import { stubMultiProtocolProvider } from '../test/testUtils.js';
import { stubMultiProtocolProvider } from '../test/multiProviderStubs.js';

import { TokenArgs } from './IToken.js';
import { Token } from './Token.js';
Expand Down
Loading