Skip to content

Commit bdc849f

Browse files
Add multiple txs tests
* Implement ToMultipleTxSender * Wallet rpc and model fixes * Refactory integration test utils * Implement other rpc wallet tests
1 parent 703980f commit bdc849f

35 files changed

Lines changed: 1954 additions & 521 deletions

src/cpp/wallet/py_monero_wallet_model.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ void PyMoneroTxWallet::from_property_tree_with_output(const boost::property_tree
519519
tx->m_is_confirmed = true;
520520
tx->m_is_relayed = true;
521521
tx->m_is_failed = false;
522+
tx->m_in_tx_pool = false;
522523

523524
auto output = std::make_shared<monero::monero_output_wallet>();
524525
auto key_image = std::make_shared<monero::monero_key_image>();
@@ -1743,13 +1744,15 @@ rapidjson::Value PyMoneroGetTransfersParams::to_rapidjson_val(rapidjson::Documen
17431744
rapidjson::Value root(rapidjson::kObjectType);
17441745
rapidjson::Value value_num(rapidjson::kNumberType);
17451746
rapidjson::Value value_str(rapidjson::kStringType);
1747+
bool filter_by_height = m_min_height != boost::none || m_max_height != boost::none;
1748+
monero_utils::add_json_member("filter_by_height", filter_by_height, allocator, root);
17461749
if (m_in != boost::none) monero_utils::add_json_member("in", m_in.get(), allocator, root);
17471750
if (m_out != boost::none) monero_utils::add_json_member("out", m_out.get(), allocator, root);
17481751
if (m_pool != boost::none) monero_utils::add_json_member("pool", m_pool.get(), allocator, root);
17491752
if (m_pending != boost::none) monero_utils::add_json_member("pending", m_pending.get(), allocator, root);
17501753
if (m_failed != boost::none) monero_utils::add_json_member("failed", m_failed.get(), allocator, root);
1751-
if (m_min_height != boost::none) monero_utils::add_json_member("min_height", m_min_height.get(), allocator, root);
1752-
if (m_max_height != boost::none) monero_utils::add_json_member("max_height", m_max_height.get(), allocator, root);
1754+
if (m_min_height != boost::none) monero_utils::add_json_member("min_height", m_min_height.get(), allocator, root, value_num);
1755+
if (m_max_height != boost::none) monero_utils::add_json_member("max_height", m_max_height.get(), allocator, root, value_num);
17531756
if (m_all_accounts != boost::none) monero_utils::add_json_member("all_accounts", m_all_accounts.get(), allocator, root);
17541757
if (m_account_index != boost::none) monero_utils::add_json_member("account_index", m_account_index.get(), allocator, root, value_num);
17551758
if (!m_subaddr_indices.empty()) root.AddMember("subaddr_indices", monero_utils::to_rapidjson_val(allocator, m_subaddr_indices), allocator);

src/cpp/wallet/py_monero_wallet_rpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ std::string PyMoneroWalletRpc::get_address(const uint32_t account_idx, const uin
436436
auto it3 = m_address_cache.find(account_idx);
437437
if (it3 == m_address_cache.end()) throw std::runtime_error("Could not find account address at index (" + std::to_string(account_idx) + ", " + std::to_string(subaddress_idx) + ")" );
438438
auto it4 = it3->second.find(subaddress_idx);
439-
if (it4 == it3->second.end()) throw std::runtime_error("Could not find address at index (" + std::to_string(account_idx) + ", " + std::to_string(subaddress_idx) + ")" );
439+
if (it4 == it3->second.end()) return std::string("");
440440
return it4->second;
441441
}
442442

src/python/monero_output_query.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class MoneroOutputQuery(MoneroOutputWallet):
1717
"""Filter outputs below this amount."""
1818
subaddress_indices: list[int]
1919
"""Subadress indices to select (empty for all)."""
20-
tx_query: MoneroTxQuery | None
21-
"""Related transaction query."""
20+
@property
21+
def tx_query(self) -> MoneroTxQuery | None:
22+
"""Related transaction query."""
23+
...
2224
@staticmethod
2325
def deserialize_from_block(output_query_json: str) -> MoneroOutputQuery:
2426
...

tests/config/config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ test_relays=True
33
test_non_relays=True
44
lite_mode=False
55
test_notifications=True
6+
test_resets=True
67
network_type=regtest
78
auto_connect_timeout_ms=3000
89

tests/test_monero_daemon_rpc.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
BinaryBlockContext,
1717
AssertUtils, TxUtils,
1818
BlockUtils, GenUtils,
19-
DaemonUtils, BlockchainUtils,
20-
MiningUtils
19+
DaemonUtils, WalletType,
20+
IntegrationTestUtils
2121
)
2222

2323
logger: logging.Logger = logging.getLogger("TestMoneroDaemonRpc")
@@ -32,11 +32,7 @@ class TestMoneroDaemonRpc:
3232

3333
@pytest.fixture(scope="class", autouse=True)
3434
def before_all(self):
35-
BlockchainUtils.setup_blockchain(Utils.NETWORK_TYPE)
36-
wallet = Utils.get_wallet_rpc()
37-
tx = MiningUtils.fund_wallet(wallet, 1)
38-
if tx is not None:
39-
BlockchainUtils.wait_for_blocks(11)
35+
IntegrationTestUtils.setup(WalletType.RPC)
4036

4137
@pytest.fixture(autouse=True)
4238
def setup_and_teardown(self, request: pytest.FixtureRequest):
@@ -377,14 +373,14 @@ def test_get_txs_by_hashes(self, daemon: MoneroDaemonRpc, wallet: MoneroWalletRp
377373
# Can get transaction pool statistics
378374
@pytest.mark.skipif(Utils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled")
379375
def test_get_tx_pool_statistics(self, daemon: MoneroDaemonRpc, wallet: MoneroWalletRpc) -> None:
380-
wallet = wallet
381376
Utils.WALLET_TX_TRACKER.wait_for_txs_to_clear_pool([wallet])
382377
tx_ids: list[str] = []
383378
try:
384379
# submit txs to the pool but don't relay
385380
i = 1
386381
while i < 3:
387382
# submit tx hex
383+
logger.debug(f"test_get_tx_pool_statistics: account {i}")
388384
tx: MoneroTx = TxUtils.get_unrelayed_tx(wallet, i)
389385
assert tx.full_hex is not None
390386
result: MoneroSubmitTxResult = daemon.submit_tx_hex(tx.full_hex, True)

0 commit comments

Comments
 (0)