From a0fc0764763329df2c4b11a4e22715ccfc0cf7d3 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Fri, 18 Oct 2019 02:05:05 +0200 Subject: [PATCH] refactor: test/bench: dedup Build{Crediting,Spending}Transaction() prototypes used in src/test/script_tests.cpp: - CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue = 0); - CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit); prototypes used in bench/verify_script.cpp: - CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey); - CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMutableTransaction& txCredit); The more generic versions from the script tests are moved into a new file pair transaction_utils.cpp/h and the calls are adapted accordingly in the verify_script benchmark (passing the nValue of 1 explicitely for BuildCreditingTransaction(), passing empty scriptWitness explicitely and converting txCredit parameter to CTransaction in BuildSpendingTransaction()). --- build_msvc/test_bitcoin/test_bitcoin.vcxproj | 1 + src/Makefile.bench.include | 2 + src/Makefile.test.include | 2 + src/bench/verify_script.cpp | 40 ++------------------ src/test/lib/transaction_utils.cpp | 39 +++++++++++++++++++ src/test/lib/transaction_utils.h | 19 ++++++++++ src/test/script_tests.cpp | 35 +---------------- 7 files changed, 67 insertions(+), 71 deletions(-) create mode 100644 src/test/lib/transaction_utils.cpp create mode 100644 src/test/lib/transaction_utils.h diff --git a/build_msvc/test_bitcoin/test_bitcoin.vcxproj b/build_msvc/test_bitcoin/test_bitcoin.vcxproj index 47e87b59e..703f616f8 100644 --- a/build_msvc/test_bitcoin/test_bitcoin.vcxproj +++ b/build_msvc/test_bitcoin/test_bitcoin.vcxproj @@ -13,6 +13,7 @@ + diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index e421b377a..38143e32b 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -39,6 +39,8 @@ bench_bench_bitcoin_SOURCES = \ bench/lockedpool.cpp \ bench/poly1305.cpp \ bench/prevector.cpp \ + test/lib/transaction_utils.h \ + test/lib/transaction_utils.cpp \ test/setup_common.h \ test/setup_common.cpp \ test/util.h \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 7292ca078..3af55d9da 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -53,6 +53,8 @@ RAW_TEST_FILES = GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h) BITCOIN_TEST_SUITE = \ + test/lib/transaction_utils.h \ + test/lib/transaction_utils.cpp \ test/main.cpp \ test/setup_common.h \ test/setup_common.cpp diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp index 4891c57b3..c9947f192 100644 --- a/src/bench/verify_script.cpp +++ b/src/bench/verify_script.cpp @@ -10,44 +10,10 @@ #include