diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 824998bfae8..d8cc45b3929 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2489,12 +2489,6 @@ CAmount CWallet::GetAvailableBalance(const CCoinControl* coinControl) const return balance; } -static void PrintUTXOSet(std::vector& vCoins) { - for (const auto& coin : vCoins) { - LogPrintf("XXX UTXOS hash %s vout %d\n", coin.tx->GetHash().ToString(), coin.i); - } -} - void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector& vCoins, bool fOnlySafe, const CCoinControl* coinControl, const CAmount& nMinimumAmount, const CAmount& nMaximumAmount, const CAmount& nMinimumSumAmount, const uint64_t nMaximumCount) const { AssertLockHeld(cs_wallet); @@ -2626,12 +2620,10 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector< // Checks the maximum number of UTXO's. if (nMaximumCount > 0 && vCoins.size() >= nMaximumCount) { - PrintUTXOSet(vCoins); return; } } } - PrintUTXOSet(vCoins); } /// @todo tokens: used only in listCoins by qt, so, limit with token = 0???? diff --git a/test/functional/feature_restore_utxo.py b/test/functional/feature_restore_utxo.py index 01abc1ef7db..43b00a2520f 100755 --- a/test/functional/feature_restore_utxo.py +++ b/test/functional/feature_restore_utxo.py @@ -9,6 +9,7 @@ from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal +import time class TestRestoreUTXOs(DefiTestFramework): def set_test_params(self): @@ -24,6 +25,24 @@ def clearmempool(self, node: int): return False return True + def account_to_account(self, node: int, soure, destination): + try: + self.nodes[node].accounttoaccount(soure, {destination: "1@BTC"}) + except JSONRPCException as e: + return False + return True + + def account_to_account_loop(self, node: int, soure, destination): + count = 0 + while not self.account_to_account(node, soure, destination): + if count == 5: + return False + else: + count += 1 + time.sleep(1) + return True + + def rollback(self, count): block = self.nodes[0].getblockhash(count) self.nodes[0].invalidateblock(block) @@ -90,20 +109,20 @@ def run_test(self): self.nodes[0].generate(1) self.sync_blocks() block = self.nodes[0].getblockcount() + 1 - #node0_utxos = len(self.nodes[0].listunspent()) - #node1_utxos = len(self.nodes[1].listunspent()) + node0_utxos = len(self.nodes[0].listunspent()) + node1_utxos = len(self.nodes[1].listunspent()) # Test rollbacks for x in range(50): - self.nodes[0].accounttoaccount(node0_source, {node0_destination: "1@BTC"}) + assert(self.account_to_account_loop(0, node0_source, node0_destination)) self.nodes[0].generate(1) self.sync_blocks() - self.nodes[1].accounttoaccount(node1_source, {node1_destination: "1@BTC"}) + assert(self.account_to_account_loop(1, node1_source, node1_destination)) self.nodes[1].generate(1) self.sync_blocks() self.rollback(block) - # assert_equal(len(self.nodes[0].listunspent()), node0_utxos) # 4 != 5 - # assert_equal(len(self.nodes[1].listunspent()), node1_utxos) + assert_equal(len(self.nodes[0].listunspent()), node0_utxos) + assert_equal(len(self.nodes[1].listunspent()), node1_utxos) if __name__ == '__main__': TestRestoreUTXOs().main()