mirror of
https://github.com/tompro/sattle.git
synced 2026-10-26 01:49:58 +00:00
test(funds): fence harness on v2 owner install
This commit is contained in:
@@ -9,7 +9,7 @@ import {finalizeEvent, getPublicKey} from 'nostr-tools/pure'
|
||||
import {v2 as nip44v2} from 'nostr-tools/nip44'
|
||||
import {buildNoteUrl} from 'lnurlcash-kit'
|
||||
|
||||
import {deriveBearerAesKey, linkingPubKeyHex, saveLinkingKey} from './keys'
|
||||
import {deriveBearerAesKey, deriveWalletMaterial, linkingPubKeyHex, saveWalletMaterial} from './keys'
|
||||
import {
|
||||
BACKUP_EVENT_KIND,
|
||||
backupPubkey,
|
||||
@@ -40,6 +40,13 @@ import {requiredValue, stubLocalStorage} from './test-utils'
|
||||
const LINKING_KEY = new Uint8Array(32).fill(7)
|
||||
const OTHER_KEY = new Uint8Array(32).fill(9)
|
||||
const OWNER_ID = linkingPubKeyHex(LINKING_KEY)
|
||||
// full v2 material for the fixed harness linking key (real BIP-32 cash root)
|
||||
const MATERIAL = {
|
||||
...deriveWalletMaterial(
|
||||
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
|
||||
),
|
||||
linkingKeyHex: bytesToHex(LINKING_KEY),
|
||||
}
|
||||
|
||||
const K1_A = 'aa'.repeat(32)
|
||||
const K1_B = 'bb'.repeat(32)
|
||||
@@ -103,7 +110,7 @@ describe('restoreFromNostr', () => {
|
||||
const {transport} = createRecordingTransport()
|
||||
|
||||
// device A: one note, one trusted mint, one setting - all published
|
||||
await saveLinkingKey(LINKING_KEY)
|
||||
await saveWalletMaterial(MATERIAL)
|
||||
await persistBearer(aesKey, bearerFixture({id: 'note-a'}))
|
||||
await addTrustedMint('mint.example', MINT_PUBKEY, {ownerId: OWNER_ID})
|
||||
persistSettings({defaultMint: 'mint.example'})
|
||||
@@ -120,7 +127,7 @@ describe('restoreFromNostr', () => {
|
||||
|
||||
// device B: the same seed on empty storage
|
||||
stubLocalStorage()
|
||||
await saveLinkingKey(LINKING_KEY)
|
||||
await saveWalletMaterial(MATERIAL)
|
||||
const result = await restoreFromNostr(LINKING_KEY, RELAYS, {transport})
|
||||
|
||||
expect(result.found).toEqual(['notes', 'mints', 'settings'])
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest'
|
||||
|
||||
import {linkingPubKeyHex, saveLinkingKey} from './keys'
|
||||
import {bytesToHex} from '@noble/hashes/utils.js'
|
||||
|
||||
import {deriveWalletMaterial, linkingPubKeyHex, saveWalletMaterial} from './keys'
|
||||
import {applyBackup, buildBackup, parseBackupFile} from './storage'
|
||||
import {readFundsDocument, writeFundsDocument} from './storage/bearers'
|
||||
import {addTrustedMint, readTrustedMints} from './trustedMints'
|
||||
@@ -16,6 +18,14 @@ const LINKING_KEY = new Uint8Array(32).fill(7)
|
||||
const OWNER_ID = linkingPubKeyHex(LINKING_KEY)
|
||||
const KEY_A = '02' + 'aa'.repeat(32)
|
||||
const KEY_B = '03' + 'bb'.repeat(32)
|
||||
// full v2 material for this harness's fixed linking key (real BIP-32 cash
|
||||
// root, same construction as the lifecycle test harness)
|
||||
const MATERIAL = {
|
||||
...deriveWalletMaterial(
|
||||
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
|
||||
),
|
||||
linkingKeyHex: bytesToHex(LINKING_KEY),
|
||||
}
|
||||
|
||||
type LockRequest = {
|
||||
readonly callback: () => unknown
|
||||
@@ -59,7 +69,7 @@ const backup = (server: string, mintPubkey: string) => ({
|
||||
],
|
||||
})
|
||||
|
||||
const installProvenOwner = (): Promise<void> => saveLinkingKey(LINKING_KEY)
|
||||
const installProvenOwner = (): Promise<void> => saveWalletMaterial(MATERIAL)
|
||||
|
||||
beforeEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
|
||||
Reference in New Issue
Block a user