-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
7 changed files
with
60 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { EvmWallet, Substrate } from './wallets'; | ||
export { EvmWallet, SubstrateWallet } from './wallets'; |
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,37 @@ | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
import { describe, it, expect, vi, afterEach } from 'vitest'; | ||
import { SubstrateWallet } from '../wallets'; | ||
|
||
vi.mock('@polkadot/api', async () => { | ||
const mod = | ||
await vi.importActual<typeof import('@polkadot/api')>('@polkadot/api'); | ||
const WsProviderMock = vi.fn(); | ||
const ApiPromiseMock = { | ||
create: async () => {} | ||
}; | ||
return { | ||
...mod, | ||
WsProvider: WsProviderMock, | ||
ApiPromise: ApiPromiseMock | ||
}; | ||
}); | ||
|
||
describe('SubstrateWallet', () => { | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should be able to create an instance of SubstrateWallet passing an ApiPromise', async () => { | ||
const wsProvider = new WsProvider('wss:someurl'); | ||
const apiPromise = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
const substrateWallet = SubstrateWallet.connectFromApiPromise(apiPromise); | ||
expect(substrateWallet).toBeInstanceOf(SubstrateWallet); | ||
}); | ||
|
||
it('should be able to create an instance of SubstrateWallet passing a wssProvider', async () => { | ||
const substrateWallet = | ||
await SubstrateWallet.connectFromWssProvider('wss:someurl'); | ||
expect(substrateWallet).toBeInstanceOf(SubstrateWallet); | ||
}); | ||
}); |
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 +1 @@ | ||
export { Substrate } from './Substrate'; | ||
export { SubstrateWallet } from './Substrate'; |
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,2 +1,2 @@ | ||
export { EvmWallet } from './Evm'; | ||
export { Substrate } from './Substrate'; | ||
export { SubstrateWallet } from './Substrate'; |
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