Skip to content

Commit f717332

Browse files
Benchmark Fixed
1 parent 1abe5d1 commit f717332

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

benchmarks/transaction-bench.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ async function deepInputChain () {
2121
const path = [
2222
[
2323
{ offset: 0, hash: txid, txid: true, duplicate: false },
24-
{ offset: 1, hash: 'otherHash1', txid: false, duplicate: false }
24+
{ offset: 1, hash: 'aa'.repeat(32), txid: false, duplicate: false }
2525
],
26-
[{ offset: 1, hash: 'mergedHash1', txid: false, duplicate: false }]
26+
[{ offset: 1, hash: 'bb'.repeat(32), txid: false, duplicate: false }]
2727
]
2828
const merklePath = new MerklePath(blockHeight, path)
2929
tx.merklePath = merklePath
@@ -65,9 +65,9 @@ async function wideInputSet () {
6565
const path = [
6666
[
6767
{ offset: 0, hash: txid, txid: true, duplicate: false },
68-
{ offset: 1, hash: 'otherHash1', txid: false, duplicate: false }
68+
{ offset: 1, hash: 'aa'.repeat(32), txid: false, duplicate: false }
6969
],
70-
[{ offset: 1, hash: 'mergedHash1', txid: false, duplicate: false }]
70+
[{ offset: 1, hash: 'bb'.repeat(32), txid: false, duplicate: false }]
7171
]
7272
const merklePath = new MerklePath(blockHeight, path)
7373
sourceTx.merklePath = merklePath
@@ -110,9 +110,9 @@ async function largeInputsOutputs () {
110110
const path = [
111111
[
112112
{ offset: 0, hash: txid, txid: true, duplicate: false },
113-
{ offset: 1, hash: 'otherHash1', txid: false, duplicate: false }
113+
{ offset: 1, hash: 'aa'.repeat(32), txid: false, duplicate: false }
114114
],
115-
[{ offset: 1, hash: 'mergedHash1', txid: false, duplicate: false }]
115+
[{ offset: 1, hash: 'bb'.repeat(32), txid: false, duplicate: false }]
116116
]
117117
const merklePath = new MerklePath(blockHeight, path)
118118
sourceTx.merklePath = merklePath
@@ -158,9 +158,9 @@ async function nestedInputs () {
158158
const path = [
159159
[
160160
{ offset: 0, hash: txid, txid: true, duplicate: false },
161-
{ offset: 1, hash: 'otherHash1', txid: false, duplicate: false }
161+
{ offset: 1, hash: 'aa'.repeat(32), txid: false, duplicate: false }
162162
],
163-
[{ offset: 1, hash: 'mergedHash1', txid: false, duplicate: false }]
163+
[{ offset: 1, hash: 'bb'.repeat(32), txid: false, duplicate: false }]
164164
]
165165
const merklePath = new MerklePath(blockHeight, path)
166166
baseTx.merklePath = merklePath

src/primitives/__tests/utils.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -323,53 +323,35 @@ describe('verifyNotNull', () => {
323323

324324
describe('toUTF8 strict UTF-8 decoding (TOB-21)', () => {
325325

326-
//
327-
// 1. Replacement for invalid 2-byte continuation
328-
//
329326
it('replaces invalid 2-byte sequences with U+FFFD', () => {
330327
// 0xC2 should expect a continuation byte 0x80–0xBF
331328
const arr = [0xC2, 0x20] // 0x20 is INVALID continuation
332329
const str = toUTF8(arr)
333330
expect(str).toBe('\uFFFD')
334331
})
335332

336-
//
337-
// 2. Valid 3-byte UTF-8 (e.g., "€")
338-
//
339333
it('decodes valid 3-byte sequences', () => {
340334
const euro = [0xE2, 0x82, 0xAC]
341335
expect(toUTF8(euro)).toBe('€')
342336
})
343337

344-
//
345-
// 3. Replacement for invalid 3-byte sequence
346-
//
347338
it('replaces invalid 3-byte sequences', () => {
348339
// Middle byte invalid
349340
const arr = [0xE2, 0x20, 0xAC]
350341
expect(toUTF8(arr)).toBe('\uFFFD')
351342
})
352343

353-
//
354-
// 4. Valid 4-byte UTF-8 (e.g., U+1F600 😀)
355-
//
356344
it('decodes valid 4-byte sequences into surrogate pairs', () => {
357345
const smile = [0xF0, 0x9F, 0x98, 0x80] // 😀
358346
expect(toUTF8(smile)).toBe('😀')
359347
})
360348

361-
//
362-
// 5. Replacement for invalid 4-byte sequence
363-
//
364349
it('replaces invalid 4-byte sequences with U+FFFD', () => {
365350
// 0x9F is valid, 0x20 is INVALID continuation for byte 3
366351
const arr = [0xF0, 0x9F, 0x20, 0x80]
367352
expect(toUTF8(arr)).toBe('\uFFFD')
368353
})
369354

370-
//
371-
// 6. Replacement of incomplete sequences at end of array
372-
//
373355
it('replaces incomplete UTF-8 sequence at end', () => {
374356
const arr = [0xE2] // incomplete 3-byte seq
375357
expect(toUTF8(arr)).toBe('\uFFFD')

0 commit comments

Comments
 (0)