1
- import config from "../../../src/config" ;
1
+ import { Wallet } from '../../../src/application/types/Wallet' ;
2
+ import config from '../../../src/config' ;
2
3
3
4
describe ( 'Wallet' , ( ) => {
4
5
const TEST_MNEMONIC = 'test test test test test test test test test test test ball' ;
@@ -9,57 +10,61 @@ describe('Wallet', () => {
9
10
} ) ;
10
11
11
12
it ( 'should return the mnemonic' , ( ) => {
12
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
13
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
13
14
expect ( wallet . getMnemonic ( ) ) . toBe ( TEST_MNEMONIC ) ;
14
15
} ) ;
15
16
16
- it ( 'should throw if mnemonic is missing' , ( ) => {
17
- // purposely breaking for test
18
- const w = new ( require ( '../../../src/application/types/Wallet' ) . Wallet ) ( ) ;
19
- expect ( ( ) => w . getMnemonic ( ) ) . toThrow ( 'Mnemonic seed phrase is not loaded.' ) ;
20
- } ) ;
21
-
22
17
it ( 'should return the expected master secret key' , async ( ) => {
23
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
18
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
24
19
const key = await wallet . getMasterSecretKey ( ) ;
25
- expect ( key . toString ( 'hex' ) ) . toBe ( '3016401f710b4e57bc41a65ae853756c6bb87b91309ccd7cab7f9bf4aefd486b' ) ;
20
+ expect ( key . toString ( 'hex' ) ) . toBe (
21
+ '3016401f710b4e57bc41a65ae853756c6bb87b91309ccd7cab7f9bf4aefd486b' ,
22
+ ) ;
26
23
} ) ;
27
24
28
25
it ( 'should return the expected public synthetic key' , async ( ) => {
29
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
26
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
30
27
const key = await wallet . getPublicSyntheticKey ( ) ;
31
- expect ( key . toString ( 'hex' ) ) . toBe ( 'aa5b2a88de3885ada96bf2d4e3bde4385d4401f0fcc86326454e78651c755a597ce15d16e9570f4cd9b30d0a34f703a1' ) ;
28
+ expect ( key . toString ( 'hex' ) ) . toBe (
29
+ 'aa5b2a88de3885ada96bf2d4e3bde4385d4401f0fcc86326454e78651c755a597ce15d16e9570f4cd9b30d0a34f703a1' ,
30
+ ) ;
32
31
} ) ;
33
32
34
33
it ( 'should return the expected private synthetic key' , async ( ) => {
35
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
34
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
36
35
const key = await wallet . getPrivateSyntheticKey ( ) ;
37
- expect ( key . toString ( 'hex' ) ) . toBe ( '6b2f510ff5a9edafde155623bc19ba49f079d1b3c52443bb40dfc41ebcfff52b' ) ;
36
+ expect ( key . toString ( 'hex' ) ) . toBe (
37
+ '6b2f510ff5a9edafde155623bc19ba49f079d1b3c52443bb40dfc41ebcfff52b' ,
38
+ ) ;
38
39
} ) ;
39
40
40
41
it ( 'should return the expected owner puzzle hash' , async ( ) => {
41
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
42
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
42
43
const hash = await wallet . getPuzzleHash ( ) ;
43
- expect ( hash . toString ( 'hex' ) ) . toBe ( '2485e1f2023ba59d36c63e2e52d3654d5d6a599773c82ba0895a3e74e7903550' ) ;
44
+ expect ( hash . toString ( 'hex' ) ) . toBe (
45
+ '2485e1f2023ba59d36c63e2e52d3654d5d6a599773c82ba0895a3e74e7903550' ,
46
+ ) ;
44
47
} ) ;
45
48
46
49
it ( 'should return the expected owner public key for mainet' , async ( ) => {
47
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
50
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
48
51
config . BLOCKCHAIN_NETWORK = 'mainnet' ;
49
52
const pub = await wallet . getOwnerPublicKey ( ) ;
50
53
expect ( pub ) . toBe ( 'xch1yjz7rusz8wje6dkx8ch995m9f4wk5kvhw0yzhgyftgl8feusx4gq820cf2' ) ;
51
54
} ) ;
52
55
53
- it ( 'should return the expected owner public key for testnet' , async ( ) => {
54
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
56
+ it ( 'should return the expected owner public key for testnet' , async ( ) => {
57
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
55
58
config . BLOCKCHAIN_NETWORK = 'testnet' ;
56
59
const pub = await wallet . getOwnerPublicKey ( ) ;
57
60
expect ( pub ) . toBe ( 'txch1yjz7rusz8wje6dkx8ch995m9f4wk5kvhw0yzhgyftgl8feusx4gq2dgwge' ) ;
58
61
} ) ;
59
62
60
63
it ( 'should return the expected key ownership signature' , async ( ) => {
61
- wallet = new ( require ( '../../../src/application/types/ Wallet' ) . Wallet ) ( TEST_MNEMONIC ) ;
64
+ wallet = new Wallet ( TEST_MNEMONIC ) ;
62
65
const sig = await wallet . createKeyOwnershipSignature ( 'nonce123' ) ;
63
- expect ( sig ) . toBe ( 'a88c13c667ac01702e1629dc6aef9215239e4b1d09eb9533a43989850713e15444ff886c4d86f14841880c52ab3bffd90ebf63c2986b27ee0450dc04ee29aef9c01de29ec7d879d6d3fa269aaf8706894bdefa1fd09c03b4464ee7b2017703ee' ) ;
66
+ expect ( sig ) . toBe (
67
+ 'a88c13c667ac01702e1629dc6aef9215239e4b1d09eb9533a43989850713e15444ff886c4d86f14841880c52ab3bffd90ebf63c2986b27ee0450dc04ee29aef9c01de29ec7d879d6d3fa269aaf8706894bdefa1fd09c03b4464ee7b2017703ee' ,
68
+ ) ;
64
69
} ) ;
65
70
} ) ;
0 commit comments