|
| 1 | +import { Wallet } from '../../../src/application/types/Wallet'; |
| 2 | + |
| 3 | +const TEST_MNEMONIC = 'test test test test test test test test test test test ball'; |
| 4 | + |
| 5 | +describe('Wallet', () => { |
| 6 | + let wallet: Wallet; |
| 7 | + |
| 8 | + beforeEach(() => { |
| 9 | + wallet = new Wallet(TEST_MNEMONIC); |
| 10 | + }); |
| 11 | + |
| 12 | + it('should return the mnemonic', () => { |
| 13 | + expect(wallet.getMnemonic()).toBe(TEST_MNEMONIC); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should throw if mnemonic is missing', () => { |
| 17 | + // @ts-expect-error: purposely breaking for test |
| 18 | + const w = new Wallet(); |
| 19 | + expect(() => w.getMnemonic()).toThrow('Mnemonic seed phrase is not loaded.'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should return the expected master secret key', async () => { |
| 23 | + const key = await wallet.getMasterSecretKey(); |
| 24 | + expect(key.toString('hex')).toBe('3016401f710b4e57bc41a65ae853756c6bb87b91309ccd7cab7f9bf4aefd486b'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should return the expected public synthetic key', async () => { |
| 28 | + const key = await wallet.getPublicSyntheticKey(); |
| 29 | + expect(key.toString('hex')).toBe('aa5b2a88de3885ada96bf2d4e3bde4385d4401f0fcc86326454e78651c755a597ce15d16e9570f4cd9b30d0a34f703a1'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should return the expected private synthetic key', async () => { |
| 33 | + const key = await wallet.getPrivateSyntheticKey(); |
| 34 | + expect(key.toString('hex')).toBe('6b2f510ff5a9edafde155623bc19ba49f079d1b3c52443bb40dfc41ebcfff52b'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should return the expected owner puzzle hash', async () => { |
| 38 | + const hash = await wallet.getOwnerPuzzleHash(); |
| 39 | + expect(hash.toString('hex')).toBe('2485e1f2023ba59d36c63e2e52d3654d5d6a599773c82ba0895a3e74e7903550'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should return the expected owner public key', async () => { |
| 43 | + const pub = await wallet.getOwnerPublicKey(); |
| 44 | + expect(pub).toBe('xch1yjz7rusz8wje6dkx8ch995m9f4wk5kvhw0yzhgyftgl8feusx4gq820cf2'); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should return the expected key ownership signature', async () => { |
| 48 | + const sig = await wallet.createKeyOwnershipSignature('nonce123'); |
| 49 | + expect(sig).toBe('a88c13c667ac01702e1629dc6aef9215239e4b1d09eb9533a43989850713e15444ff886c4d86f14841880c52ab3bffd90ebf63c2986b27ee0450dc04ee29aef9c01de29ec7d879d6d3fa269aaf8706894bdefa1fd09c03b4464ee7b2017703ee'); |
| 50 | + }); |
| 51 | +}); |
0 commit comments