aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/README.md2
-rw-r--r--tests/core_tests/chaingen.cpp2
-rw-r--r--tests/functional_tests/CMakeLists.txt4
-rwxr-xr-xtests/functional_tests/functional_tests_rpc.py4
-rwxr-xr-xtests/functional_tests/txpool.py20
-rw-r--r--tests/trezor/trezor_tests.cpp94
-rw-r--r--tests/trezor/trezor_tests.h17
7 files changed, 121 insertions, 22 deletions
diff --git a/tests/README.md b/tests/README.md
index 908482c99..c63294e9b 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -54,7 +54,7 @@ Functional tests are located under the `tests/functional_tests` directory.
Building all the tests requires installing the following dependencies:
```bash
-pip install requests psutil monotonic
+pip install requests psutil monotonic zmq
```
First, run a regtest daemon in the offline mode and with a fixed difficulty:
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index 144e87bc2..9bcae19d0 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -661,7 +661,7 @@ void block_tracker::process(const block* blk, const transaction * tx, size_t i)
for (size_t j = 0; j < tx->vout.size(); ++j) {
const tx_out &out = tx->vout[j];
- if (typeid(cryptonote::txout_to_key) != out.target.type()) { // out_to_key
+ if (typeid(cryptonote::txout_to_key) != out.target.type() && typeid(cryptonote::txout_to_tagged_key) != out.target.type()) {
continue;
}
diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt
index 5511cab1c..f7747b515 100644
--- a/tests/functional_tests/CMakeLists.txt
+++ b/tests/functional_tests/CMakeLists.txt
@@ -67,7 +67,7 @@ target_link_libraries(make_test_signature
monero_add_minimal_executable(cpu_power_test cpu_power_test.cpp)
find_program(PYTHON3_FOUND python3 REQUIRED)
-execute_process(COMMAND ${PYTHON3_FOUND} "-c" "import requests; import psutil; import monotonic; print('OK')" OUTPUT_VARIABLE REQUESTS_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND ${PYTHON3_FOUND} "-c" "import requests; import psutil; import monotonic; import zmq; print('OK')" OUTPUT_VARIABLE REQUESTS_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
if (REQUESTS_OUTPUT STREQUAL "OK")
add_test(
NAME functional_tests_rpc
@@ -76,6 +76,6 @@ if (REQUESTS_OUTPUT STREQUAL "OK")
NAME check_missing_rpc_methods
COMMAND ${PYTHON3_FOUND} "${CMAKE_CURRENT_SOURCE_DIR}/check_missing_rpc_methods.py" "${CMAKE_SOURCE_DIR}")
else()
- message(WARNING "functional_tests_rpc and check_missing_rpc_methods skipped, needs the 'requests', 'psutil' and 'monotonic' python modules")
+ message(WARNING "functional_tests_rpc and check_missing_rpc_methods skipped, needs the 'requests', 'psutil', 'monotonic', and 'zmq' python modules")
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} functional_tests_rpc check_missing_rpc_methods)
endif()
diff --git a/tests/functional_tests/functional_tests_rpc.py b/tests/functional_tests/functional_tests_rpc.py
index 450552cf8..eb8d51f08 100755
--- a/tests/functional_tests/functional_tests_rpc.py
+++ b/tests/functional_tests/functional_tests_rpc.py
@@ -47,7 +47,7 @@ WALLET_DIRECTORY = builddir + "/functional-tests-directory"
FUNCTIONAL_TESTS_DIRECTORY = builddir + "/tests/functional_tests"
DIFFICULTY = 10
-monerod_base = [builddir + "/bin/monerod", "--regtest", "--fixed-difficulty", str(DIFFICULTY), "--no-igd", "--p2p-bind-port", "monerod_p2p_port", "--rpc-bind-port", "monerod_rpc_port", "--zmq-rpc-bind-port", "monerod_zmq_port", "--non-interactive", "--disable-dns-checkpoints", "--check-updates", "disabled", "--rpc-ssl", "disabled", "--data-dir", "monerod_data_dir", "--log-level", "1"]
+monerod_base = [builddir + "/bin/monerod", "--regtest", "--fixed-difficulty", str(DIFFICULTY), "--no-igd", "--p2p-bind-port", "monerod_p2p_port", "--rpc-bind-port", "monerod_rpc_port", "--zmq-rpc-bind-port", "monerod_zmq_port", "--zmq-pub", "monerod_zmq_pub", "--non-interactive", "--disable-dns-checkpoints", "--check-updates", "disabled", "--rpc-ssl", "disabled", "--data-dir", "monerod_data_dir", "--log-level", "1"]
monerod_extra = [
["--offline"],
["--rpc-payment-address", "44SKxxLQw929wRF6BA9paQ1EWFshNnKhXM3qz6Mo3JGDE2YG3xyzVutMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUiqhcwR", "--rpc-payment-difficulty", str(DIFFICULTY), "--rpc-payment-credits", "5000", "--offline"],
@@ -69,7 +69,7 @@ outputs = []
ports = []
for i in range(N_MONERODS):
- command_lines.append([str(18180+i) if x == "monerod_rpc_port" else str(18280+i) if x == "monerod_p2p_port" else str(18380+i) if x == "monerod_zmq_port" else builddir + "/functional-tests-directory/monerod" + str(i) if x == "monerod_data_dir" else x for x in monerod_base])
+ command_lines.append([str(18180+i) if x == "monerod_rpc_port" else str(18280+i) if x == "monerod_p2p_port" else str(18380+i) if x == "monerod_zmq_port" else "tcp://127.0.0.1:" + str(18480+i) if x == "monerod_zmq_pub" else builddir + "/functional-tests-directory/monerod" + str(i) if x == "monerod_data_dir" else x for x in monerod_base])
if i < len(monerod_extra):
command_lines[-1] += monerod_extra[i]
outputs.append(open(FUNCTIONAL_TESTS_DIRECTORY + '/monerod' + str(i) + '.log', 'a+'))
diff --git a/tests/functional_tests/txpool.py b/tests/functional_tests/txpool.py
index e92b5a530..b7f55d04c 100755
--- a/tests/functional_tests/txpool.py
+++ b/tests/functional_tests/txpool.py
@@ -35,6 +35,7 @@ from __future__ import print_function
from framework.daemon import Daemon
from framework.wallet import Wallet
+from framework.zmq import Zmq
class TransferTest():
def run_test(self):
@@ -105,6 +106,10 @@ class TransferTest():
def check_txpool(self):
daemon = Daemon()
wallet = Wallet()
+ zmq = Zmq()
+
+ zmq_topic = "json-minimal-txpool_add"
+ zmq.sub(zmq_topic)
res = daemon.get_info()
height = res.height
@@ -142,6 +147,21 @@ class TransferTest():
min_bytes = min(min_bytes, x.blob_size)
max_bytes = max(max_bytes, x.blob_size)
+ print('Checking all txs received via zmq')
+ for i in range(len(txes.keys())):
+ zmq_event = zmq.recv(zmq_topic)
+ assert len(zmq_event) == 1
+
+ zmq_tx = zmq_event[0]
+
+ x = [x for x in res.transactions if x.id_hash == zmq_tx["id"]]
+ assert len(x) == 1
+
+ x = x[0]
+ assert x.blob_size == zmq_tx["blob_size"]
+ assert x.weight == zmq_tx["weight"]
+ assert x.fee == zmq_tx["fee"]
+
res = daemon.get_transaction_pool_hashes()
assert sorted(res.tx_hashes) == sorted(txes.keys())
diff --git a/tests/trezor/trezor_tests.cpp b/tests/trezor/trezor_tests.cpp
index 0db05760a..0d61610be 100644
--- a/tests/trezor/trezor_tests.cpp
+++ b/tests/trezor/trezor_tests.cpp
@@ -52,7 +52,6 @@ namespace po = boost::program_options;
namespace
{
const command_line::arg_descriptor<std::string> arg_filter = { "filter", "Regular expression filter for which tests to run" };
- const command_line::arg_descriptor<bool> arg_generate_and_play_test_data = {"generate_and_play_test_data", ""};
const command_line::arg_descriptor<std::string> arg_trezor_path = {"trezor_path", "Path to the trezor device to use, has to support debug link", ""};
const command_line::arg_descriptor<bool> arg_heavy_tests = {"heavy_tests", "Runs expensive tests (volume tests with real device)", false};
const command_line::arg_descriptor<std::string> arg_chain_path = {"chain_path", "Path to the serialized blockchain, speeds up testing", ""};
@@ -138,7 +137,7 @@ int main(int argc, char* argv[])
hw::register_device(HW_TREZOR_NAME, ensure_trezor_test_device()); // shim device for call tracking
// Bootstrapping common chain & accounts
- const uint8_t initial_hf = (uint8_t)get_env_long("TEST_MIN_HF", 12);
+ const uint8_t initial_hf = (uint8_t)get_env_long("TEST_MIN_HF", HF_VERSION_CLSAG);
const uint8_t max_hf = (uint8_t)get_env_long("TEST_MAX_HF", HF_VERSION_CLSAG);
auto sync_test = get_env_long("TEST_KI_SYNC", 1);
MINFO("Test versions " << MONERO_RELEASE_NAME << "' (v" << MONERO_VERSION_FULL << ")");
@@ -162,6 +161,10 @@ int main(int argc, char* argv[])
// Transaction tests
for(uint8_t hf=initial_hf; hf <= max_hf + 1; ++hf)
{
+ if (hf == 14) { // HF 14 is skipped.
+ continue;
+ }
+
if (hf > initial_hf || hf > max_hf)
{
daemon->stop_and_deinit();
@@ -201,12 +204,14 @@ int main(int argc, char* argv[])
TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_1norm_2sub, core, trezor_base);
TREZOR_COMMON_TEST_CASE(gen_trezor_2utxo_sub_acc_to_1norm_2sub, core, trezor_base);
TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_7outs, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_4utxo_to_15outs, core, trezor_base);
TREZOR_COMMON_TEST_CASE(wallet_api_tests, core, trezor_base);
}
if (trezor_base.heavy_tests())
{
TREZOR_COMMON_TEST_CASE(gen_trezor_many_utxo, core, trezor_base);
+ TREZOR_COMMON_TEST_CASE(gen_trezor_many_utxo_many_txo, core, trezor_base);
}
core->deinit();
@@ -555,7 +560,7 @@ static void expand_tsx(cryptonote::transaction &tx)
rv.p.MGs[n].II[0] = rct::ki2rct(boost::get<txin_to_key>(tx.vin[n]).k_image);
}
}
- else if (rv.type == rct::RCTTypeCLSAG)
+ else if (rv.type == rct::RCTTypeCLSAG || rv.type == rct::RCTTypeBulletproofPlus)
{
if (!tx.pruned)
{
@@ -1269,6 +1274,8 @@ void gen_trezor_base::set_hard_fork(uint8_t hf)
rct_config({rct::RangeProofPaddedBulletproof, 2});
} else if (hf == HF_VERSION_CLSAG){
rct_config({rct::RangeProofPaddedBulletproof, 3});
+ } else if (hf == HF_VERSION_BULLETPROOF_PLUS){
+ rct_config({rct::RangeProofPaddedBulletproof, 4});
} else {
throw std::runtime_error("Unsupported HF");
}
@@ -1655,7 +1662,7 @@ bool gen_trezor_1utxo::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(boost::none, MK_COINS(1), -1, -1)
@@ -1671,7 +1678,7 @@ bool gen_trezor_1utxo_paymentid_short::generate(std::vector<test_event_entry>& e
TREZOR_TEST_PREFIX();
TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(boost::none, MK_COINS(1), -1, -1)
@@ -1688,7 +1695,7 @@ bool gen_trezor_1utxo_paymentid_short_integrated::generate(std::vector<test_even
TREZOR_TEST_PREFIX();
TREZOR_SKIP_IF_VERSION_LEQ(hw::trezor::pack_version(2, 0, 9));
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(boost::none, MK_COINS(1), -1, -1)
@@ -1705,7 +1712,7 @@ bool gen_trezor_4utxo::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1720,7 +1727,7 @@ bool gen_trezor_4utxo_acc1::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 1)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1735,7 +1742,7 @@ bool gen_trezor_4utxo_to_sub::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1750,7 +1757,7 @@ bool gen_trezor_4utxo_to_2sub::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1766,7 +1773,7 @@ bool gen_trezor_4utxo_to_1norm_2sub::generate(std::vector<test_event_entry>& eve
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1783,7 +1790,7 @@ bool gen_trezor_2utxo_sub_acc_to_1norm_2sub::generate(std::vector<test_event_ent
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources_to_sub_acc(2, MK_COINS(1) >> 2, -1, -1)
@@ -1800,7 +1807,7 @@ bool gen_trezor_4utxo_to_7outs::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(4, MK_COINS(1), -1, -1)
@@ -1817,11 +1824,39 @@ bool gen_trezor_4utxo_to_7outs::generate(std::vector<test_event_entry>& events)
TREZOR_TEST_SUFFIX();
}
+bool gen_trezor_4utxo_to_15outs::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(num_mixin())
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(4, MK_COINS(1), -1, -1)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
+ ->add_destination(m_wl_eve.get(), false, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
bool gen_trezor_many_utxo::generate(std::vector<test_event_entry>& events)
{
TREZOR_TEST_PREFIX();
t_builder->cur_height(num_blocks(events) - 1)
- ->mixin(TREZOR_TEST_MIXIN)
+ ->mixin(num_mixin())
->fee(TREZOR_TEST_FEE)
->from(m_wl_alice.get(), 0)
->compute_sources(110, MK_COINS(1), -1, -1)
@@ -1832,6 +1867,35 @@ bool gen_trezor_many_utxo::generate(std::vector<test_event_entry>& events)
TREZOR_TEST_SUFFIX();
}
+bool gen_trezor_many_utxo_many_txo::generate(std::vector<test_event_entry>& events)
+{
+ TREZOR_TEST_PREFIX();
+ t_builder->cur_height(num_blocks(events) - 1)
+ ->mixin(num_mixin())
+ ->fee(TREZOR_TEST_FEE)
+ ->from(m_wl_alice.get(), 0)
+ ->compute_sources(40, MK_COINS(1), -1, -1)
+ ->add_destination(m_eve_account, false, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 4}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({1, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 1}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 2}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({0, 3}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({1, 4}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({2, 4}), true, 1000)
+ ->add_destination(m_wl_eve->get_subaddress({3, 4}), true, 1000)
+ ->rct_config(m_rct_config)
+ ->build_tx();
+
+ TREZOR_TEST_SUFFIX();
+}
+
void wallet_api_tests::init()
{
m_wallet_dir = boost::filesystem::unique_path();
@@ -1873,7 +1937,7 @@ bool wallet_api_tests::generate(std::vector<test_event_entry>& events)
Monero::PendingTransaction * transaction = w->createTransaction(recepient_address,
"",
MK_COINS(10),
- TREZOR_TEST_MIXIN,
+ num_mixin(),
Monero::PendingTransaction::Priority_Medium,
0,
std::set<uint32_t>{});
diff --git a/tests/trezor/trezor_tests.h b/tests/trezor/trezor_tests.h
index 2953cc2bd..f7684da12 100644
--- a/tests/trezor/trezor_tests.h
+++ b/tests/trezor/trezor_tests.h
@@ -37,7 +37,9 @@
#include "../core_tests/wallet_tools.h"
#define TREZOR_TEST_FEE 90000000000
-#define TREZOR_TEST_MIXIN 11
+#define TREZOR_TEST_CLSAG_MIXIN 11
+#define TREZOR_TEST_HF15_MIXIN 16
+#define TREZOR_TEST_MIXIN TREZOR_TEST_CLSAG_MIXIN
/************************************************************************/
/* */
@@ -93,6 +95,7 @@ public:
bool heavy_tests() const { return m_heavy_tests; }
void rct_config(rct::RCTConfig rct_config) { m_rct_config = rct_config; }
uint8_t cur_hf() const { return m_hard_forks.size() > 0 ? m_hard_forks.back().first : 0; }
+ size_t num_mixin() const { return m_top_hard_fork >= HF_VERSION_BULLETPROOF_PLUS ? TREZOR_TEST_HF15_MIXIN : TREZOR_TEST_CLSAG_MIXIN; }
cryptonote::network_type nettype() const { return m_network_type; }
std::shared_ptr<mock_daemon> daemon() const { return m_daemon; }
void daemon(std::shared_ptr<mock_daemon> daemon){ m_daemon = std::move(daemon); }
@@ -306,12 +309,24 @@ public:
bool generate(std::vector<test_event_entry>& events) override;
};
+class gen_trezor_4utxo_to_15outs : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
class gen_trezor_many_utxo : public gen_trezor_base
{
public:
bool generate(std::vector<test_event_entry>& events) override;
};
+class gen_trezor_many_utxo_many_txo : public gen_trezor_base
+{
+public:
+ bool generate(std::vector<test_event_entry>& events) override;
+};
+
// Wallet::API tests
class wallet_api_tests : public gen_trezor_base
{