Page MenuHomePhabricator

[Chronik] Add `SlpScript` Python helper for functional tests
ClosedPublic

Authored by tobias_ruck on Jan 15 2024, 15:37.

Details

Summary

SLP requires us to encode Scripts differently than CScript currently does.

SLP forbids encoding the empty bytestring with OP_0, but CScript encodes it this way. Therefore, we add SlpScript, which encodes b"" as b"\x4c\x00".

We rename __coerce_instance to _coerce_instance, as it prevents us from overriding the function. __prefix is intended to have a "private" scope, and _prefix a "protected" scope, and to override a method in a subclass we need the latter.

Test Plan

python -m unittest test_framework.chronik.script

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-test-framework-slp-script
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26367
Build 52304: Build Diffbuild-without-wallet · build-clang-tidy · build-clang · build-diff · build-debug
Build 52303: arc lint + arc unit

Event Timeline

Fabien requested changes to this revision.Jan 15 2024, 20:02
Fabien added inline comments.
test/functional/test_framework/chronik/slp.py
31 ↗(On Diff #44192)

Please also check with int: self.assertEqual(SlpScript([0]), b"\x4c\x00")

This revision now requires changes to proceed.Jan 15 2024, 20:02

Also handle number -1 to 16 and add some tests

Use < instead of <= for clarity

This revision is now accepted and ready to land.Jan 15 2024, 21:05