Page MenuHomePhabricator

[ecash-script] Add util function swapEndianness
ClosedPublic

Authored by bytesofman on Jun 6 2023, 21:24.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCdbf24d31c5bd: [ecash-script] Add util function swapEndianness
Summary

Add new function swapEndianness

Use this in consumeNextPush in place of manual implementation. Export function for developer use.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
add-tobigendian
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23941
Build 47492: Build Diff
Build 47491: arc lint + arc unit

Event Timeline

bytesofman retitled this revision from [ecash-script] Add util function toBigEndianHexString to [ecash-script] Add util function swapEndianness.Jun 6 2023, 21:25
Fabien requested changes to this revision.Jun 7 2023, 12:35
Fabien added a subscriber: Fabien.
Fabien added inline comments.
modules/ecash-script/src/utils.js
23 ↗(On Diff #40631)

You're never checking it's an hex string, only that it's a string of even length.

28 ↗(On Diff #40631)

There is no bigEndianHexString

31 ↗(On Diff #40631)

dito

modules/ecash-script/test/utils.js
31 ↗(On Diff #40631)

Please also generate some random numbers and make sure that number == swapEndianness(swapEndianness(number)) (the whole roundtrip)

This revision now requires changes to proceed.Jun 7 2023, 12:35
bytesofman marked 3 inline comments as done.

Better tests, remove commenting errors, validate for hex string

This revision is now accepted and ready to land.Jun 7 2023, 18:10