Skip to content

Commit

Permalink
Merge branch 'main' into noah/txs
Browse files Browse the repository at this point in the history
  • Loading branch information
nbayindirli committed May 1, 2024
2 parents 87f8be6 + cf727db commit face9b1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
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

0 comments on commit face9b1

Please sign in to comment.