-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c26b788
commit c290fb3
Showing
24 changed files
with
824 additions
and
1,287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ExtrinsicData } from '@interlay/interbtc-api'; | ||
import { SubmittableExtrinsic } from '@polkadot/api/types'; | ||
import { ISubmittableResult } from '@polkadot/types/types'; | ||
|
||
const EXTRINSIC: SubmittableExtrinsic<'promise', ISubmittableResult> = ({ | ||
signAndSend: jest.fn().mockImplementation(async (_a, _b, cb) => { | ||
return new Promise((resolve) => { | ||
resolve(jest.fn()); | ||
|
||
setTimeout(() => { | ||
cb({ status: { isReady: true, isInBlock: true, isFinalized: true, type: 'Finalized' } }); | ||
}, 1); | ||
}); | ||
}) | ||
} as unknown) as SubmittableExtrinsic<'promise', ISubmittableResult>; | ||
|
||
const EXTRINSIC_DATA: ExtrinsicData = { | ||
extrinsic: EXTRINSIC | ||
}; | ||
|
||
export { EXTRINSIC, EXTRINSIC_DATA }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,63 @@ | ||
import { ApiPromise } from '@polkadot/api'; | ||
import { Text, TypeRegistry } from '@polkadot/types'; | ||
import { Registry } from '@polkadot/types/types'; | ||
import Big from 'big.js'; | ||
|
||
const mockApiCreateType = jest.fn(<T extends unknown>(type: string, data: T) => data); | ||
import { EXTRINSIC } from '../extrinsic'; | ||
|
||
const mockRegistry = ({ chainDecimals: [], chainSS58: 0, chainTokens: [] } as unknown) as Registry; | ||
|
||
const mockSystemChain = jest.fn().mockReturnValue(new Text(mockRegistry, 'interBTC')) as any; | ||
const REGISTRY = ({ chainDecimals: [], chainSS58: 0, chainTokens: [] } as unknown) as Registry; | ||
const SYSTEM_CHAIN = new Text(REGISTRY, 'interBTC'); | ||
|
||
const registry = new TypeRegistry(); | ||
const CHAIN_TYPE = registry.createType('ChainType', 'Live'); | ||
|
||
const VESTING_SCHEDULES = { | ||
EMPTY: [], | ||
FULL: [{ start: new Big(0), period: new Big(0), periodCount: new Big(1), perPeriod: new Big(1) }] | ||
}; | ||
|
||
// add here data that is being used in tests | ||
const DATA = { VESTING_SCHEDULES }; | ||
|
||
// add here mocks that are being manipulated in tests | ||
const MODULE = { | ||
vestingSchedules: jest.fn().mockReturnValue(VESTING_SCHEDULES.EMPTY), | ||
claimVesting: jest.fn().mockReturnValue(EXTRINSIC) | ||
}; | ||
|
||
const mockChainType = jest.fn().mockReturnValue(registry.createType('ChainType', 'Live')) as any; | ||
// maps module to ApiPromise | ||
const PROMISE: Partial<Record<keyof ApiPromise, unknown>> = { | ||
on: jest.fn(), | ||
createType: jest.fn().mockImplementation((_, data) => data), | ||
rpc: { | ||
system: { | ||
chain: jest.fn().mockReturnValue(SYSTEM_CHAIN), | ||
chainType: jest.fn().mockReturnValue(CHAIN_TYPE) | ||
} | ||
}, | ||
query: { | ||
vesting: { | ||
vestingSchedules: MODULE.vestingSchedules | ||
}, | ||
oracle: { | ||
aggregate: { | ||
keys: jest.fn().mockReturnValue([]) | ||
} | ||
} | ||
}, | ||
tx: { | ||
vesting: { | ||
claim: MODULE.claimVesting | ||
}, | ||
multiTransactionPayment: { | ||
withFeeSwapPath: jest.fn().mockReturnValue(EXTRINSIC) | ||
} | ||
} | ||
}; | ||
|
||
export { mockApiCreateType, mockChainType, mockSystemChain }; | ||
const MOCK_API = { | ||
DATA, | ||
MODULE, | ||
PROMISE | ||
}; | ||
export { MOCK_API }; |
17 changes: 0 additions & 17 deletions
17
src/test/mocks/@interlay/interbtc-api/parachain/extrinsic.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
c290fb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-kintsugi-testnet – ./
interbtc-ui-kintsugi-testnet-git-master-interlay.vercel.app
interbtc-ui.vercel.app
interbtc-ui-kintsugi-testnet-interlay.vercel.app
kintnet.interlay.io
c290fb3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-interlay-testnet – ./
interbtc-ui-interlay-testnet.vercel.app
interbtc-ui-interlay-testnet-interlay.vercel.app
interbtc-ui-interlay-testnet-git-master-interlay.vercel.app
testnet.interlay.io