Skip to content

Commit

Permalink
Merge #20180: test: Fix -Wunused-function warnings if configured --wi…
Browse files Browse the repository at this point in the history
…thout-libs

76bbcc4 test: Fix -Wunused-function warning if configured --without-libs (Hennadii Stepanov)

Pull request description:

  On master (80c8a02) compiling with gcc:
  ```
  $ ./configure --without-libs
  $ make clean && make
  ...
  test/script_tests.cpp:1369:23: warning: ‘CScriptWitness script_tests::ScriptWitnessFromJSON(const UniValue&)’ defined but not used [-Wunused-function]
   1369 | static CScriptWitness ScriptWitnessFromJSON(const UniValue& univalue)
        |                       ^~~~~~~~~~~~~~~~~~~~~
  test/script_tests.cpp:1357:28: warning: ‘std::vector<CTxOut> script_tests::TxOutsFromJSON(const UniValue&)’ defined but not used [-Wunused-function]
   1357 | static std::vector<CTxOut> TxOutsFromJSON(const UniValue& univalue)
        |                            ^~~~~~~~~~~~~~
  test/script_tests.cpp:1350:28: warning: ‘CMutableTransaction script_tests::TxFromHex(const string&)’ defined but not used [-Wunused-function]
   1350 | static CMutableTransaction TxFromHex(const std::string& str)
        |                            ^~~~~~~~~
  ...
  ```

  This change is move-only (nice to review with `git diff --color-moved`).

ACKs for top commit:
  practicalswift:
    ACK 76bbcc4: diff looks correct
  fanquake:
    ACK 76bbcc4 - verified that this fixes the warnings. As mentioned can be reviewed with `git diff HEAD~ --color-moved=dimmed_zebra`.

Tree-SHA512: 7799ac190d1e3f15e38b36cfcd1f8d138be80cab6c6cfad8f7828e07deffc2037d52f1d967f7f233a3a8ed74eee184f5275076c2f364c3e363c77a1f40aa5030
  • Loading branch information
MarcoFalke committed Oct 19, 2020
2 parents 62af467 + 76bbcc4 commit 152ddb3
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,36 +1347,6 @@ static CScript ScriptFromHex(const std::string& str)
return CScript(data.begin(), data.end());
}

static CMutableTransaction TxFromHex(const std::string& str)
{
CMutableTransaction tx;
VectorReader(SER_DISK, SERIALIZE_TRANSACTION_NO_WITNESS, ParseHex(str), 0) >> tx;
return tx;
}

static std::vector<CTxOut> TxOutsFromJSON(const UniValue& univalue)
{
assert(univalue.isArray());
std::vector<CTxOut> prevouts;
for (size_t i = 0; i < univalue.size(); ++i) {
CTxOut txout;
VectorReader(SER_DISK, 0, ParseHex(univalue[i].get_str()), 0) >> txout;
prevouts.push_back(std::move(txout));
}
return prevouts;
}

static CScriptWitness ScriptWitnessFromJSON(const UniValue& univalue)
{
assert(univalue.isArray());
CScriptWitness scriptwitness;
for (size_t i = 0; i < univalue.size(); ++i) {
auto bytes = ParseHex(univalue[i].get_str());
scriptwitness.stack.push_back(std::move(bytes));
}
return scriptwitness;
}

BOOST_AUTO_TEST_CASE(script_FindAndDelete)
{
// Exercise the FindAndDelete functionality
Expand Down Expand Up @@ -1502,6 +1472,36 @@ BOOST_AUTO_TEST_CASE(script_HasValidOps)

#if defined(HAVE_CONSENSUS_LIB)

static CMutableTransaction TxFromHex(const std::string& str)
{
CMutableTransaction tx;
VectorReader(SER_DISK, SERIALIZE_TRANSACTION_NO_WITNESS, ParseHex(str), 0) >> tx;
return tx;
}

static std::vector<CTxOut> TxOutsFromJSON(const UniValue& univalue)
{
assert(univalue.isArray());
std::vector<CTxOut> prevouts;
for (size_t i = 0; i < univalue.size(); ++i) {
CTxOut txout;
VectorReader(SER_DISK, 0, ParseHex(univalue[i].get_str()), 0) >> txout;
prevouts.push_back(std::move(txout));
}
return prevouts;
}

static CScriptWitness ScriptWitnessFromJSON(const UniValue& univalue)
{
assert(univalue.isArray());
CScriptWitness scriptwitness;
for (size_t i = 0; i < univalue.size(); ++i) {
auto bytes = ParseHex(univalue[i].get_str());
scriptwitness.stack.push_back(std::move(bytes));
}
return scriptwitness;
}

/* Test simple (successful) usage of bitcoinconsensus_verify_script */
BOOST_AUTO_TEST_CASE(bitcoinconsensus_verify_script_returns_true)
{
Expand Down

0 comments on commit 152ddb3

Please sign in to comment.