Skip to content

Commit

Permalink
tests, fuzz: use new NUMS_H const
Browse files Browse the repository at this point in the history
  • Loading branch information
josibake committed May 14, 2024
1 parent 91a8047 commit e9dfa28
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/test/fuzz/miniscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,6 @@ const struct KeyComparator {
// A dummy scriptsig to pass to VerifyScript (we always use Segwit v0).
const CScript DUMMY_SCRIPTSIG;

//! Public key to be used as internal key for dummy Taproot spends.
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};

//! Construct a miniscript node as a shared_ptr.
template<typename... Args> NodeRef MakeNodeRef(Args&&... args) {
return miniscript::MakeNodeRef<CPubKey>(miniscript::internal::NoDupCheck{}, std::forward<Args>(args)...);
Expand Down Expand Up @@ -1018,7 +1015,7 @@ CScript ScriptPubKey(MsCtx ctx, const CScript& script, TaprootBuilder& builder)

// For Taproot outputs we always use a tree with a single script and a dummy internal key.
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
builder.Finalize(XOnlyPubKey{NUMS_PK});
builder.Finalize(XOnlyPubKey::NUMS_H);
return GetScriptForDestination(builder.GetOutput());
}

Expand Down
5 changes: 1 addition & 4 deletions src/test/miniscript_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ class TestSignatureChecker : public BaseSignatureChecker {
}
};

//! Public key to be used as internal key for dummy Taproot spends.
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};

using Fragment = miniscript::Fragment;
using NodeRef = miniscript::NodeRef<CPubKey>;
using miniscript::operator"" _mst;
Expand Down Expand Up @@ -330,7 +327,7 @@ CScript ScriptPubKey(miniscript::MiniscriptContext ctx, const CScript& script, T

// For Taproot outputs we always use a tree with a single script and a dummy internal key.
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
builder.Finalize(XOnlyPubKey{NUMS_PK});
builder.Finalize(XOnlyPubKey::NUMS_H);
return GetScriptForDestination(builder.GetOutput());
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,7 @@ BOOST_AUTO_TEST_CASE(sign_invalid_miniscript)
const auto invalid_pubkey{ParseHex("173d36c8c9c9c9ffffffffffff0200000000021e1e37373721361818181818181e1e1e1e19000000000000000000b19292929292926b006c9b9b9292")};
TaprootBuilder builder;
builder.Add(0, {invalid_pubkey}, 0xc0);
XOnlyPubKey nums{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
builder.Finalize(nums);
builder.Finalize(XOnlyPubKey::NUMS_H);
prev.vout.emplace_back(0, GetScriptForDestination(builder.GetOutput()));
curr.vin.emplace_back(COutPoint{prev.GetHash(), 0});
sig_data.tr_spenddata = builder.GetSpendData();
Expand Down

0 comments on commit e9dfa28

Please sign in to comment.