Skip to content

Commit 8cfafe7

Browse files
committed
test: wif.decode never returns pooled keys
1 parent 515007a commit 8cfafe7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/wif.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import { test } from 'node:test'
55
import assert from 'node:assert/strict'
66
import * as wif from 'wif'
77

8+
const tracked = []
9+
810
async function fromWifString(str) {
911
const a = await lib.fromWifString(str)
1012
const b = lib.fromWifStringSync(str)
1113
assert.deepStrictEqual(a, b)
14+
tracked.push(a.privateKey, b.privateKey)
1215
return a
1316
}
1417

@@ -97,3 +100,11 @@ test('invalid length throws before version check', async (t) => {
97100
})
98101
}
99102
})
103+
104+
test('wif.decode returns non-pooled Uint8Array instances', (t) => {
105+
t.assert.ok(tracked.length > 1000)
106+
107+
for (const u8 of tracked) {
108+
t.assert.strictEqual(u8.byteLength, u8.buffer.byteLength)
109+
}
110+
})

0 commit comments

Comments
 (0)