-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve wallet + test and improve types
- Loading branch information
1 parent
558d028
commit 6996b89
Showing
8 changed files
with
61 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { defaultNetwork, networks } from '../src/constants/network' | ||
import { setupWallet } from '../src/wallet' | ||
|
||
describe('Verify wallet functions', () => { | ||
const isLocalhost = process.env.LOCALHOST === 'true' | ||
|
||
// Define the test network and its details | ||
const TEST_NETWORK = !isLocalhost | ||
? { networkId: networks[0].id } | ||
: { networkId: 'autonomys-localhost' } | ||
const TEST_NETWORK_DETAIL = networks.find((network) => network.id === TEST_NETWORK.networkId) | ||
if (!TEST_NETWORK_DETAIL) throw new Error(`Network with id ${TEST_NETWORK.networkId} not found`) | ||
|
||
const TEST_INVALID_NETWORK = { networkId: 'invalid-network' } | ||
|
||
const ALICE_MNEMONIC = 'bottom drive obey lake curtain smoke basket hold race lonely fit walk' //Alice | ||
const ALICE_ADDRESS = '5DFJF7tY4bpbpcKPJcBTQaKuCDEPCpiz8TRjpmLeTtweqmXL' | ||
const BOB_URI = '//BOB' | ||
const BOB_ADDRESS = '5DAw2FpYk2y3JHrsia14KEx7tpezNymdFKkunicZ5ygPGXYF' | ||
|
||
test('Check setupWallet return a pair with matching address and public key when provided with a mnemonic', async () => { | ||
const pair = setupWallet({ mnemonic: ALICE_MNEMONIC }) | ||
expect(pair.address).toEqual(ALICE_ADDRESS) | ||
}) | ||
|
||
test('Check setupWallet return a pair with matching private key when provided with a pk', async () => { | ||
const pair = setupWallet({ uri: BOB_URI }) | ||
expect(pair.address).toEqual(BOB_ADDRESS) | ||
}) | ||
}) |
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
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,2 @@ | ||
export * from './types' | ||
export * from './network' | ||
export * from './wallet' |
File renamed without changes.
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,13 @@ | ||
export type Mnemonic = { | ||
mnemonic: string | ||
} | ||
|
||
export type URI = { | ||
uri: string | ||
} | ||
|
||
export type AppName = { | ||
appName: string | ||
} | ||
|
||
export type MnemonicOrURI = Mnemonic | URI |
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