From 7cd86ccf62d67842d083cd0b8932362d9e4868da Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Sat, 13 Apr 2024 11:45:24 +0100 Subject: [PATCH] Eliminate recursive opening of transactions in unit tests. Recursive transactions are unnecessary and will deadlock when memory protection is needed/added to ledger transactions. --- nano/core_test/wallet.cpp | 3 +-- nano/rpc_test/rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nano/core_test/wallet.cpp b/nano/core_test/wallet.cpp index 05d49392f..e099e7576 100644 --- a/nano/core_test/wallet.cpp +++ b/nano/core_test/wallet.cpp @@ -650,8 +650,7 @@ TEST (wallet, work_generate) } nano::keypair key; auto block (wallet->send_action (nano::dev::genesis_key.pub, key.pub, 100)); - auto transaction (node1.store.tx_begin_read ()); - ASSERT_TIMELY (10s, node1.ledger.account_balance (transaction, nano::dev::genesis_key.pub) != amount1); + ASSERT_TIMELY (10s, node1.ledger.account_balance (node1.ledger.store.tx_begin_read (), nano::dev::genesis_key.pub) != amount1); system.deadline_set (10s); auto again (true); while (again) diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 78893bc53..27961b142 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -5770,8 +5770,8 @@ TEST (rpc, block_confirmed) // Open an account directly in the ledger { - auto transaction = node->store.tx_begin_write (); - nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); + auto transaction = node->ledger.store.tx_begin_write (); + nano::block_hash latest (node->ledger.latest (transaction, nano::dev::genesis_key.pub)); auto send1 = builder .send () .previous (latest)