From a0fc0764763329df2c4b11a4e22715ccfc0cf7d3 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Fri, 18 Oct 2019 02:05:05 +0200 Subject: 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()). --- 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 +-------------------------------- 6 files changed, 66 insertions(+), 71 deletions(-) create mode 100644 src/test/lib/transaction_utils.cpp create mode 100644 src/test/lib/transaction_utils.h (limited to 'src') diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index e421b377a0..38143e32b9 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 7292ca0784..3af55d9dab 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 4891c57b3a..c9947f192e 100644 --- a/src/bench/verify_script.cpp +++ b/src/bench/verify_script.cpp @@ -10,44 +10,10 @@ #include