mirror of
https://github.com/monero-project/monero.git
synced 2025-07-24 18:15:24 -04:00
Merge pull request #8427
1fc60ca
Publish submitted txs via zmq (j-berman)
This commit is contained in:
commit
ce80747c58
10 changed files with 142 additions and 11 deletions
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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+'))
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue