Skip to content

Commit

Permalink
reproduce promise hanging
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 19, 2025
1 parent 0cfa2ba commit 3cf07ab
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions example/src/tests/clientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,60 @@ test('can add and remove accounts', async () => {

return true
})

test('errors if dbEncryptionKey is lost', async () => {
const keyBytes = new Uint8Array([
233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64,
166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145,
])
const badKeyBytes = new Uint8Array([
0, 0, 0, 0, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, 166, 83,
208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 0, 0, 0, 0,
])
const alixWallet = Wallet.createRandom()

const alix = await Client.create(adaptEthersWalletToSigner(alixWallet), {
env: 'local',
appVersion: 'Testing/0.0.0',
dbEncryptionKey: keyBytes,
})

let errorThrown = false

try {
await Client.build(alix.address, {
env: 'local',
appVersion: 'Testing/0.0.0',
dbEncryptionKey: badKeyBytes,
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
errorThrown = true
}

if (!errorThrown) {
throw new Error(
'Expected build to throw an error with a bad encryption key but it did not'
)
}

errorThrown = false
try {
await Client.create(adaptEthersWalletToSigner(alixWallet), {
env: 'local',
appVersion: 'Testing/0.0.0',
dbEncryptionKey: badKeyBytes,
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
errorThrown = true
}

if (!errorThrown) {
throw new Error(
'Expected create to throw an error with a bad encryption key but it did not'
)
}

return true
})

0 comments on commit 3cf07ab

Please sign in to comment.