mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-22 01:02:01 -07:00
Import the browser-safe buffer module in the multi-push adapter so the CRA production bundle no longer reads the Node global Buffer, add regression tests for the falsy-wallet and idempotent-attach paths, share the script-encoding test helper, and de-duplicate the UTF-8 push acceptance assertions. Refresh the language mutation manifests and the soft acceptance-mutation manifest. By architect.
21 lines
579 B
JavaScript
21 lines
579 B
JavaScript
/*
|
|
Test helper: encode a script the way Bitcoin does.
|
|
|
|
An opcode number is one byte; a Buffer/string becomes a length-prefixed push.
|
|
Enough to observe that the multi-push adapter produced the expected pushes.
|
|
Shared by the memo-multipush unit and property tests.
|
|
*/
|
|
|
|
'use strict'
|
|
|
|
function encodeScript (script) {
|
|
const parts = script.map((el) => {
|
|
if (typeof el === 'number') return Buffer.from([el])
|
|
const buf = Buffer.from(el)
|
|
return Buffer.concat([Buffer.from([buf.length]), buf])
|
|
})
|
|
return Buffer.concat(parts)
|
|
}
|
|
|
|
module.exports = { encodeScript }
|