Skip to content

Commit

Permalink
WIP: Simplicity Functional Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
roconnor-blockstream committed Mar 10, 2023
1 parent 6afcf01 commit acf8f90
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/functional/feature_taproot.py
Expand Up @@ -291,6 +291,8 @@ def default_witness_taproot(ctx):
suffix_annex = [annex]
if get(ctx, "leaf") is None:
return get(ctx, "inputs_keypath") + suffix_annex
elif get(ctx, "leafversion") == LEAF_VERSION_TAPSIMPLICITY:
return [bytes(get(ctx, "simplicity_program")), bytes(get(ctx, "script_taproot")), get(ctx, "controlblock")] + suffix_annex
else:
return get(ctx, "inputs") + [bytes(get(ctx, "script_taproot")), get(ctx, "controlblock")] + suffix_annex

Expand Down Expand Up @@ -357,6 +359,8 @@ def default_scriptsig(ctx):
"tapleaf": default_tapleaf,
# The script to push, and include in the sighash, for a taproot script path spend.
"script_taproot": default_script_taproot,
# The simplicity program for a taproot simplicity spend.
"simplicity_program": [],
# The internal pubkey for a taproot script path spend (32 bytes).
"pubkey_internal": default_pubkey_internal,
# The negation flag of the internal pubkey for a taproot script path spend.
Expand Down Expand Up @@ -1115,6 +1119,11 @@ def predict_sigops_ratio(n, dummy_size):
tap = taproot_construct(pubs[0], scripts)
add_spender(spenders, "alwaysvalid/notsuccessx", tap=tap, leaf="op_success", inputs=[], standard=False, failure={"leaf": "normal"}) # err_msg differs based on opcode

# == Simplicity tests ==

tap = taproot_construct(pubs[0], [("simplicity_iden", bytes.fromhex("dbfefcfc7796acfc86b435c1f81ed8a165dab2649dc48b0f35f832647868fb5e"), LEAF_VERSION_TAPSIMPLICITY)])
add_spender(spenders, "simplicity/iden", tap=tap, leaf="simplicity_iden", simplicity_program=bytes.fromhex("20"), failure={"simplicity_program": bitflipper(bytes.fromhex("20"))}, **ERR_NO_SUCCESS)

# == Legacy tests ==

# Also add a few legacy spends into the mix, so that transactions which combine taproot and pre-taproot spends get tested too.
Expand Down

0 comments on commit acf8f90

Please sign in to comment.