Skip to content

Commit cfc10a5

Browse files
authored
Merge pull request #1232 from delta1/script-assets-test
test: re-enable and fix script assets test
2 parents de94251 + 5cbd44f commit cfc10a5

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

ci/test/04_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ DOCKER_EXEC df -h
8686

8787
if [ "$RUN_FUZZ_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
8888
if [ ! -d ${DIR_QA_ASSETS} ]; then
89-
DOCKER_EXEC git clone --depth=1 https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
89+
DOCKER_EXEC git clone --depth=1 https://github.com/ElementsProject/qa-assets ${DIR_QA_ASSETS}
9090
fi
9191

9292
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/

src/test/script_tests.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ static void AssetTest(const UniValue& test)
16841684
size_t idx = test["index"].get_int64();
16851685
unsigned int test_flags = ParseScriptFlags(test["flags"].get_str());
16861686
bool fin = test.exists("final") && test["final"].get_bool();
1687-
// ELEMENTS FIXME: update feature_taproot.py --dumptests to actually output these
1687+
// ELEMENTS: feature_taproot.py --dumptests outputs this field
16881688
uint256 hash_genesis_block = test.exists("hash_genesis_block") ? uint256S(test["hash_genesis_block"].get_str()) : uint256{};
16891689

16901690
if (test.exists("success")) {
@@ -1725,6 +1725,8 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
17251725
{
17261726
// See src/test/fuzz/script_assets_test_minimizer.cpp for information on how to generate
17271727
// the script_assets_test.json file used by this test.
1728+
// ELEMENTS: qa-assets repo can be cloned here https://github.com/ElementsProject/qa-assets
1729+
// then set DIR_UNIT_TEST_DATA env var to /path/to/qa-assets/unit_test_data when running this test
17281730

17291731
const char* dir = std::getenv("DIR_UNIT_TEST_DATA");
17301732
BOOST_WARN_MESSAGE(dir != nullptr, "Variable DIR_UNIT_TEST_DATA unset, skipping script_assets_test");
@@ -1744,12 +1746,11 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
17441746
BOOST_CHECK(tests.isArray());
17451747
BOOST_CHECK(tests.size() > 0);
17461748

1747-
/*
1748-
ELEMENTS: temporarily disabled until we implement the new Taproot sighash and upload new qa-assets
1749+
g_con_elementsmode = true;
17491750
for (size_t i = 0; i < tests.size(); i++) {
17501751
AssetTest(tests[i]);
17511752
}
1752-
*/
1753+
g_con_elementsmode = false;
17531754
file.close();
17541755
}
17551756

test/functional/feature_taproot.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CTxOut,
2222
CTxOutValue,
2323
CTxOutWitness,
24+
ser_uint256,
2425
uint256_from_str,
2526
)
2627
from test_framework.script import (
@@ -1179,12 +1180,15 @@ def dump_json_test(tx, input_utxos, idx, success, failure):
11791180
# Determine flags to dump
11801181
flags = LEGACY_FLAGS if spender.comment.startswith("legacy/") or spender.comment.startswith("inactive/") else TAPROOT_FLAGS
11811182

1183+
hash_genesis_block = bytearray(ser_uint256(g_genesis_hash))
1184+
hash_genesis_block.reverse()
11821185
fields = [
11831186
("tx", tx.serialize().hex()),
11841187
("prevouts", [x.output.serialize().hex() for x in input_utxos]),
11851188
("index", idx),
11861189
("flags", flags),
1187-
("comment", spender.comment)
1190+
("comment", spender.comment),
1191+
("hash_genesis_block", hash_genesis_block.hex())
11881192
]
11891193

11901194
# The "final" field indicates that a spend should be always valid, even with more validation flags enabled

0 commit comments

Comments
 (0)