Skip to content

Commit cea3f0f

Browse files
committed
Reclassify and extend VMB tests for 2026 proposals
1 parent 489cac0 commit cea3f0f

2,400 files changed

Lines changed: 369728 additions & 123779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bitauth/libauth': patch
3+
---
4+
5+
Rename `nonP2SH` to `P2S`

.changeset/kind-drinks-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bitauth/libauth': minor
3+
---
4+
5+
Reclassify existing VMB tests for 2026 proposals, add additional tests

.changeset/plenty-frogs-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bitauth/libauth': minor
3+
---
4+
5+
Add `elideWordsAndHexAtLength`

.changeset/rare-carrots-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bitauth/libauth': minor
3+
---
4+
5+
`yarn gen:vmb-tests` watch mode: rebuild only the modified file

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ src/lib/vmb-tests/export
1717
src/lib/vmb-tests/generated/.vmb-*
1818
src/lib/vmb-tests/generated/**/*bench.csv
1919
src/lib/vmb-tests/generated/bch_chip_*
20+
.DS_Store
2021

2122
src/lib/bin/**/*.html
2223
src/lib/bin/**/*.js

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"bchn:cmake": "cd wasm/bitcoin-cash-node/build && cmake -GNinja .. -DBUILD_BITCOIN_WALLET=OFF -DBUILD_BITCOIN_QT=OFF -DENABLE_NATPMP=OFF -DENABLE_MAN=OFF -DCMAKE_BUILD_TYPE=Release",
4545
"bchn:build": "cd wasm/bitcoin-cash-node/build && ninja",
4646
"bchn:setup": "cd wasm/bitcoin-cash-node && mkdir build && yarn bchn:cmake && yarn bchn:build",
47-
"bchn:remove-old-vmb-tests": "rm -r wasm/bitcoin-cash-node/src/test/data/vmb_tests/bch_{2023,2025}_{invalid,nonstandard,standard} && echo 'Removed old VMB tests from: wasm/bitcoin-cash-node/src/test/data/vmb_tests'",
48-
"bchn:add-new-vmb-tests": "cp -r src/lib/vmb-tests/generated/* wasm/bitcoin-cash-node/src/test/data/vmb_tests && echo 'Added new VMB tests.'",
47+
"bchn:remove-old-vmb-tests": "rm -r wasm/bitcoin-cash-node/src/test/data/vmb_tests/bch_{2023,2025,2026}_{invalid,nonstandard,standard} && echo 'Removed old VMB tests from: wasm/bitcoin-cash-node/src/test/data/vmb_tests'",
48+
"bchn:add-new-vmb-tests": "cp -r src/lib/vmb-tests/generated/bch_{2023,2025,2026}_{invalid,nonstandard,standard} wasm/bitcoin-cash-node/src/test/data/vmb_tests && echo 'Added new VMB tests.'",
4949
"bchn:replace-vmb-tests": "yarn bchn:remove-old-vmb-tests && yarn bchn:add-new-vmb-tests",
5050
"bchn:run-tests": "cd wasm/bitcoin-cash-node/build && echo 'Building BCHN tests...' && ninja test_bitcoin && echo 'Running VMB tests in BCHN...' && src/test/test_bitcoin -t libauth_tests",
5151
"bchn:check-vmb-tests": "yarn bchn:cmake && yarn bchn:build && yarn bchn:run-tests",

src/lib/address/cash-address.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ test('encodeCashAddressFormat: works', (t) => {
163163
});
164164

165165
test('encodeCashAddress: works', (t) => {
166+
/**
167+
* From `f85d4bd8a03ca106c9deb47b791803dac7f0333809e3f1dd04d182e0aba6e553`
168+
*/
166169
const payload = hexToBin('15d16c84669ab46059313bf0747e781f1d13936d');
167170
t.deepEqual(
168171
encodeCashAddress({

src/lib/engine/types/bcmr-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ export type IdentitySnapshot = {
584584
* The split ID of this identity's chain of record.
585585
*
586586
* If undefined, defaults to {@link MetadataRegistry.defaultChain}.
587+
*
588+
* TODO: rename "splitId" to "chainBranchId" (more clearly refers to the immediate descendent of the split block)
587589
*/
588590
splitId?: string;
589591

src/lib/format/log.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ test('stringifyTestVector', (t) => {
8181
one,
8282
);
8383
});
84+
85+
test.todo('elideWordsAtLength');

src/lib/format/log.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,37 @@ export const stringifyTestVector = (
114114
.replace(uint8ArrayRegex, "hexToBin('$1')")
115115
.replace(bigIntRegex, '$1n');
116116
};
117+
118+
/**
119+
* Elide words and hex strings in the given `text` at `maxLength`. Max length
120+
* defaults to `148`, the maximum hex-encoded length (with `0x` prefix) of most
121+
* ECDSA signatures.
122+
*
123+
* Hex strings include a count of total bytes, e.g.
124+
* `0x01 … (512 total bytes) … 10101`. (Note that the surrounding spacing
125+
* decreases the incidences of line breaks within the message.)
126+
*
127+
* @param text - the text to process
128+
* @param maxLength - the maximum length of each word in the resulting text
129+
* @returns
130+
*/
131+
export const elideWordsAndHexAtLength = (
132+
text: string,
133+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
134+
maxLength = 148,
135+
) =>
136+
text.replace(/\S+/gu, (w) => {
137+
if (w.length < maxLength) return w;
138+
const prefix = '0x'.length;
139+
const byte = 2;
140+
const match = /^(?:<)?(?<hex>0x[0-9A-Fa-f]+)(?:>)?$/gu.exec(w);
141+
const middle = match
142+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
143+
` … (${(match.groups!['hex']!.length - prefix) / byte} total bytes) … `
144+
: '…';
145+
const keep = maxLength - middle.length;
146+
const half = 2;
147+
const front = Math.floor(keep / half);
148+
const back = keep - front;
149+
return `${w.slice(0, front)}${middle}${w.slice(w.length - back)}`;
150+
});

0 commit comments

Comments
 (0)