MCPcopy Create free account
hub / github.com/ElementsProject/elements / bitflipper

Function bitflipper

test/functional/feature_taproot.py:634–640  ·  view source on GitHub ↗

Return a callable that evaluates expr and returns it with a random bitflip.

(expr)

Source from the content-addressed store, hash-verified

632 return bytes(random.getrandbits(8) for i in range(n))
633
634def bitflipper(expr):
635 """Return a callable that evaluates expr and returns it with a random bitflip."""
636 def fn(ctx):
637 sub = deep_eval(ctx, expr)
638 assert isinstance(sub, bytes)
639 return (int.from_bytes(sub, 'little') ^ (1 << random.randrange(len(sub) * 8))).to_bytes(len(sub), 'little')
640 return fn
641
642def zero_appender(expr):
643 """Return a callable that evaluates expr and returns it with a zero added."""

Callers 3

feature_taproot.pyFile · 0.85
spenders_taproot_activeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected