Skip to content

Commit a419c7b

Browse files
authored
Merge pull request nanocurrency#5023 "Refactor wallet API to use nano::result (boost outcome) and direct return values"
Refactor wallet API to use nano::result (boost outcome) and direct return values
2 parents 2a011b4 + 63c2503 commit a419c7b

File tree

15 files changed

+851
-504
lines changed

15 files changed

+851
-504
lines changed

nano/boost/outcome.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
// Disable [[nodiscard]] for outcome results
4+
#define BOOST_OUTCOME_NODISCARD
5+
36
#include <boost/outcome.hpp>
47

58
namespace outcome = BOOST_OUTCOME_V2_NAMESPACE;

nano/core_test/node.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,11 +1058,11 @@ TEST (node, fork_no_vote_quorum)
10581058
auto & node2 (*system.nodes[1]);
10591059
auto & node3 (*system.nodes[2]);
10601060
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
1061-
auto key4 (system.wallet (0)->deterministic_insert ());
1061+
auto key4 = system.wallet (0)->deterministic_insert ().value ();
10621062
system.wallet (0)->send_action (nano::dev::genesis_key.pub, key4, nano::dev::constants.genesis_amount / 4);
1063-
auto key1 (system.wallet (1)->deterministic_insert ());
1063+
auto key1 = system.wallet (1)->deterministic_insert ().value ();
10641064
system.wallet (1)->set_representative (key1);
1065-
auto block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1, node1.config.receive_minimum.number ()));
1065+
auto block = system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1, node1.config.receive_minimum.number ());
10661066
ASSERT_NE (nullptr, block);
10671067
ASSERT_TIMELY (30s, node3.balance (key1) == node1.config.receive_minimum.number () && node2.balance (key1) == node1.config.receive_minimum.number () && node1.balance (key1) == node1.config.receive_minimum.number ());
10681068
ASSERT_EQ (node1.config.receive_minimum.number (), node1.weight (key1));
@@ -1082,17 +1082,17 @@ TEST (node, fork_no_vote_quorum)
10821082
nano::test::process (node1, { send1 });
10831083
nano::test::process (node2, { send1 });
10841084
nano::test::process (node3, { send1 });
1085-
auto key2 (system.wallet (2)->deterministic_insert ());
1085+
auto key2 = system.wallet (2)->deterministic_insert ().value ();
10861086
auto send2 = nano::send_block_builder ()
10871087
.previous (block->hash ())
10881088
.destination (key2)
10891089
.balance ((nano::dev::constants.genesis_amount / 4) - (node1.config.receive_minimum.number () * 2))
10901090
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
10911091
.work (*system.work.generate (block->hash ()))
10921092
.build ();
1093-
nano::raw_key key3;
1094-
ASSERT_FALSE (system.wallet (1)->fetch_prv (key1, key3));
1095-
auto vote = std::make_shared<nano::vote> (key1, key3, 0, 0, std::vector<nano::block_hash>{ send2->hash () });
1093+
auto key3_result = system.wallet (1)->fetch_prv (key1);
1094+
ASSERT_TRUE (key3_result);
1095+
auto vote = std::make_shared<nano::vote> (key1, key3_result.value (), 0, 0, std::vector<nano::block_hash>{ send2->hash () });
10961096
nano::messages::confirm_ack confirm{ nano::dev::network_params.network, vote };
10971097
auto channel = node2.network.find_node_id (node3.node_id.pub);
10981098
ASSERT_NE (nullptr, channel);

0 commit comments

Comments
 (0)