From 62e139703ec6acdaa99022895fd12349ffc26f7c Mon Sep 17 00:00:00 2001 From: turuslan Date: Tue, 20 Aug 2024 09:54:50 +0500 Subject: [PATCH 1/3] refactor test outcome Signed-off-by: turuslan --- cmake/Hunter/hunter-gate-url.cmake | 6 +- core/api/jrpc/value_converter.hpp | 2 +- .../service/author/impl/author_api_impl.cpp | 2 +- .../service/child_state/requests/get_keys.cpp | 2 +- .../child_state/requests/get_keys_paged.cpp | 2 +- .../service/payment/impl/payment_api_impl.cpp | 2 +- core/api/service/state/requests/call.cpp | 2 +- .../service/state/requests/get_keys_paged.cpp | 2 +- .../service/system/impl/system_api_impl.cpp | 2 +- core/api/service/system/requests/peers.hpp | 8 +- .../impl/app_configuration_impl.cpp | 2 +- .../impl/block_header_repository_impl.cpp | 2 +- core/blockchain/impl/block_storage_impl.cpp | 2 +- .../babe/impl/babe_block_validator_impl.cpp | 4 +- .../babe/impl/babe_config_repository_impl.cpp | 7 +- .../consensus/babe/impl/babe_digests_util.cpp | 2 +- .../grandpa/authority_manager_error.cpp | 2 +- .../grandpa/impl/authority_manager_impl.cpp | 2 +- .../grandpa/impl/environment_impl.cpp | 2 +- core/consensus/grandpa/voting_round_error.cpp | 2 +- core/crypto/blake2/blake2b.cpp | 2 +- core/crypto/blake2/blake2s.cpp | 2 +- core/crypto/ed25519_types.cpp | 2 +- core/crypto/key_store/key_type.hpp | 2 +- core/crypto/random_generator.hpp | 2 +- .../random_generator/boost_generator.hpp | 2 +- .../dispute_coordinator/impl/storage_impl.cpp | 2 +- .../impl/prioritized_selection.hpp | 2 +- .../host_api/impl/child_storage_extension.cpp | 2 +- core/host_api/impl/crypto_extension.cpp | 2 +- core/host_api/impl/misc_extension.cpp | 2 +- core/host_api/impl/offchain_extension.cpp | 2 +- core/host_api/impl/storage_extension.cpp | 2 +- core/metrics/exposer.hpp | 3 +- core/metrics/impl/metrics_watcher.cpp | 2 +- core/metrics/impl/prometheus/handler_impl.cpp | 3 +- .../adapters/protobuf_block_response.hpp | 2 +- .../adapters/protobuf_state_response.hpp | 2 +- .../helpers/protobuf_message_read_writer.hpp | 2 +- .../helpers/scale_message_read_writer.hpp | 2 +- .../protocols/request_response_protocol.hpp | 2 +- core/network/impl/stream_engine.hpp | 8 +- core/network/rpc.hpp | 8 +- core/network/types/block_announce.hpp | 2 +- .../types/block_announce_handshake.hpp | 2 +- .../impl/offchain_persistent_storage.cpp | 2 +- core/offchain/types.hpp | 2 +- core/parachain/pvf/kagome_pvf_worker.cpp | 2 +- core/parachain/pvf/pvf_worker_types.hpp | 2 +- core/parachain/pvf/secure_mode_precheck.cpp | 2 +- core/parachain/pvf/secure_mode_precheck.hpp | 2 +- .../validator/impl/parachain_processor.cpp | 2 +- core/primitives/apply_result.hpp | 2 +- core/primitives/code_substitutes.hpp | 2 +- core/primitives/digest.hpp | 2 +- core/primitives/inherent_data.hpp | 4 +- core/runtime/common/core_api_factory_impl.cpp | 2 +- core/runtime/common/executor.cpp | 2 +- .../common/runtime_properties_cache_impl.cpp | 2 +- .../impl/parachain_host_types_serde.hpp | 2 +- .../runtime/wasm_edge/module_factory_impl.cpp | 2 +- .../intrinsics/intrinsic_resolver_impl.cpp | 4 +- core/scale/kagome_scale.hpp | 2 +- core/scale/libp2p_types.hpp | 2 +- .../in_memory/in_memory_spaced_storage.hpp | 5 - core/storage/rocksdb/rocksdb_cursor.cpp | 2 +- .../trie/serialization/ordered_trie_hash.hpp | 2 +- .../trie/serialization/polkadot_codec.cpp | 4 +- .../trie/serialization/polkadot_codec.hpp | 2 +- .../api/service/author/author_api_test.cpp | 88 +++++------- .../api/service/chain/base_request_test.cpp | 8 +- .../core/api/service/chain/chain_api_test.cpp | 33 ++--- .../child_state/child_state_api_test.cpp | 16 +-- .../api/service/payment/payment_api_test.cpp | 6 +- .../core/api/service/state/state_api_test.cpp | 66 ++++----- .../state/state_jrpc_processor_test.cpp | 6 +- .../api/service/system/system_api_test.cpp | 13 +- .../core/api/transport/http_listener_test.cpp | 4 +- test/core/api/transport/listener_test.hpp | 2 +- test/core/api/transport/ws_listener_test.cpp | 4 +- test/core/application/chain_spec_test.cpp | 4 +- .../authorship/block_builder_factory_test.cpp | 1 - test/core/authorship/block_builder_test.cpp | 9 +- test/core/authorship/proposer_test.cpp | 1 - .../block_header_repository_test.cpp | 38 +++-- test/core/blockchain/block_storage_test.cpp | 31 ++-- test/core/blockchain/block_tree_test.cpp | 48 +++---- .../babe/babe_block_validator_test.cpp | 29 ++-- test/core/consensus/babe/babe_test.cpp | 25 ++-- test/core/consensus/grandpa/chain_test.cpp | 10 +- .../grandpa/vote_graph/adjust_base_test.cpp | 6 +- .../vote_graph/duplicate_vote_test.cpp | 6 +- .../consensus/grandpa/vote_graph/fixture.hpp | 34 ++--- .../ghost_introduce_branch_test.cpp | 6 +- .../vote_graph/ghost_merge_at_node_test.cpp | 8 +- ...rge_not_at_node_one_side_weighted_test.cpp | 6 +- .../grandpa/vote_graph/graph_fork_test.cpp | 12 +- .../grandpa/vote_graph/remove_vote_test.cpp | 6 +- .../vote_graph/small_block_number_test.cpp | 4 +- .../vote_graph/walk_back_at_node_test.cpp | 8 +- ...ack_from_block_in_edge_fork_below_test.cpp | 6 +- ..._back_from_fork_block_node_below_tests.cpp | 8 +- .../core/consensus/grandpa/voter_set_test.cpp | 30 ++-- .../timeline/block_executor_test.cpp | 5 +- .../crypto/bandersnatch/bandersnatch_test.cpp | 17 +-- .../crypto/bip39/bip39_integration_test.cpp | 10 +- .../crypto/bip39/entropy_calculation_test.cpp | 9 +- .../core/crypto/ecdsa/ecdsa_provider_test.cpp | 21 ++- .../crypto/ed25519/ed25519_provider_test.cpp | 30 ++-- test/core/crypto/key_store/key_store_test.cpp | 78 +++++----- .../secp256k1/secp256k1_provider_test.cpp | 37 +++-- .../crypto/sr25519/sr25519_provider_test.cpp | 45 +++--- .../host_api/child_storage_extension_test.cpp | 3 +- test/core/host_api/crypto_extension_test.cpp | 11 +- test/core/host_api/misc_extension_test.cpp | 2 +- .../core/host_api/offchain_extension_test.cpp | 3 +- test/core/host_api/storage_extension_test.cpp | 3 +- test/core/network/rpc_libp2p_test.cpp | 2 +- .../network/state_protocol_observer_test.cpp | 10 +- .../network/sync_protocol_observer_test.cpp | 10 +- .../network/types/block_announce_test.cpp | 11 +- .../network/types/block_attributes_test.cpp | 7 +- .../network/types/block_direction_test.cpp | 4 +- .../types/message_read_writer_test.cpp | 1 - .../types/protobuf_block_request_test.cpp | 12 +- .../types/protobuf_block_response_test.cpp | 39 +++-- .../types/protobuf_state_request_test.cpp | 12 +- .../types/protobuf_state_response_test.cpp | 4 +- test/core/network/types/uvar_adapter_test.cpp | 11 +- .../core/parachain/prospective_parachains.cpp | 13 +- test/core/parachain/pvf_test.cpp | 6 +- test/core/parachain/secure_mode.cpp | 8 +- .../core/primitives/primitives_codec_test.cpp | 70 ++++----- test/core/primitives/ss58_codec_test.cpp | 5 +- .../binaryen/block_builder_api_test.cpp | 18 +-- test/core/runtime/binaryen/metadata_test.cpp | 1 - test/core/runtime/binaryen/parachain_test.cpp | 1 - .../tagged_transaction_queue_test.cpp | 5 +- test/core/runtime/executor_test.cpp | 57 +++----- test/core/runtime/instance_pool_test.cpp | 6 +- test/core/runtime/runtime_test_base.hpp | 1 - .../runtime/runtime_upgrade_tracker_test.cpp | 35 +++-- test/core/runtime/stack_limiter_test.cpp | 14 +- .../runtime/storage_code_provider_test.cpp | 10 +- .../runtime/trie_storage_provider_test.cpp | 134 ++++++++---------- test/core/scale/big_fixed_integers_test.cpp | 6 +- .../changes_trie/changes_tracker_test.cpp | 10 +- test/core/storage/rocksdb/rocksdb_fs_test.cpp | 5 +- .../rocksdb/rocksdb_integration_test.cpp | 31 ++-- .../polkadot_trie_cursor_test.cpp | 71 +++++----- .../trie/polkadot_trie/polkadot_trie_test.cpp | 100 ++++++------- .../trie_storage/ordered_trie_hash_test.cpp | 47 ++---- .../polkadot_codec_node_decoding_test.cpp | 11 +- .../polkadot_codec_node_encoding_test.cpp | 9 +- .../trie/trie_storage/trie_batch_test.cpp | 78 +++++----- .../trie_storage_backend_test.cpp | 16 +-- .../trie/trie_storage/trie_storage_test.cpp | 23 ++- .../storage/trie_pruner/trie_pruner_test.cpp | 69 ++++----- .../transaction_pool/pool_moderator_test.cpp | 1 - .../transaction_pool_test.cpp | 15 +- .../storage/trie_pruner/trie_pruner_mock.hpp | 2 +- .../libp2p/message_read_writer_helper.cpp | 2 +- test/testutil/ma_generator.hpp | 5 +- test/testutil/outcome.hpp | 59 -------- test/testutil/scale_test_comparator.hpp | 2 +- 165 files changed, 925 insertions(+), 1178 deletions(-) delete mode 100644 test/testutil/outcome.hpp diff --git a/cmake/Hunter/hunter-gate-url.cmake b/cmake/Hunter/hunter-gate-url.cmake index be63f1e82b..d07baddcd3 100644 --- a/cmake/Hunter/hunter-gate-url.cmake +++ b/cmake/Hunter/hunter-gate-url.cmake @@ -1,5 +1,5 @@ HunterGate( - URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm19.zip - SHA1 eed8b8333c14f25176d4af4fb26256981fd1b527 + URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm21.zip + SHA1 5b52ab9a309771f172ca609a46e26dde60a8edd7 LOCAL -) \ No newline at end of file +) diff --git a/core/api/jrpc/value_converter.hpp b/core/api/jrpc/value_converter.hpp index 5bfeac3d2f..7270ce5308 100644 --- a/core/api/jrpc/value_converter.hpp +++ b/core/api/jrpc/value_converter.hpp @@ -11,6 +11,7 @@ #include #include +#include #include "api/service/state/state_api.hpp" #include "common/blob.hpp" #include "common/hexutil.hpp" @@ -24,7 +25,6 @@ #include "primitives/rpc_methods.hpp" #include "primitives/runtime_dispatch_info.hpp" #include "primitives/version.hpp" -#include "scale/scale.hpp" namespace kagome::api { diff --git a/core/api/service/author/impl/author_api_impl.cpp b/core/api/service/author/impl/author_api_impl.cpp index b2d36988bf..af2d51cb10 100644 --- a/core/api/service/author/impl/author_api_impl.cpp +++ b/core/api/service/author/impl/author_api_impl.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "api/service/api_service.hpp" #include "blockchain/block_tree.hpp" #include "crypto/hasher.hpp" @@ -20,7 +21,6 @@ #include "crypto/sr25519_types.hpp" #include "primitives/transaction.hpp" #include "runtime/runtime_api/session_keys_api.hpp" -#include "scale/scale_decoder_stream.hpp" #include "subscription/subscriber.hpp" #include "transaction_pool/transaction_pool.hpp" diff --git a/core/api/service/child_state/requests/get_keys.cpp b/core/api/service/child_state/requests/get_keys.cpp index 40bfee60d4..ebf8be8433 100644 --- a/core/api/service/child_state/requests/get_keys.cpp +++ b/core/api/service/child_state/requests/get_keys.cpp @@ -6,7 +6,7 @@ #include "api/service/child_state/requests/get_keys.hpp" -#include "scale/scale.hpp" +#include namespace kagome::api::child_state::request { diff --git a/core/api/service/child_state/requests/get_keys_paged.cpp b/core/api/service/child_state/requests/get_keys_paged.cpp index addcbea051..73cfe6f758 100644 --- a/core/api/service/child_state/requests/get_keys_paged.cpp +++ b/core/api/service/child_state/requests/get_keys_paged.cpp @@ -6,7 +6,7 @@ #include "api/service/child_state/requests/get_keys_paged.hpp" -#include "scale/scale.hpp" +#include namespace kagome::api::child_state::request { diff --git a/core/api/service/payment/impl/payment_api_impl.cpp b/core/api/service/payment/impl/payment_api_impl.cpp index 572fa73b2c..3420740f65 100644 --- a/core/api/service/payment/impl/payment_api_impl.cpp +++ b/core/api/service/payment/impl/payment_api_impl.cpp @@ -6,9 +6,9 @@ #include "api/service/payment/impl/payment_api_impl.hpp" +#include #include "blockchain/block_tree.hpp" #include "runtime/runtime_api/transaction_payment_api.hpp" -#include "scale/types.hpp" namespace kagome::api { diff --git a/core/api/service/state/requests/call.cpp b/core/api/service/state/requests/call.cpp index 7581e20a82..5368448eab 100644 --- a/core/api/service/state/requests/call.cpp +++ b/core/api/service/state/requests/call.cpp @@ -6,7 +6,7 @@ #include "api/service/state/requests/call.hpp" -#include "scale/scale.hpp" +#include namespace kagome::api::state::request { diff --git a/core/api/service/state/requests/get_keys_paged.cpp b/core/api/service/state/requests/get_keys_paged.cpp index 1978342d43..b4d0a8b094 100644 --- a/core/api/service/state/requests/get_keys_paged.cpp +++ b/core/api/service/state/requests/get_keys_paged.cpp @@ -6,7 +6,7 @@ #include "api/service/state/requests/get_keys_paged.hpp" -#include "scale/scale.hpp" +#include namespace kagome::api::state::request { diff --git a/core/api/service/system/impl/system_api_impl.cpp b/core/api/service/system/impl/system_api_impl.cpp index 9485cd6568..30171a544c 100644 --- a/core/api/service/system/impl/system_api_impl.cpp +++ b/core/api/service/system/impl/system_api_impl.cpp @@ -10,9 +10,9 @@ #include +#include #include "blockchain/block_tree.hpp" #include "primitives/ss58_codec.hpp" -#include "scale/scale.hpp" #include "transaction_pool/transaction_pool.hpp" namespace kagome::api { diff --git a/core/api/service/system/requests/peers.hpp b/core/api/service/system/requests/peers.hpp index eca5ca032d..e05eaa9d28 100644 --- a/core/api/service/system/requests/peers.hpp +++ b/core/api/service/system/requests/peers.hpp @@ -8,11 +8,11 @@ #include "api/service/base_request.hpp" -#include "account_next_index.hpp" +#include "api/service/system/requests/account_next_index.hpp" +#include "api/service/system/requests/chain.hpp" +#include "api/service/system/requests/chain_type.hpp" +#include "api/service/system/requests/health.hpp" #include "api/service/system/system_api.hpp" -#include "chain.hpp" -#include "chain_type.hpp" -#include "health.hpp" namespace kagome::api::system::request { diff --git a/core/application/impl/app_configuration_impl.cpp b/core/application/impl/app_configuration_impl.cpp index aedd21f2d2..ff502c4776 100644 --- a/core/application/impl/app_configuration_impl.cpp +++ b/core/application/impl/app_configuration_impl.cpp @@ -24,9 +24,9 @@ #include "api/transport/tuner.hpp" #include "application/build_version.hpp" +#include "application/impl/chain_spec_impl.hpp" #include "assets/assets.hpp" #include "assets/embedded_chainspec.hpp" -#include "chain_spec_impl.hpp" #include "common/hexutil.hpp" #include "common/uri.hpp" #include "filesystem/common.hpp" diff --git a/core/blockchain/impl/block_header_repository_impl.cpp b/core/blockchain/impl/block_header_repository_impl.cpp index 11afe95ed0..202263eff5 100644 --- a/core/blockchain/impl/block_header_repository_impl.cpp +++ b/core/blockchain/impl/block_header_repository_impl.cpp @@ -8,9 +8,9 @@ #include +#include #include "blockchain/block_tree_error.hpp" #include "blockchain/impl/storage_util.hpp" -#include "scale/scale.hpp" using kagome::primitives::BlockHash; using kagome::primitives::BlockNumber; diff --git a/core/blockchain/impl/block_storage_impl.cpp b/core/blockchain/impl/block_storage_impl.cpp index 0e19b1fce0..679bd83eb8 100644 --- a/core/blockchain/impl/block_storage_impl.cpp +++ b/core/blockchain/impl/block_storage_impl.cpp @@ -6,10 +6,10 @@ #include "blockchain/impl/block_storage_impl.hpp" +#include #include "blockchain/block_storage_error.hpp" #include "blockchain/impl/storage_util.hpp" #include "common/visitor.hpp" -#include "scale/scale.hpp" namespace kagome::blockchain { using primitives::Block; diff --git a/core/consensus/babe/impl/babe_block_validator_impl.cpp b/core/consensus/babe/impl/babe_block_validator_impl.cpp index 465d86122e..b06e9d147f 100644 --- a/core/consensus/babe/impl/babe_block_validator_impl.cpp +++ b/core/consensus/babe/impl/babe_block_validator_impl.cpp @@ -12,18 +12,18 @@ #include "consensus/babe/babe_config_repository.hpp" #include "consensus/babe/babe_lottery.hpp" #include "consensus/babe/impl/babe_digests_util.hpp" +#include "consensus/babe/impl/prepare_transcript.hpp" +#include "consensus/babe/impl/threshold_util.hpp" #include "consensus/babe/types/seal.hpp" #include "consensus/timeline/impl/slot_leadership_error.hpp" #include "consensus/timeline/slots_util.hpp" #include "crypto/sr25519_provider.hpp" #include "crypto/vrf_provider.hpp" #include "metrics/histogram_timer.hpp" -#include "prepare_transcript.hpp" #include "primitives/inherent_data.hpp" #include "primitives/transcript.hpp" #include "runtime/runtime_api/babe_api.hpp" #include "runtime/runtime_api/offchain_worker_api.hpp" -#include "threshold_util.hpp" OUTCOME_CPP_DEFINE_CATEGORY(kagome::consensus::babe, BabeBlockValidatorImpl::ValidationError, diff --git a/core/consensus/babe/impl/babe_config_repository_impl.cpp b/core/consensus/babe/impl/babe_config_repository_impl.cpp index 3764315dac..3fda9ecbd1 100644 --- a/core/consensus/babe/impl/babe_config_repository_impl.cpp +++ b/core/consensus/babe/impl/babe_config_repository_impl.cpp @@ -4,19 +4,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "babe_config_repository_impl.hpp" +#include "consensus/babe/impl/babe_config_repository_impl.hpp" #include "application/app_configuration.hpp" #include "application/app_state_manager.hpp" -#include "babe.hpp" -#include "babe_digests_util.hpp" #include "blockchain/block_header_repository.hpp" #include "blockchain/block_tree.hpp" +#include "consensus/babe/impl/babe.hpp" +#include "consensus/babe/impl/babe_digests_util.hpp" #include "consensus/consensus_selector.hpp" #include "consensus/timeline/slots_util.hpp" #include "primitives/block_header.hpp" #include "runtime/runtime_api/babe_api.hpp" -#include "scale/scale.hpp" #include "storage/map_prefix/prefix.hpp" #include "storage/predefined_keys.hpp" #include "storage/trie/trie_storage.hpp" diff --git a/core/consensus/babe/impl/babe_digests_util.cpp b/core/consensus/babe/impl/babe_digests_util.cpp index 87ac6feb76..63eef3f046 100644 --- a/core/consensus/babe/impl/babe_digests_util.cpp +++ b/core/consensus/babe/impl/babe_digests_util.cpp @@ -6,7 +6,7 @@ #include "consensus/babe/impl/babe_digests_util.hpp" -#include "scale/scale.hpp" +#include OUTCOME_CPP_DEFINE_CATEGORY(kagome::consensus::babe, DigestError, e) { using E = kagome::consensus::babe::DigestError; diff --git a/core/consensus/grandpa/authority_manager_error.cpp b/core/consensus/grandpa/authority_manager_error.cpp index ac34f49744..f5a0de327d 100644 --- a/core/consensus/grandpa/authority_manager_error.cpp +++ b/core/consensus/grandpa/authority_manager_error.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "authority_manager_error.hpp" +#include "consensus/grandpa/authority_manager_error.hpp" OUTCOME_CPP_DEFINE_CATEGORY(kagome::consensus::grandpa, AuthorityManagerError, diff --git a/core/consensus/grandpa/impl/authority_manager_impl.cpp b/core/consensus/grandpa/impl/authority_manager_impl.cpp index dc37c3dd29..56f29d489b 100644 --- a/core/consensus/grandpa/impl/authority_manager_impl.cpp +++ b/core/consensus/grandpa/impl/authority_manager_impl.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "authority_manager_impl.hpp" +#include "consensus/grandpa/impl/authority_manager_impl.hpp" #include "application/app_state_manager.hpp" #include "blockchain/block_tree.hpp" diff --git a/core/consensus/grandpa/impl/environment_impl.cpp b/core/consensus/grandpa/impl/environment_impl.cpp index c5cd2adf0c..199fb1cabf 100644 --- a/core/consensus/grandpa/impl/environment_impl.cpp +++ b/core/consensus/grandpa/impl/environment_impl.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "application/app_state_manager.hpp" #include "blockchain/block_header_repository.hpp" #include "blockchain/block_tree.hpp" @@ -34,7 +35,6 @@ #include "primitives/common.hpp" #include "runtime/runtime_api/grandpa_api.hpp" #include "runtime/runtime_api/parachain_host.hpp" -#include "scale/scale.hpp" #include "utils/pool_handler.hpp" namespace kagome::consensus::grandpa { diff --git a/core/consensus/grandpa/voting_round_error.cpp b/core/consensus/grandpa/voting_round_error.cpp index 51151f9db8..f72c8281ba 100644 --- a/core/consensus/grandpa/voting_round_error.cpp +++ b/core/consensus/grandpa/voting_round_error.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "voting_round_error.hpp" +#include "consensus/grandpa/voting_round_error.hpp" OUTCOME_CPP_DEFINE_CATEGORY(kagome::consensus::grandpa, VotingRoundError, e) { using E = kagome::consensus::grandpa::VotingRoundError; diff --git a/core/crypto/blake2/blake2b.cpp b/core/crypto/blake2/blake2b.cpp index 0367a9e51b..22f7530d8e 100644 --- a/core/crypto/blake2/blake2b.cpp +++ b/core/crypto/blake2/blake2b.cpp @@ -10,7 +10,7 @@ // blake2b.c // A simple BLAKE2b Reference Implementation. -#include "blake2b.h" +#include "crypto/blake2/blake2b.h" namespace kagome::crypto { diff --git a/core/crypto/blake2/blake2s.cpp b/core/crypto/blake2/blake2s.cpp index 320f4196ef..78eb0955ad 100644 --- a/core/crypto/blake2/blake2s.cpp +++ b/core/crypto/blake2/blake2s.cpp @@ -10,7 +10,7 @@ // blake2s.c // A simple blake2s Reference Implementation. -#include "blake2s.h" +#include "crypto/blake2/blake2s.h" #include diff --git a/core/crypto/ed25519_types.cpp b/core/crypto/ed25519_types.cpp index 3c2f97f3e0..f6754ed4e8 100644 --- a/core/crypto/ed25519_types.cpp +++ b/core/crypto/ed25519_types.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "ed25519_types.hpp" +#include "crypto/ed25519_types.hpp" namespace kagome::crypto { bool Ed25519Keypair::operator==(const Ed25519Keypair &other) const { diff --git a/core/crypto/key_store/key_type.hpp b/core/crypto/key_store/key_type.hpp index a583c773b7..3039e5bb5e 100644 --- a/core/crypto/key_store/key_type.hpp +++ b/core/crypto/key_store/key_type.hpp @@ -6,9 +6,9 @@ #pragma once +#include #include "common/buffer.hpp" #include "outcome/outcome.hpp" -#include "scale/scale.hpp" namespace kagome::crypto { diff --git a/core/crypto/random_generator.hpp b/core/crypto/random_generator.hpp index 3ca6743de3..a8ad6fecdf 100644 --- a/core/crypto/random_generator.hpp +++ b/core/crypto/random_generator.hpp @@ -6,7 +6,7 @@ #pragma once -#include "libp2p/crypto/random_generator.hpp" +#include namespace kagome::crypto { using RandomGenerator = libp2p::crypto::random::RandomGenerator; diff --git a/core/crypto/random_generator/boost_generator.hpp b/core/crypto/random_generator/boost_generator.hpp index 76eb7ffcc7..572ddbdf10 100644 --- a/core/crypto/random_generator/boost_generator.hpp +++ b/core/crypto/random_generator/boost_generator.hpp @@ -6,7 +6,7 @@ #pragma once -#include "libp2p/crypto/random_generator/boost_generator.hpp" +#include namespace kagome::crypto { diff --git a/core/dispute_coordinator/impl/storage_impl.cpp b/core/dispute_coordinator/impl/storage_impl.cpp index cb9756e633..8d187649dd 100644 --- a/core/dispute_coordinator/impl/storage_impl.cpp +++ b/core/dispute_coordinator/impl/storage_impl.cpp @@ -6,7 +6,7 @@ #include "dispute_coordinator/impl/storage_impl.hpp" -#include "scale/scale.hpp" +#include #include "storage/predefined_keys.hpp" #include "storage/spaced_storage.hpp" diff --git a/core/dispute_coordinator/provisioner/impl/prioritized_selection.hpp b/core/dispute_coordinator/provisioner/impl/prioritized_selection.hpp index c27ec7e5fe..a7e76211cf 100644 --- a/core/dispute_coordinator/provisioner/impl/prioritized_selection.hpp +++ b/core/dispute_coordinator/provisioner/impl/prioritized_selection.hpp @@ -6,9 +6,9 @@ #pragma once +#include #include "dispute_coordinator/types.hpp" #include "log/logger.hpp" -#include "scale/bitvec.hpp" namespace kagome::runtime { class ParachainHost; diff --git a/core/host_api/impl/child_storage_extension.cpp b/core/host_api/impl/child_storage_extension.cpp index ec87ce70ee..caad4ebe41 100644 --- a/core/host_api/impl/child_storage_extension.cpp +++ b/core/host_api/impl/child_storage_extension.cpp @@ -11,6 +11,7 @@ #include +#include #include "common/monadic_utils.hpp" #include "common/tagged.hpp" #include "host_api/impl/storage_util.hpp" @@ -18,7 +19,6 @@ #include "runtime/memory_provider.hpp" #include "runtime/ptr_size.hpp" #include "runtime/trie_storage_provider.hpp" -#include "scale/encode_append.hpp" #include "storage/predefined_keys.hpp" #include "storage/trie/polkadot_trie/trie_error.hpp" diff --git a/core/host_api/impl/crypto_extension.cpp b/core/host_api/impl/crypto_extension.cpp index 17ef6638c2..0a43800a58 100644 --- a/core/host_api/impl/crypto_extension.cpp +++ b/core/host_api/impl/crypto_extension.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "crypto/bandersnatch_provider.hpp" #include "crypto/ecdsa_provider.hpp" #include "crypto/ed25519_provider.hpp" @@ -23,7 +24,6 @@ #include "crypto/sr25519_provider.hpp" #include "log/trace_macros.hpp" #include "runtime/ptr_size.hpp" -#include "scale/scale.hpp" namespace { template diff --git a/core/host_api/impl/misc_extension.cpp b/core/host_api/impl/misc_extension.cpp index 6b792d0253..e139898269 100644 --- a/core/host_api/impl/misc_extension.cpp +++ b/core/host_api/impl/misc_extension.cpp @@ -6,12 +6,12 @@ #include "host_api/impl/misc_extension.hpp" +#include #include "log/trace_macros.hpp" #include "primitives/version.hpp" #include "runtime/core_api_factory.hpp" #include "runtime/memory_provider.hpp" #include "runtime/runtime_api/core.hpp" -#include "scale/scale.hpp" namespace kagome::host_api { diff --git a/core/host_api/impl/offchain_extension.cpp b/core/host_api/impl/offchain_extension.cpp index cd25fbc461..6e22f768c9 100644 --- a/core/host_api/impl/offchain_extension.cpp +++ b/core/host_api/impl/offchain_extension.cpp @@ -9,13 +9,13 @@ #include #include +#include #include "log/trace_macros.hpp" #include "offchain/offchain_worker.hpp" #include "offchain/offchain_worker_pool.hpp" #include "runtime/memory.hpp" #include "runtime/memory_provider.hpp" #include "runtime/ptr_size.hpp" -#include "scale/scale.hpp" namespace kagome::host_api { diff --git a/core/host_api/impl/storage_extension.cpp b/core/host_api/impl/storage_extension.cpp index 078f739d24..f9d80e5281 100644 --- a/core/host_api/impl/storage_extension.cpp +++ b/core/host_api/impl/storage_extension.cpp @@ -11,6 +11,7 @@ #include +#include #include "clock/impl/clock_impl.hpp" #include "common/monadic_utils.hpp" #include "common/outcome_throw.hpp" @@ -23,7 +24,6 @@ #include "runtime/memory_provider.hpp" #include "runtime/ptr_size.hpp" #include "runtime/trie_storage_provider.hpp" -#include "scale/encode_append.hpp" #include "storage/predefined_keys.hpp" #include "storage/trie/impl/topper_trie_batch_impl.hpp" #include "storage/trie/serialization/ordered_trie_hash.hpp" diff --git a/core/metrics/exposer.hpp b/core/metrics/exposer.hpp index 313e9821f7..b28a51b990 100644 --- a/core/metrics/exposer.hpp +++ b/core/metrics/exposer.hpp @@ -10,7 +10,8 @@ #include #include -#include "handler.hpp" + +#include "metrics/handler.hpp" namespace kagome::metrics { diff --git a/core/metrics/impl/metrics_watcher.cpp b/core/metrics/impl/metrics_watcher.cpp index 2770d387ba..bc9714e0a7 100644 --- a/core/metrics/impl/metrics_watcher.cpp +++ b/core/metrics/impl/metrics_watcher.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "metrics_watcher.hpp" +#include "metrics/impl/metrics_watcher.hpp" #include "filesystem/common.hpp" diff --git a/core/metrics/impl/prometheus/handler_impl.cpp b/core/metrics/impl/prometheus/handler_impl.cpp index 0b0ad1ad1e..4887c4df6e 100644 --- a/core/metrics/impl/prometheus/handler_impl.cpp +++ b/core/metrics/impl/prometheus/handler_impl.cpp @@ -7,8 +7,9 @@ #include "metrics/impl/prometheus/handler_impl.hpp" #include + #include "log/logger.hpp" -#include "registry_impl.hpp" +#include "metrics/impl/prometheus/registry_impl.hpp" #include "utils/retain_if.hpp" #include "utils/wptr.hpp" diff --git a/core/network/adapters/protobuf_block_response.hpp b/core/network/adapters/protobuf_block_response.hpp index 372ff1cf9f..14d9f9e5e0 100644 --- a/core/network/adapters/protobuf_block_response.hpp +++ b/core/network/adapters/protobuf_block_response.hpp @@ -8,10 +8,10 @@ #include "network/adapters/protobuf.hpp" +#include #include "common/bytestr.hpp" #include "network/protobuf/api.v1.pb.h" #include "network/types/blocks_response.hpp" -#include "scale/scale.hpp" namespace kagome::network { diff --git a/core/network/adapters/protobuf_state_response.hpp b/core/network/adapters/protobuf_state_response.hpp index a2569ac522..e1ee12dfad 100644 --- a/core/network/adapters/protobuf_state_response.hpp +++ b/core/network/adapters/protobuf_state_response.hpp @@ -8,9 +8,9 @@ #include "network/adapters/protobuf.hpp" +#include #include "network/protobuf/api.v1.pb.h" #include "network/types/state_response.hpp" -#include "scale/scale.hpp" namespace kagome::network { diff --git a/core/network/helpers/protobuf_message_read_writer.hpp b/core/network/helpers/protobuf_message_read_writer.hpp index 79e42314fd..1c5d629c03 100644 --- a/core/network/helpers/protobuf_message_read_writer.hpp +++ b/core/network/helpers/protobuf_message_read_writer.hpp @@ -13,10 +13,10 @@ #include #include +#include #include "network/adapters/protobuf.hpp" #include "network/adapters/uvar.hpp" #include "network/helpers/message_read_writer.hpp" -#include "scale/scale.hpp" namespace kagome::network { /** diff --git a/core/network/helpers/scale_message_read_writer.hpp b/core/network/helpers/scale_message_read_writer.hpp index d605d81848..99443de40d 100644 --- a/core/network/helpers/scale_message_read_writer.hpp +++ b/core/network/helpers/scale_message_read_writer.hpp @@ -12,7 +12,7 @@ #include #include -#include "scale/scale.hpp" +#include namespace kagome::network { /** diff --git a/core/network/impl/protocols/request_response_protocol.hpp b/core/network/impl/protocols/request_response_protocol.hpp index a56c80e244..a8424b93fe 100644 --- a/core/network/impl/protocols/request_response_protocol.hpp +++ b/core/network/impl/protocols/request_response_protocol.hpp @@ -8,7 +8,7 @@ #include "network/impl/protocols/protocol_base_impl.hpp" -#include "protocol_error.hpp" +#include "network/impl/protocols/protocol_error.hpp" #include "utils/box.hpp" namespace kagome::network { diff --git a/core/network/impl/stream_engine.hpp b/core/network/impl/stream_engine.hpp index 562ab1d174..db72caff2e 100644 --- a/core/network/impl/stream_engine.hpp +++ b/core/network/impl/stream_engine.hpp @@ -17,10 +17,10 @@ #include #endif -#include "libp2p/connection/stream.hpp" -#include "libp2p/host/host.hpp" -#include "libp2p/peer/peer_info.hpp" -#include "libp2p/peer/protocol.hpp" +#include +#include +#include +#include #include "log/logger.hpp" #include "network/helpers/scale_message_read_writer.hpp" #include "network/protocol_base.hpp" diff --git a/core/network/rpc.hpp b/core/network/rpc.hpp index 30cf0eee58..e1c2c08b61 100644 --- a/core/network/rpc.hpp +++ b/core/network/rpc.hpp @@ -9,11 +9,11 @@ #include #include +#include +#include +#include +#include #include "common/buffer.hpp" -#include "libp2p/basic/readwriter.hpp" -#include "libp2p/host/host.hpp" -#include "libp2p/peer/peer_info.hpp" -#include "libp2p/peer/protocol.hpp" #include "log/logger.hpp" #include "outcome/outcome.hpp" diff --git a/core/network/types/block_announce.hpp b/core/network/types/block_announce.hpp index e381140a50..8f1892bc4b 100644 --- a/core/network/types/block_announce.hpp +++ b/core/network/types/block_announce.hpp @@ -6,8 +6,8 @@ #pragma once +#include #include "primitives/block_header.hpp" -#include "scale/scale.hpp" namespace kagome::network { diff --git a/core/network/types/block_announce_handshake.hpp b/core/network/types/block_announce_handshake.hpp index 102973d520..0fd2fa8263 100644 --- a/core/network/types/block_announce_handshake.hpp +++ b/core/network/types/block_announce_handshake.hpp @@ -10,9 +10,9 @@ #include #include +#include #include "network/types/roles.hpp" #include "primitives/common.hpp" -#include "scale/scale.hpp" namespace kagome::network { diff --git a/core/offchain/impl/offchain_persistent_storage.cpp b/core/offchain/impl/offchain_persistent_storage.cpp index 4961f73fb6..8f346b7dda 100644 --- a/core/offchain/impl/offchain_persistent_storage.cpp +++ b/core/offchain/impl/offchain_persistent_storage.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "offchain_persistent_storage.hpp" +#include "offchain/impl/offchain_persistent_storage.hpp" #include "storage/database_error.hpp" #include "storage/predefined_keys.hpp" diff --git a/core/offchain/types.hpp b/core/offchain/types.hpp index 11f2c94b9f..56f1ed48e9 100644 --- a/core/offchain/types.hpp +++ b/core/offchain/types.hpp @@ -11,9 +11,9 @@ #include #include +#include #include "common/blob.hpp" #include "common/buffer.hpp" -#include "scale/scale.hpp" namespace kagome::offchain { diff --git a/core/parachain/pvf/kagome_pvf_worker.cpp b/core/parachain/pvf/kagome_pvf_worker.cpp index ebdd14c351..ca17f5daae 100644 --- a/core/parachain/pvf/kagome_pvf_worker.cpp +++ b/core/parachain/pvf/kagome_pvf_worker.cpp @@ -32,12 +32,12 @@ #include #include +#include #include "common/bytestr.hpp" #include "log/configurator.hpp" #include "log/logger.hpp" #include "parachain/pvf/kagome_pvf_worker_injector.hpp" #include "parachain/pvf/pvf_worker_types.hpp" -#include "scale/scale.hpp" #include "parachain/pvf/kagome_pvf_worker.hpp" #include "parachain/pvf/secure_mode.hpp" diff --git a/core/parachain/pvf/pvf_worker_types.hpp b/core/parachain/pvf/pvf_worker_types.hpp index 43daca7e83..f6accd9c27 100644 --- a/core/parachain/pvf/pvf_worker_types.hpp +++ b/core/parachain/pvf/pvf_worker_types.hpp @@ -8,9 +8,9 @@ #include +#include #include "common/buffer.hpp" #include "runtime/runtime_context.hpp" -#include "scale/scale.hpp" #include "scale/std_variant.hpp" #include "scale/tie.hpp" diff --git a/core/parachain/pvf/secure_mode_precheck.cpp b/core/parachain/pvf/secure_mode_precheck.cpp index 00f4d48e21..23c595aac5 100644 --- a/core/parachain/pvf/secure_mode_precheck.cpp +++ b/core/parachain/pvf/secure_mode_precheck.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "secure_mode_precheck.hpp" +#include "parachain/pvf/secure_mode_precheck.hpp" #include #include diff --git a/core/parachain/pvf/secure_mode_precheck.hpp b/core/parachain/pvf/secure_mode_precheck.hpp index 615657cc48..729fb1b044 100644 --- a/core/parachain/pvf/secure_mode_precheck.hpp +++ b/core/parachain/pvf/secure_mode_precheck.hpp @@ -8,9 +8,9 @@ #include #include +#include #include "parachain/pvf/secure_mode.hpp" -#include "qtils/outcome.hpp" #include "scale/tie.hpp" namespace kagome::parachain { diff --git a/core/parachain/validator/impl/parachain_processor.cpp b/core/parachain/validator/impl/parachain_processor.cpp index cbec906d41..ecedc217b2 100644 --- a/core/parachain/validator/impl/parachain_processor.cpp +++ b/core/parachain/validator/impl/parachain_processor.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "common/main_thread_pool.hpp" #include "common/worker_thread_pool.hpp" #include "consensus/babe/impl/babe_digests_util.hpp" @@ -31,7 +32,6 @@ #include "parachain/availability/proof.hpp" #include "parachain/candidate_view.hpp" #include "parachain/peer_relay_parent_knowledge.hpp" -#include "scale/scale.hpp" #include "utils/async_sequence.hpp" #include "utils/map.hpp" #include "utils/pool_handler.hpp" diff --git a/core/primitives/apply_result.hpp b/core/primitives/apply_result.hpp index f8be859f0d..7faa7e00f4 100644 --- a/core/primitives/apply_result.hpp +++ b/core/primitives/apply_result.hpp @@ -8,10 +8,10 @@ #include +#include #include "primitives/arithmetic_error.hpp" #include "primitives/token_error.hpp" #include "primitives/transaction_validity.hpp" -#include "scale/scale.hpp" #include "scale/tie.hpp" namespace kagome::primitives { diff --git a/core/primitives/code_substitutes.hpp b/core/primitives/code_substitutes.hpp index 430228976f..d69f7cb0aa 100644 --- a/core/primitives/code_substitutes.hpp +++ b/core/primitives/code_substitutes.hpp @@ -9,7 +9,7 @@ #include #include -#include "block_id.hpp" +#include "primitives/block_id.hpp" namespace kagome::primitives { diff --git a/core/primitives/digest.hpp b/core/primitives/digest.hpp index 0b7679cc2e..dd8e2ace63 100644 --- a/core/primitives/digest.hpp +++ b/core/primitives/digest.hpp @@ -8,6 +8,7 @@ #include +#include #include "common/buffer.hpp" #include "common/tagged.hpp" #include "common/unused.hpp" @@ -17,7 +18,6 @@ #include "consensus/babe/types/scheduled_change.hpp" #include "consensus/constants.hpp" #include "consensus/grandpa/types/scheduled_change.hpp" -#include "scale/scale.hpp" #include "scale/std_variant.hpp" #include "scale/tie.hpp" diff --git a/core/primitives/inherent_data.hpp b/core/primitives/inherent_data.hpp index 6e63f895c7..a1e211ef8b 100644 --- a/core/primitives/inherent_data.hpp +++ b/core/primitives/inherent_data.hpp @@ -12,11 +12,11 @@ #include #include #include +#include +#include #include "common/blob.hpp" #include "common/buffer.hpp" #include "common/outcome_throw.hpp" -#include "scale/scale.hpp" -#include "scale/scale_error.hpp" namespace kagome::primitives { /** diff --git a/core/runtime/common/core_api_factory_impl.cpp b/core/runtime/common/core_api_factory_impl.cpp index 66439b7222..9eb565bbca 100644 --- a/core/runtime/common/core_api_factory_impl.cpp +++ b/core/runtime/common/core_api_factory_impl.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "core_api_factory_impl.hpp" +#include "runtime/common/core_api_factory_impl.hpp" #include "runtime/common/uncompress_code_if_needed.hpp" #include "runtime/heap_alloc_strategy_heappages.hpp" diff --git a/core/runtime/common/executor.cpp b/core/runtime/common/executor.cpp index 17c7aa45b1..f788ad2280 100644 --- a/core/runtime/common/executor.cpp +++ b/core/runtime/common/executor.cpp @@ -6,6 +6,7 @@ #include "runtime/executor.hpp" +#include #include "blockchain/block_header_repository.hpp" #include "common/buffer.hpp" #include "host_api/host_api.hpp" @@ -15,7 +16,6 @@ #include "runtime/module_repository.hpp" #include "runtime/runtime_context.hpp" #include "runtime/trie_storage_provider.hpp" -#include "scale/scale.hpp" #include "storage/trie/trie_batches.hpp" namespace kagome::runtime { diff --git a/core/runtime/common/runtime_properties_cache_impl.cpp b/core/runtime/common/runtime_properties_cache_impl.cpp index 7fb87b3f9d..52aadd8d9e 100644 --- a/core/runtime/common/runtime_properties_cache_impl.cpp +++ b/core/runtime/common/runtime_properties_cache_impl.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "runtime_properties_cache_impl.hpp" +#include "runtime/common/runtime_properties_cache_impl.hpp" namespace kagome::runtime { diff --git a/core/runtime/runtime_api/impl/parachain_host_types_serde.hpp b/core/runtime/runtime_api/impl/parachain_host_types_serde.hpp index 1613653ec0..35750e7a3e 100644 --- a/core/runtime/runtime_api/impl/parachain_host_types_serde.hpp +++ b/core/runtime/runtime_api/impl/parachain_host_types_serde.hpp @@ -6,8 +6,8 @@ #pragma once +#include #include "runtime/runtime_api/parachain_host_types.hpp" -#include "scale/scale.hpp" namespace kagome::runtime { diff --git a/core/runtime/wasm_edge/module_factory_impl.cpp b/core/runtime/wasm_edge/module_factory_impl.cpp index 770968a3c9..e41e31dd6d 100644 --- a/core/runtime/wasm_edge/module_factory_impl.cpp +++ b/core/runtime/wasm_edge/module_factory_impl.cpp @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "module_factory_impl.hpp" +#include "runtime/wasm_edge/module_factory_impl.hpp" #include diff --git a/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.cpp b/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.cpp index e2494974a8..9ca9c870f2 100644 --- a/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.cpp +++ b/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.cpp @@ -4,15 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "intrinsic_resolver_impl.hpp" +#include "runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp" #include #include #include #include -#include "intrinsic_module_instance.hpp" #include "runtime/wavm/compartment_wrapper.hpp" +#include "runtime/wavm/intrinsics/intrinsic_module_instance.hpp" namespace kagome::runtime::wavm { diff --git a/core/scale/kagome_scale.hpp b/core/scale/kagome_scale.hpp index d5adba070e..f33aedcd7c 100644 --- a/core/scale/kagome_scale.hpp +++ b/core/scale/kagome_scale.hpp @@ -7,6 +7,7 @@ #ifndef KAGOME_KAGOME_SCALE_HPP #define KAGOME_KAGOME_SCALE_HPP +#include #include #include #include "common/blob.hpp" @@ -19,7 +20,6 @@ #include "primitives/justification.hpp" #include "runtime/runtime_api/parachain_host_types.hpp" #include "scale/big_fixed_integers.hpp" -#include "scale/encode_append.hpp" #include "scale/libp2p_types.hpp" namespace kagome::scale { diff --git a/core/scale/libp2p_types.hpp b/core/scale/libp2p_types.hpp index fc102bb8f0..d1bc486350 100644 --- a/core/scale/libp2p_types.hpp +++ b/core/scale/libp2p_types.hpp @@ -7,7 +7,7 @@ #pragma once #include -#include "scale/scale.hpp" +#include namespace scale { diff --git a/core/storage/in_memory/in_memory_spaced_storage.hpp b/core/storage/in_memory/in_memory_spaced_storage.hpp index 0a257c6866..ea769fc7a5 100644 --- a/core/storage/in_memory/in_memory_spaced_storage.hpp +++ b/core/storage/in_memory/in_memory_spaced_storage.hpp @@ -6,12 +6,7 @@ #pragma once -#include - -#include - #include "common/buffer.hpp" -#include "in_memory_storage.hpp" #include "outcome/outcome.hpp" #include "storage/buffer_map_types.hpp" #include "storage/in_memory/in_memory_storage.hpp" diff --git a/core/storage/rocksdb/rocksdb_cursor.cpp b/core/storage/rocksdb/rocksdb_cursor.cpp index c03ba6f87e..1be2eb7d30 100644 --- a/core/storage/rocksdb/rocksdb_cursor.cpp +++ b/core/storage/rocksdb/rocksdb_cursor.cpp @@ -6,7 +6,7 @@ #include "storage/rocksdb/rocksdb_cursor.hpp" -#include "rocksdb_util.hpp" +#include "storage/rocksdb/rocksdb_util.hpp" namespace kagome::storage { diff --git a/core/storage/trie/serialization/ordered_trie_hash.hpp b/core/storage/trie/serialization/ordered_trie_hash.hpp index 995c2c7788..bcc64dd42a 100644 --- a/core/storage/trie/serialization/ordered_trie_hash.hpp +++ b/core/storage/trie/serialization/ordered_trie_hash.hpp @@ -8,9 +8,9 @@ #include +#include #include "common/buffer.hpp" #include "crypto/hasher.hpp" -#include "scale/scale.hpp" #include "storage/trie/polkadot_trie/polkadot_trie_impl.hpp" #include "storage/trie/serialization/polkadot_codec.hpp" #include "storage/trie/types.hpp" diff --git a/core/storage/trie/serialization/polkadot_codec.cpp b/core/storage/trie/serialization/polkadot_codec.cpp index 2b85843401..02f25da879 100644 --- a/core/storage/trie/serialization/polkadot_codec.cpp +++ b/core/storage/trie/serialization/polkadot_codec.cpp @@ -6,10 +6,10 @@ #include "storage/trie/serialization/polkadot_codec.hpp" +#include +#include #include "crypto/blake2/blake2b.h" #include "log/logger.hpp" -#include "scale/scale.hpp" -#include "scale/scale_decoder_stream.hpp" #include "storage/trie/polkadot_trie/trie_node.hpp" OUTCOME_CPP_DEFINE_CATEGORY(kagome::storage::trie, PolkadotCodec::Error, e) { diff --git a/core/storage/trie/serialization/polkadot_codec.hpp b/core/storage/trie/serialization/polkadot_codec.hpp index b2e49585e1..0665ba6638 100644 --- a/core/storage/trie/serialization/polkadot_codec.hpp +++ b/core/storage/trie/serialization/polkadot_codec.hpp @@ -10,10 +10,10 @@ #include #include -#include "codec.hpp" #include "crypto/blake2/blake2b.h" #include "storage/trie/polkadot_trie/trie_node.hpp" #include "storage/trie/serialization/buffer_stream.hpp" +#include "storage/trie/serialization/codec.hpp" namespace kagome::storage::trie { diff --git a/test/core/api/service/author/author_api_test.cpp b/test/core/api/service/author/author_api_test.cpp index ba166bdec4..3225bdf680 100644 --- a/test/core/api/service/author/author_api_test.cpp +++ b/test/core/api/service/author/author_api_test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "common/blob.hpp" @@ -32,7 +33,6 @@ #include "subscription/subscription_engine.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/outcome/dummy_error.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/primitives/mp_utils.hpp" @@ -145,10 +145,9 @@ struct AuthorApiTest : public ::testing::Test { store = std::make_shared(); key_store = KeyFileStorage::createAt("test_chain_43/keystore").value(); key_pair = generateSr25519Keypair(0); - ASSERT_OUTCOME_SUCCESS_TRY( - key_store->saveKeyPair(KeyTypes::BABE, - std::span(key_pair.public_key).first<32>(), - std::array{1})); + EXPECT_OK(key_store->saveKeyPair(KeyTypes::BABE, + std::span(key_pair.public_key).first<32>(), + std::array{1})); role.flags.authority = 1; EXPECT_CALL(*config, roles()).WillOnce(Return(role)); keys = std::make_shared(store, *config); @@ -178,10 +177,9 @@ TEST_F(AuthorApiTest, SubmitExtrinsicSuccess) { EXPECT_CALL(*transaction_pool, submitExtrinsic(TransactionSource::External, *extrinsic)) .WillOnce(Return(outcome::success())); - EXPECT_OUTCOME_SUCCESS( - hash, + auto hash = EXPECT_OK( author_api->submitExtrinsic(TransactionSource::External, *extrinsic)); - ASSERT_EQ(hash.value(), Hash256{}); + ASSERT_EQ(hash, Hash256{}); } /** @@ -194,8 +192,7 @@ TEST_F(AuthorApiTest, SubmitExtrinsicSuccess) { TEST_F(AuthorApiTest, SubmitExtrinsicFail) { EXPECT_CALL(*transaction_pool, submitExtrinsic(_, _)) .WillOnce(Return(outcome::failure(DummyError::ERROR))); - EXPECT_OUTCOME_ERROR( - res, + EXPECT_EC( author_api->submitExtrinsic(TransactionSource::External, *extrinsic), DummyError::ERROR); } @@ -210,10 +207,8 @@ MATCHER_P(eventsAreEqual, n, "") { * @then corresponing error is returned */ TEST_F(AuthorApiTest, InsertKeyUnsupported) { - EXPECT_OUTCOME_ERROR( - res, - author_api->insertKey(KeyType::fromString("unkn").value(), {}, {}), - KeyStoreError::UNSUPPORTED_KEY_TYPE); + EXPECT_EC(author_api->insertKey(KeyType::fromString("unkn").value(), {}, {}), + KeyStoreError::UNSUPPORTED_KEY_TYPE); } /** @@ -226,10 +221,8 @@ TEST_F(AuthorApiTest, InsertKeyBabe) { Sr25519PublicKey public_key; EXPECT_CALL(store->sr25519(), generateKeypair(KeyTypes::BABE, seed)) .WillOnce(Return(Sr25519Keypair{{}, public_key})); - EXPECT_OUTCOME_SUCCESS( - res, - author_api->insertKey( - KeyTypes::BABE, SecureBuffer<>{seed.unsafeBytes()}, public_key)); + EXPECT_OK(author_api->insertKey( + KeyTypes::BABE, SecureBuffer<>{seed.unsafeBytes()}, public_key)); } /** @@ -243,11 +236,9 @@ TEST_F(AuthorApiTest, InsertKeyAudi) { EXPECT_CALL(store->sr25519(), generateKeypair(KeyTypes::AUTHORITY_DISCOVERY, seed)) .WillOnce(Return(Sr25519Keypair{{}, public_key})); - EXPECT_OUTCOME_SUCCESS( - res, - author_api->insertKey(KeyTypes::AUTHORITY_DISCOVERY, - SecureBuffer<>{seed.unsafeBytes()}, - public_key)); + EXPECT_OK(author_api->insertKey(KeyTypes::AUTHORITY_DISCOVERY, + SecureBuffer<>{seed.unsafeBytes()}, + public_key)); } /** @@ -260,10 +251,8 @@ TEST_F(AuthorApiTest, InsertKeyGran) { Ed25519PublicKey public_key; EXPECT_CALL(store->ed25519(), generateKeypair(KeyTypes::GRANDPA, seed)) .WillOnce(Return(Ed25519Keypair{{}, public_key})); - EXPECT_OUTCOME_SUCCESS( - res, - author_api->insertKey( - KeyTypes::GRANDPA, SecureBuffer<>{seed.unsafeBytes()}, public_key)); + EXPECT_OK(author_api->insertKey( + KeyTypes::GRANDPA, SecureBuffer<>{seed.unsafeBytes()}, public_key)); } /** @@ -274,8 +263,8 @@ TEST_F(AuthorApiTest, InsertKeyGran) { */ TEST_F(AuthorApiTest, HasSessionKeysEmpty) { Buffer keys; - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, false); } /** @@ -287,8 +276,8 @@ TEST_F(AuthorApiTest, HasSessionKeysEmpty) { TEST_F(AuthorApiTest, HasSessionKeysLessThanOne) { Buffer keys; keys.resize(31); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, false); } /** @@ -300,8 +289,8 @@ TEST_F(AuthorApiTest, HasSessionKeysLessThanOne) { TEST_F(AuthorApiTest, HasSessionKeysOverload) { Buffer keys; keys.resize(32 * 6 + 1); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, false); } /** @@ -313,8 +302,8 @@ TEST_F(AuthorApiTest, HasSessionKeysOverload) { TEST_F(AuthorApiTest, HasSessionKeysNotEqualKeys) { Buffer keys; keys.resize(32 * 5 + 1); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, false); } /** @@ -346,8 +335,8 @@ TEST_F(AuthorApiTest, HasSessionKeysSuccess6Keys) { EXPECT_CALL(store->sr25519(), findKeypair(KeyTypes::AUTHORITY_DISCOVERY, _)) .Times(1) .WillOnce(Return(OptRef(srOk))); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), true); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, true); } /** @@ -362,8 +351,8 @@ TEST_F(AuthorApiTest, HasSessionKeysSuccess1Keys) { EXPECT_CALL(store->ed25519(), findKeypair(KeyTypes::GRANDPA, _)) .Times(1) .WillOnce(Return(edOk)); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), true); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, true); } /** @@ -382,8 +371,8 @@ TEST_F(AuthorApiTest, HasSessionKeysFailureNotFound) { EXPECT_CALL(store->sr25519(), findKeypair(_, _)) .Times(1) .WillOnce(Return(srErr)); - EXPECT_OUTCOME_SUCCESS(res, author_api->hasSessionKeys(keys)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasSessionKeys(keys)); + EXPECT_EQ(res, false); } /** @@ -392,11 +381,9 @@ TEST_F(AuthorApiTest, HasSessionKeysFailureNotFound) { * @then call succeeds, true result */ TEST_F(AuthorApiTest, HasKeySuccess) { - EXPECT_OUTCOME_SUCCESS( - res, - author_api->hasKey(std::span(key_pair.public_key).first<32>(), - KeyTypes::BABE)); - EXPECT_EQ(res.value(), true); + auto res = EXPECT_OK(author_api->hasKey( + std::span(key_pair.public_key).first<32>(), KeyTypes::BABE)); + EXPECT_EQ(res, true); } /** @@ -405,8 +392,8 @@ TEST_F(AuthorApiTest, HasKeySuccess) { * @then call succeeds, false result */ TEST_F(AuthorApiTest, HasKeyFail) { - EXPECT_OUTCOME_SUCCESS(res, author_api->hasKey({}, KeyTypes::BABE)); - EXPECT_EQ(res.value(), false); + auto res = EXPECT_OK(author_api->hasKey({}, KeyTypes::BABE)); + EXPECT_EQ(res, false); } /** @@ -458,8 +445,7 @@ TEST_F(AuthorApiTest, SubmitAndWatchExtrinsicSubmitsAndWatches) { .WillOnce(Return(sub_id)); // throws because api service is uninitialized - ASSERT_OUTCOME_SUCCESS(ret_sub_id, - author_api->submitAndWatchExtrinsic(*extrinsic)); + auto ret_sub_id = EXPECT_OK(author_api->submitAndWatchExtrinsic(*extrinsic)); ASSERT_EQ(sub_id, ret_sub_id); } @@ -473,7 +459,7 @@ TEST_F(AuthorApiTest, PendingExtrinsics) { EXPECT_CALL(*transaction_pool, getPendingTransactions(_)); - ASSERT_OUTCOME_SUCCESS(actual_result, author_api->pendingExtrinsics()); + auto actual_result = EXPECT_OK(author_api->pendingExtrinsics()); ASSERT_EQ(expected_result, actual_result); } diff --git a/test/core/api/service/chain/base_request_test.cpp b/test/core/api/service/chain/base_request_test.cpp index 44fc486983..ee1e4bc740 100644 --- a/test/core/api/service/chain/base_request_test.cpp +++ b/test/core/api/service/chain/base_request_test.cpp @@ -5,10 +5,10 @@ */ #include +#include #include "api/service/base_request.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::common::Buffer; struct BaseRequestTest : public ::testing::Test { @@ -39,7 +39,7 @@ TEST_F(BaseRequestTest, Params_Int) { params.emplace_back(test_val); TestRequestInt32 tr; - ASSERT_OUTCOME_SUCCESS_TRY(tr.init(params)); + EXPECT_OK(tr.init(params)); ASSERT_EQ(tr.getParam<0>(), test_val); } @@ -56,7 +56,7 @@ TEST_F(BaseRequestTest, Params_Str) { params.emplace_back(test_val); TestRequestStr tr; - ASSERT_OUTCOME_SUCCESS_TRY(tr.init(params)); + EXPECT_OK(tr.init(params)); ASSERT_EQ(tr.getParam<0>(), test_val); } @@ -73,6 +73,6 @@ TEST_F(BaseRequestTest, Params_Invalid) { params.emplace_back(test_val); TestRequestInt32 tr; - auto init = [&] { ASSERT_OUTCOME_SUCCESS_TRY(tr.init(params)); }; + auto init = [&] { EXPECT_OK(tr.init(params)); }; EXPECT_THROW(init(), jsonrpc::InvalidParametersFault); } diff --git a/test/core/api/service/chain/chain_api_test.cpp b/test/core/api/service/chain/chain_api_test.cpp index bb080bc47d..e76ef7898f 100644 --- a/test/core/api/service/chain/chain_api_test.cpp +++ b/test/core/api/service/chain/chain_api_test.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include "api/service/chain/impl/chain_api_impl.hpp" #include "api/service/chain/requests/subscribe_finalized_heads.hpp" @@ -20,7 +20,6 @@ #include "primitives/extrinsic.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::api::ApiService; using kagome::api::ApiServiceMock; @@ -97,7 +96,7 @@ TEST_F(ChainApiTest, GetBlockHashNoParam) { EXPECT_CALL(*block_tree, getLastFinalized()) .WillOnce(Return(BlockInfo(42, "D"_hash256))); - EXPECT_OUTCOME_TRUE(r, api->getBlockHash()); + auto r = EXPECT_OK(api->getBlockHash()); ASSERT_EQ(r, "D"_hash256); } @@ -111,7 +110,7 @@ TEST_F(ChainApiTest, GetBlockHashByNumber) { EXPECT_CALL(*header_repo, getHashByNumber(42)) .WillOnce(Return("CDE"_hash256)); - EXPECT_OUTCOME_TRUE(r, api->getBlockHash(42)); + auto r = EXPECT_OK(api->getBlockHash(42)); ASSERT_EQ(r, "CDE"_hash256); } @@ -124,7 +123,7 @@ TEST_F(ChainApiTest, GetBlockHashByHexNumber) { EXPECT_CALL(*header_repo, getHashByNumber(42)) .WillOnce(Return("CDE"_hash256)); - EXPECT_OUTCOME_TRUE(r, api->getBlockHash("0x2a")); + auto r = EXPECT_OK(api->getBlockHash("0x2a")); ASSERT_EQ(r, "CDE"_hash256); } @@ -139,8 +138,7 @@ TEST_F(ChainApiTest, GetBlockHashArray) { EXPECT_CALL(*header_repo, getHashByNumber(200)).WillOnce(Return(hash3)); std::vector> request_data = { 50, "0x64", 200}; - EXPECT_OUTCOME_TRUE( - r, + auto r = EXPECT_OK( api->getBlockHash(std::vector>( {50, "0x64", 200}))); ASSERT_EQ(r, std::vector({hash1, hash2, hash3})); @@ -155,7 +153,7 @@ TEST_F(ChainApiTest, GetHeader) { BlockHash a = hash1; EXPECT_CALL(*header_repo, getBlockHeader(a)).WillOnce(Return(*data.header)); - EXPECT_OUTCOME_TRUE(r, api->getHeader(std::string("0x") + hash1.toHex())); + auto r = EXPECT_OK(api->getHeader(std::string("0x") + hash1.toHex())); ASSERT_EQ(r, *data.header); } @@ -171,7 +169,7 @@ TEST_F(ChainApiTest, GetHeaderLats) { EXPECT_CALL(*header_repo, getBlockHeader(a)).WillOnce(Return(*data.header)); - EXPECT_OUTCOME_TRUE(r, api->getHeader()); + auto r = EXPECT_OK(api->getHeader()); ASSERT_EQ(r, *data.header); } @@ -184,7 +182,7 @@ TEST_F(ChainApiTest, GetBlock) { BlockHash a = hash1; EXPECT_CALL(*block_storage, getBlockData(a)).WillOnce(Return(data)); - EXPECT_OUTCOME_TRUE(r, api->getBlock(std::string("0x") + hash1.toHex())); + auto r = EXPECT_OK(api->getBlock(std::string("0x") + hash1.toHex())); ASSERT_EQ(r, data); } @@ -200,7 +198,7 @@ TEST_F(ChainApiTest, GetLastBlock) { EXPECT_CALL(*block_storage, getBlockData(a)).WillOnce(Return(data)); - EXPECT_OUTCOME_TRUE(r, api->getBlock()); + auto r = EXPECT_OK(api->getBlock()); ASSERT_EQ(r, data); } @@ -218,8 +216,8 @@ TEST(StateApiTest, SubscribeStorage) { auto sub = std::make_shared(p); jsonrpc::Request::Parameters params; - EXPECT_OUTCOME_SUCCESS(r, sub->init(params)); - EXPECT_OUTCOME_TRUE(result, sub->execute()); + EXPECT_OK(sub->init(params)); + auto result = EXPECT_OK(sub->execute()); ASSERT_EQ(result, 55); } @@ -233,9 +231,9 @@ TEST_F(ChainApiTest, GetFinalizedHead) { EXPECT_CALL(*block_tree, getLastFinalized()) .WillOnce(Return(BlockInfo{10, expected_result})); - EXPECT_OUTCOME_SUCCESS(result, api->getFinalizedHead()); + auto result = EXPECT_OK(api->getFinalizedHead()); ASSERT_TRUE(std::equal( - expected_result.begin(), expected_result.end(), result.value().begin())); + expected_result.begin(), expected_result.end(), result.begin())); } /** @@ -264,7 +262,7 @@ TEST_F(ChainApiTest, SubscribeNewHeads) { EXPECT_CALL(*api_service, subscribeNewHeads()) .WillOnce(Return(expected_result)); - ASSERT_OUTCOME_SUCCESS(actual_result, api->subscribeNewHeads()); + auto actual_result = EXPECT_OK(api->subscribeNewHeads()); ASSERT_EQ(expected_result, actual_result); } @@ -280,6 +278,5 @@ TEST_F(ChainApiTest, UnsubscribeNewHeads) { EXPECT_CALL(*api_service, unsubscribeNewHeads(subscription_id)) .WillOnce(Return(expected_return)); - EXPECT_OUTCOME_ERROR( - result, api->unsubscribeNewHeads(subscription_id), expected_return); + EXPECT_EC(api->unsubscribeNewHeads(subscription_id), expected_return); } diff --git a/test/core/api/service/child_state/child_state_api_test.cpp b/test/core/api/service/child_state/child_state_api_test.cpp index 400929040d..5859ca8f0b 100644 --- a/test/core/api/service/child_state/child_state_api_test.cpp +++ b/test/core/api/service/child_state/child_state_api_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include "api/service/child_state/impl/child_state_api_impl.hpp" #include "core/storage/trie/polkadot_trie_cursor_dummy.hpp" @@ -19,7 +20,6 @@ #include "primitives/block_header.hpp" #include "runtime/runtime_context.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::api::ChildStateApiMock; using kagome::blockchain::BlockHeaderRepositoryMock; @@ -102,8 +102,8 @@ namespace kagome::api { return batch; })); - EXPECT_OUTCOME_SUCCESS(r, api_->getStorage("a"_buf, "b"_buf, std::nullopt)); - ASSERT_EQ(r.value().value(), "2"_buf); + auto r = EXPECT_OK(api_->getStorage("a"_buf, "b"_buf, std::nullopt)); + ASSERT_EQ(*r, "2"_buf); } TEST_F(ChildStateApiTest, GetStorageAt) { @@ -129,10 +129,8 @@ namespace kagome::api { return batch; })); - EXPECT_OUTCOME_TRUE( - r1, - api_->getStorage( - "c"_buf, "d"_buf, std::optional{"B"_hash256})); + auto r1 = EXPECT_OK(api_->getStorage( + "c"_buf, "d"_buf, std::optional{"B"_hash256})); ASSERT_EQ(r1.value(), "4"_buf); } @@ -277,8 +275,8 @@ namespace kagome::api { return batch; })); - ASSERT_OUTCOME_SUCCESS( - size_opt, api_->getStorageSize(child_storage_key, key, block_hash_opt)); + auto size_opt = + EXPECT_OK(api_->getStorageSize(child_storage_key, key, block_hash_opt)); ASSERT_TRUE(size_opt.has_value()); ASSERT_EQ(expected_result.size(), size_opt.value()); } diff --git a/test/core/api/service/payment/payment_api_test.cpp b/test/core/api/service/payment/payment_api_test.cpp index 555a6811b2..643742bc6c 100644 --- a/test/core/api/service/payment/payment_api_test.cpp +++ b/test/core/api/service/payment/payment_api_test.cpp @@ -7,11 +7,11 @@ #include "api/service/payment/impl/payment_api_impl.hpp" #include +#include #include "mock/core/blockchain/block_tree_mock.hpp" #include "mock/core/runtime/transaction_payment_api_mock.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::api::PaymentApi; using kagome::api::PaymentApiImpl; @@ -61,8 +61,8 @@ TEST_F(PaymentApiTest, QueryInfo) { query_info(deepest_hash, extrinsic, len)) .WillOnce(Return(expected_result)); - ASSERT_OUTCOME_SUCCESS(result, - payment_api_->queryInfo(extrinsic, len, std::nullopt)); + auto result = + EXPECT_OK(payment_api_->queryInfo(extrinsic, len, std::nullopt)); ASSERT_EQ(result, expected_result); } diff --git a/test/core/api/service/state/state_api_test.cpp b/test/core/api/service/state/state_api_test.cpp index 1acb19b02d..ee213344ce 100644 --- a/test/core/api/service/state/state_api_test.cpp +++ b/test/core/api/service/state/state_api_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include "api/service/state/impl/state_api_impl.hpp" @@ -25,7 +26,6 @@ #include "runtime/runtime_context.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::api::ApiServiceMock; using kagome::api::StateApiMock; @@ -109,13 +109,13 @@ namespace kagome::api { })); auto key = "a"_buf; - EXPECT_OUTCOME_TRUE(r, api_->getStorage(key.view())) + auto r = EXPECT_OK(api_->getStorage(key.view())); ASSERT_EQ(r.value(), "1"_buf); EXPECT_CALL(*block_header_repo_, getBlockHeader("B"_hash256)) .WillOnce(testing::Return(makeBlockHeaderOfStateRoot("ABC"_hash256))); - EXPECT_OUTCOME_TRUE(r1, api_->getStorageAt(key.view(), "B"_hash256)); + auto r1 = EXPECT_OK(api_->getStorageAt(key.view(), "B"_hash256)); ASSERT_EQ(r1.value(), "1"_buf); } @@ -186,8 +186,8 @@ namespace kagome::api { * @then expected amount of keys from beginning of cursor are returned */ TEST_F(GetKeysPagedTest, EmptyParamsTest) { - EXPECT_OUTCOME_TRUE( - val, api_->getKeysPaged(std::nullopt, 2, std::nullopt, std::nullopt)); + auto val = EXPECT_OK( + api_->getKeysPaged(std::nullopt, 2, std::nullopt, std::nullopt)); ASSERT_THAT(val, ElementsAre("0102"_hex2buf, "0103"_hex2buf)); } @@ -197,8 +197,8 @@ namespace kagome::api { * @then expected amount of keys with provided prefix are returned */ TEST_F(GetKeysPagedTest, NonEmptyPrefixTest) { - EXPECT_OUTCOME_TRUE( - val, api_->getKeysPaged("0607"_hex2buf, 3, std::nullopt, std::nullopt)); + auto val = EXPECT_OK( + api_->getKeysPaged("0607"_hex2buf, 3, std::nullopt, std::nullopt)); ASSERT_THAT( val, ElementsAre("0607"_hex2buf, "060708"_hex2buf, "06070801"_hex2buf)); } @@ -209,8 +209,8 @@ namespace kagome::api { * @then exepected amount of keys after provided prev_key are returned */ TEST_F(GetKeysPagedTest, NonEmptyPrevKeyTest) { - EXPECT_OUTCOME_TRUE( - val, api_->getKeysPaged("06"_hex2buf, 3, "0607"_hex2buf, std::nullopt)); + auto val = EXPECT_OK( + api_->getKeysPaged("06"_hex2buf, 3, "0607"_hex2buf, std::nullopt)); ASSERT_THAT( val, ElementsAre("060708"_hex2buf, "06070801"_hex2buf, "06070802"_hex2buf)); @@ -224,8 +224,7 @@ namespace kagome::api { * returned */ TEST_F(GetKeysPagedTest, PrefixBiggerThanPrevkey) { - EXPECT_OUTCOME_TRUE( - val, + auto val = EXPECT_OK( api_->getKeysPaged("060708"_hex2buf, 5, "06"_hex2buf, std::nullopt)); ASSERT_THAT(val, ElementsAre("060708"_hex2buf, @@ -253,7 +252,7 @@ namespace kagome::api { .WillOnce(testing::Return(test_version)); { - EXPECT_OUTCOME_TRUE(result, api_->getRuntimeVersion(std::nullopt)); + auto result = EXPECT_OK(api_->getRuntimeVersion(std::nullopt)); ASSERT_EQ(result, test_version); } @@ -262,7 +261,7 @@ namespace kagome::api { .WillOnce(testing::Return(test_version)); { - EXPECT_OUTCOME_TRUE(result, api_->getRuntimeVersion("T"_hash256)); + auto result = EXPECT_OK(api_->getRuntimeVersion("T"_hash256)); ASSERT_EQ(result, test_version); } } @@ -290,8 +289,8 @@ namespace kagome::api { jsonrpc::Value::Array{std::string("0x") + keys[0].toHex(), std::string("0x") + keys[1].toHex()}); - EXPECT_OUTCOME_SUCCESS(r, subscribe_storage->init(params)); - EXPECT_OUTCOME_TRUE(result, subscribe_storage->execute()); + EXPECT_OK(subscribe_storage->init(params)); + auto result = EXPECT_OK(subscribe_storage->execute()); ASSERT_EQ(result, 55); } @@ -308,9 +307,7 @@ namespace kagome::api { jsonrpc::Request::Parameters params; params.push_back(jsonrpc::Value::Array{std::string("test_data")}); - EXPECT_OUTCOME_ERROR(result, - subscribe_storage->init(params), - qtils::UnhexError::REQUIRED_0X); + EXPECT_EC(subscribe_storage->init(params), qtils::UnhexError::REQUIRED_0X); } /** @@ -326,9 +323,7 @@ namespace kagome::api { jsonrpc::Request::Parameters params; params.push_back(jsonrpc::Value::Array{std::string("aa1122334455")}); - EXPECT_OUTCOME_ERROR(result, - subscribe_storage->init(params), - qtils::UnhexError::REQUIRED_0X); + EXPECT_EC(subscribe_storage->init(params), qtils::UnhexError::REQUIRED_0X); } /** @@ -344,8 +339,7 @@ namespace kagome::api { jsonrpc::Request::Parameters params; params.push_back(jsonrpc::Value::Array{std::string("0xtestdata")}); - EXPECT_OUTCOME_ERROR( - result, subscribe_storage->init(params), qtils::UnhexError::NON_HEX); + EXPECT_EC(subscribe_storage->init(params), qtils::UnhexError::NON_HEX); } /** @@ -363,8 +357,8 @@ namespace kagome::api { jsonrpc::Request::Parameters params; EXPECT_CALL(*state_api, getMetadata()).WillOnce(testing::Return(data)); - EXPECT_OUTCOME_SUCCESS(r, get_metadata->init(params)); - EXPECT_OUTCOME_TRUE(result, get_metadata->execute()); + EXPECT_OK(get_metadata->init(params)); + auto result = EXPECT_OK(get_metadata->execute()); ASSERT_EQ(result, data); } @@ -410,7 +404,7 @@ namespace kagome::api { })); } // WHEN - EXPECT_OUTCOME_TRUE(changes, api_->queryStorage(keys, from, to)) + auto changes = EXPECT_OK(api_->queryStorage(keys, from, to)); // THEN auto current_block = block_range.begin(); @@ -435,9 +429,8 @@ namespace kagome::api { .WillOnce(Return(42)); EXPECT_CALL(*block_header_repo_, getNumberByHash(to)) .WillOnce(Return(42 + StateApiImpl::kMaxBlockRange + 1)); - EXPECT_OUTCOME_FALSE( - error, api_->queryStorage(std::vector({"some_key"_buf}), from, to)); - ASSERT_EQ(error, StateApiImpl::Error::MAX_BLOCK_RANGE_EXCEEDED); + EXPECT_EC(api_->queryStorage(std::vector({"some_key"_buf}), from, to), + StateApiImpl::Error::MAX_BLOCK_RANGE_EXCEEDED); } /** @@ -448,8 +441,8 @@ namespace kagome::api { TEST_F(StateApiTest, HitsKeyRangeLimits) { std::vector keys(StateApiImpl::kMaxKeySetSize + 1); primitives::BlockHash from{"from"_hash256}, to{"to"_hash256}; - EXPECT_OUTCOME_FALSE(error, api_->queryStorage(keys, from, to)); - ASSERT_EQ(error, StateApiImpl::Error::MAX_KEY_SET_SIZE_EXCEEDED); + EXPECT_EC(api_->queryStorage(keys, from, to), + StateApiImpl::Error::MAX_KEY_SET_SIZE_EXCEEDED); } /** @@ -480,7 +473,7 @@ namespace kagome::api { })); // WHEN - EXPECT_OUTCOME_TRUE(changes, api_->queryStorageAt(keys, at)) + auto changes = EXPECT_OK(api_->queryStorageAt(keys, at)); // THEN ASSERT_EQ(changes.size(), 1); @@ -503,7 +496,7 @@ namespace kagome::api { EXPECT_CALL(*api_service_, unsubscribeSessionFromIds(subscription_id)) .WillOnce(Return(expected_return)); - ASSERT_OUTCOME_SUCCESS(result, api_->unsubscribeStorage(subscription_id)); + auto result = EXPECT_OK(api_->unsubscribeStorage(subscription_id)); ASSERT_EQ(expected_return, result); } @@ -518,7 +511,7 @@ namespace kagome::api { EXPECT_CALL(*api_service_, subscribeRuntimeVersion()) .WillOnce(Return(expected_return)); - ASSERT_OUTCOME_SUCCESS(result, api_->subscribeRuntimeVersion()); + auto result = EXPECT_OK(api_->subscribeRuntimeVersion()); ASSERT_EQ(expected_return, result); } @@ -534,9 +527,8 @@ namespace kagome::api { EXPECT_CALL(*api_service_, unsubscribeRuntimeVersion(subscription_id)) .WillOnce(Return(expected_return)); - EXPECT_OUTCOME_ERROR(result, - api_->unsubscribeRuntimeVersion(subscription_id), - expected_return); + EXPECT_EC(api_->unsubscribeRuntimeVersion(subscription_id), + expected_return); } } // namespace kagome::api diff --git a/test/core/api/service/state/state_jrpc_processor_test.cpp b/test/core/api/service/state/state_jrpc_processor_test.cpp index d3c763271b..9801d7f0e6 100644 --- a/test/core/api/service/state/state_jrpc_processor_test.cpp +++ b/test/core/api/service/state/state_jrpc_processor_test.cpp @@ -11,12 +11,12 @@ #include #include #include +#include #include "api/service/state/requests/query_storage.hpp" // for makeValue #include "mock/core/api/jrpc/jrpc_server_mock.hpp" #include "mock/core/api/service/state/state_api_mock.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::api::JRpcServer; using kagome::api::JRpcServerMock; @@ -173,7 +173,7 @@ TEST_F(StateJrpcProcessorTest, ProcessRequest) { jsonrpc::Request::Parameters params{"0x01234567"}; auto result_hex = execute(CallType::kCallType_GetStorage, params).AsString(); - EXPECT_OUTCOME_TRUE(result_vec, kagome::common::unhexWith0x(result_hex)); + auto result_vec = EXPECT_OK(kagome::common::unhexWith0x(result_hex)); ASSERT_EQ(expected_result.asVector(), result_vec); } @@ -194,7 +194,7 @@ TEST_F(StateJrpcProcessorTest, ProcessAnotherRequest) { jsonrpc::Request::Parameters params{"0x01234567", "0x" + ("010203"_hash256).toHex()}; auto result_hex = execute(CallType::kCallType_GetStorage, params).AsString(); - EXPECT_OUTCOME_TRUE(result_vec, kagome::common::unhexWith0x(result_hex)); + auto result_vec = EXPECT_OK(kagome::common::unhexWith0x(result_hex)); ASSERT_EQ(expected_result.asVector(), result_vec); } diff --git a/test/core/api/service/system/system_api_test.cpp b/test/core/api/service/system/system_api_test.cpp index 999978f6af..b60e65d311 100644 --- a/test/core/api/service/system/system_api_test.cpp +++ b/test/core/api/service/system/system_api_test.cpp @@ -7,7 +7,9 @@ #include "api/service/system/impl/system_api_impl.hpp" #include +#include +#include #include "mock/core/application/chain_spec_mock.hpp" #include "mock/core/blockchain/block_tree_mock.hpp" #include "mock/core/consensus/timeline/timeline_mock.hpp" @@ -16,9 +18,7 @@ #include "mock/core/runtime/account_nonce_api_mock.hpp" #include "mock/core/transaction_pool/transaction_pool_mock.hpp" #include "scale/kagome_scale.hpp" -#include "scale/scale.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/scale_test_comparator.hpp" using kagome::api::SystemApi; @@ -97,7 +97,7 @@ TEST_F(SystemApiTest, GetNonceNoPendingTxs) { .WillOnce(Return(kagome::common::Hash512{{'\035', '!'}})); EXPECT_CALL(*transaction_pool_mock_, getReadyTransactions()); - EXPECT_OUTCOME_TRUE(nonce, system_api_->getNonceFor(kSs58Account)) + auto nonce = EXPECT_OK(system_api_->getNonceFor(kSs58Account)); ASSERT_EQ(nonce, kInitialNonce); } @@ -125,9 +125,8 @@ TEST_F(SystemApiTest, GetNonceWithPendingTxs) { std::vector>> ready_txs; for (size_t i = 0; i < kReadyTxNum; i++) { - EXPECT_OUTCOME_TRUE( - enc_nonce, - testutil::scaleEncodeAndCompareWithRef(kAccountId, kInitialNonce + i)) + auto enc_nonce = EXPECT_OK( + testutil::scaleEncodeAndCompareWithRef(kAccountId, kInitialNonce + i)); encoded_nonces[i] = std::move(enc_nonce); ready_txs.emplace_back( std::make_pair(Hash256{{static_cast(i)}}, @@ -138,6 +137,6 @@ TEST_F(SystemApiTest, GetNonceWithPendingTxs) { EXPECT_CALL(*transaction_pool_mock_, getReadyTransactions()) .WillOnce(Return(ready_txs)); - EXPECT_OUTCOME_TRUE(nonce, system_api_->getNonceFor(kSs58Account)); + auto nonce = EXPECT_OK(system_api_->getNonceFor(kSs58Account)); ASSERT_EQ(nonce, kInitialNonce + kReadyTxNum); } diff --git a/test/core/api/transport/http_listener_test.cpp b/test/core/api/transport/http_listener_test.cpp index a5ce86647d..3e89cccaa8 100644 --- a/test/core/api/transport/http_listener_test.cpp +++ b/test/core/api/transport/http_listener_test.cpp @@ -61,10 +61,10 @@ TEST_F(HttpListenerTest, EchoSuccess) { local_context->post([&] { auto client = std::make_shared(*local_context); - ASSERT_OUTCOME_SUCCESS_TRY(client->connect(endpoint)); + EXPECT_OK(client->connect(endpoint)); client->query(request, [&](outcome::result res) { - ASSERT_OUTCOME_SUCCESS_TRY(res); + EXPECT_OK(res); EXPECT_EQ(res.value(), response); client->disconnect(); time_is_out = false; diff --git a/test/core/api/transport/listener_test.hpp b/test/core/api/transport/listener_test.hpp index af509b01fe..f6ee23386d 100644 --- a/test/core/api/transport/listener_test.hpp +++ b/test/core/api/transport/listener_test.hpp @@ -9,6 +9,7 @@ #include "api/transport/listener.hpp" #include +#include #include "api/jrpc/jrpc_processor.hpp" #include "api/jrpc/jrpc_server.hpp" @@ -28,7 +29,6 @@ #include "runtime/runtime_context.hpp" #include "subscription/extrinsic_event_key_repository.hpp" #include "subscription/subscriber.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "transaction_pool/transaction_pool_error.hpp" #include "utils/watchdog.hpp" diff --git a/test/core/api/transport/ws_listener_test.cpp b/test/core/api/transport/ws_listener_test.cpp index 5c0de9fc25..f395673108 100644 --- a/test/core/api/transport/ws_listener_test.cpp +++ b/test/core/api/transport/ws_listener_test.cpp @@ -62,10 +62,10 @@ TEST_F(WsListenerTest, EchoSuccess) { local_context->post([&] { auto client = std::make_shared(*local_context); - ASSERT_OUTCOME_SUCCESS_TRY(client->connect(endpoint)); + EXPECT_OK(client->connect(endpoint)); client->query(request, [&](outcome::result res) { - ASSERT_OUTCOME_SUCCESS_TRY(res); + EXPECT_OK(res); EXPECT_EQ(res.value(), response); client->disconnect(); time_is_out = false; diff --git a/test/core/application/chain_spec_test.cpp b/test/core/application/chain_spec_test.cpp index 17055f38d5..22048352b6 100644 --- a/test/core/application/chain_spec_test.cpp +++ b/test/core/application/chain_spec_test.cpp @@ -5,10 +5,10 @@ */ #include +#include #include "application/impl/chain_spec_impl.hpp" #include "filesystem/common.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::application::ChainSpecImpl; @@ -56,7 +56,7 @@ class ConfigurationStorageTest : public ::testing::Test { TEST_F(ConfigurationStorageTest, MatchesConfig) { // given provided in set up // when - EXPECT_OUTCOME_TRUE(config_storage, ChainSpecImpl::loadFrom(path_)); + auto config_storage = EXPECT_OK(ChainSpecImpl::loadFrom(path_)); // then ASSERT_EQ(config_storage->getGenesisTopSection(), expected_genesis_config_); diff --git a/test/core/authorship/block_builder_factory_test.cpp b/test/core/authorship/block_builder_factory_test.cpp index 786caf1d01..327b0c89de 100644 --- a/test/core/authorship/block_builder_factory_test.cpp +++ b/test/core/authorship/block_builder_factory_test.cpp @@ -11,7 +11,6 @@ #include "mock/core/runtime/block_builder_api_mock.hpp" #include "mock/core/runtime/core_mock.hpp" #include "runtime/runtime_context.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using ::testing::_; diff --git a/test/core/authorship/block_builder_test.cpp b/test/core/authorship/block_builder_test.cpp index 183ebbae11..42a19a8b9e 100644 --- a/test/core/authorship/block_builder_test.cpp +++ b/test/core/authorship/block_builder_test.cpp @@ -7,9 +7,10 @@ #include "authorship/impl/block_builder_impl.hpp" #include +#include + #include "mock/core/runtime/block_builder_api_mock.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using ::testing::_; @@ -77,7 +78,7 @@ TEST_F(BlockBuilderTest, PushWhenApplyFails) { // when auto res = block_builder_->pushExtrinsic(xt); - EXPECT_OUTCOME_TRUE(block, block_builder_->bake()); + auto block = EXPECT_OK(block_builder_->bake()); // then ASSERT_FALSE(res); @@ -102,7 +103,7 @@ TEST_F(BlockBuilderTest, PushWhenApplySucceedsWithTrue) { auto res = block_builder_->pushExtrinsic(xt); ASSERT_TRUE(res); - EXPECT_OUTCOME_TRUE(block, block_builder_->bake()); + auto block = EXPECT_OK(block_builder_->bake()); // then ASSERT_EQ(block.header, expected_header_); @@ -128,7 +129,7 @@ TEST_F(BlockBuilderTest, PushWhenApplySucceedsWithFalse) { // then ASSERT_FALSE(res); - EXPECT_OUTCOME_TRUE(block, block_builder_->bake()); + auto block = EXPECT_OK(block_builder_->bake()); ASSERT_EQ(block.header, expected_header_); ASSERT_THAT(block.body, IsEmpty()); } diff --git a/test/core/authorship/proposer_test.cpp b/test/core/authorship/proposer_test.cpp index eb2313f408..a02db15cec 100644 --- a/test/core/authorship/proposer_test.cpp +++ b/test/core/authorship/proposer_test.cpp @@ -17,7 +17,6 @@ #include "primitives/event_types.hpp" #include "subscription/extrinsic_event_key_repository.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "transaction_pool/transaction_pool_error.hpp" diff --git a/test/core/blockchain/block_header_repository_test.cpp b/test/core/blockchain/block_header_repository_test.cpp index 1eee6d2ca6..9b019be174 100644 --- a/test/core/blockchain/block_header_repository_test.cpp +++ b/test/core/blockchain/block_header_repository_test.cpp @@ -8,15 +8,13 @@ #include #include +#include -#include - +#include #include "blockchain/impl/block_header_repository_impl.hpp" #include "blockchain/impl/storage_util.hpp" #include "crypto/hasher/hasher_impl.hpp" -#include "scale/scale.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/storage/base_rocksdb_test.hpp" @@ -88,20 +86,20 @@ TEST_F(BlockHeaderRepository_Test, UnexistingHeader) { auto chosen_number = ParamValues[0]; for (auto &c : ParamValues) { if (c != chosen_number) { - EXPECT_OUTCOME_TRUE_1(storeHeader(c, getDefaultHeader())) + EXPECT_OK(storeHeader(c, getDefaultHeader())); } } BlockHeader not_in_storage = getDefaultHeader(); not_in_storage.number = chosen_number; - EXPECT_OUTCOME_TRUE(enc_header, scale::encode(not_in_storage)) + auto enc_header = EXPECT_OK(scale::encode(not_in_storage)); auto hash = hasher_->blake2b_256(enc_header); - EXPECT_OUTCOME_FALSE_1(header_repo_->getBlockHeader(hash)) - EXPECT_OUTCOME_FALSE_1(header_repo_->getHashById(chosen_number)) - EXPECT_OUTCOME_FALSE_1(header_repo_->getNumberById(hash)) + EXPECT_HAS_ERROR(header_repo_->getBlockHeader(hash)); + EXPECT_HAS_ERROR(header_repo_->getHashById(chosen_number)); + EXPECT_HAS_ERROR(header_repo_->getNumberById(hash)); // doesn't require access to storage, as it basically returns its argument - EXPECT_OUTCOME_TRUE_1(header_repo_->getHashById(hash)) - EXPECT_OUTCOME_TRUE_1(header_repo_->getNumberById(chosen_number)) + EXPECT_OK(header_repo_->getHashById(hash)); + EXPECT_OK(header_repo_->getNumberById(chosen_number)); } /** @@ -111,10 +109,10 @@ TEST_F(BlockHeaderRepository_Test, UnexistingHeader) { * retrieval through getHashByNumber and getHashById */ TEST_P(BlockHeaderRepository_NumberParametrized_Test, GetHashByNumber) { - EXPECT_OUTCOME_TRUE(hash, storeHeader(GetParam(), getDefaultHeader())) - EXPECT_OUTCOME_TRUE(maybe_hash, header_repo_->getHashByNumber(GetParam())) + auto hash = EXPECT_OK(storeHeader(GetParam(), getDefaultHeader())); + auto maybe_hash = EXPECT_OK(header_repo_->getHashByNumber(GetParam())); ASSERT_THAT(hash, testing::ContainerEq(maybe_hash)); - EXPECT_OUTCOME_TRUE(maybe_another_hash, header_repo_->getHashById(GetParam())) + auto maybe_another_hash = EXPECT_OK(header_repo_->getHashById(GetParam())); ASSERT_THAT(hash, testing::ContainerEq(maybe_another_hash)); } @@ -125,11 +123,11 @@ TEST_P(BlockHeaderRepository_NumberParametrized_Test, GetHashByNumber) { * retrieval through getNumberByHash and getNumberById */ TEST_P(BlockHeaderRepository_NumberParametrized_Test, GetNumberByHash) { - EXPECT_OUTCOME_TRUE(hash, storeHeader(GetParam(), getDefaultHeader())) - EXPECT_OUTCOME_TRUE(maybe_number, header_repo_->getNumberByHash(hash)) + auto hash = EXPECT_OK(storeHeader(GetParam(), getDefaultHeader())); + auto maybe_number = EXPECT_OK(header_repo_->getNumberByHash(hash)); ASSERT_EQ(GetParam(), maybe_number); - EXPECT_OUTCOME_TRUE(maybe_another_number, - header_repo_->getNumberById(GetParam())) + auto maybe_another_number = + EXPECT_OK(header_repo_->getNumberById(GetParam())); ASSERT_EQ(GetParam(), maybe_another_number); } @@ -140,8 +138,8 @@ TEST_P(BlockHeaderRepository_NumberParametrized_Test, GetNumberByHash) { * of whether the id contained a number or a hash */ TEST_P(BlockHeaderRepository_NumberParametrized_Test, GetHeader) { - EXPECT_OUTCOME_TRUE(hash, storeHeader(GetParam(), getDefaultHeader())) - EXPECT_OUTCOME_TRUE(header_by_hash, header_repo_->getBlockHeader(hash)) + auto hash = EXPECT_OK(storeHeader(GetParam(), getDefaultHeader())); + auto header_by_hash = EXPECT_OK(header_repo_->getBlockHeader(hash)); auto header_should_be = getDefaultHeader(); header_should_be.number = GetParam(); ASSERT_EQ(header_by_hash, header_should_be); diff --git a/test/core/blockchain/block_storage_test.cpp b/test/core/blockchain/block_storage_test.cpp index f9ad1daedf..6c7a80d1ec 100644 --- a/test/core/blockchain/block_storage_test.cpp +++ b/test/core/blockchain/block_storage_test.cpp @@ -7,16 +7,16 @@ #include "blockchain/impl/block_storage_impl.hpp" #include +#include +#include #include "blockchain/block_storage_error.hpp" #include "mock/core/crypto/hasher_mock.hpp" #include "mock/core/storage/generic_storage_mock.hpp" #include "mock/core/storage/spaced_storage_mock.hpp" #include "scale/kagome_scale.hpp" -#include "scale/scale.hpp" #include "storage/database_error.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::blockchain::BlockStorageError; @@ -80,9 +80,8 @@ class BlockStorageTest : public testing::Test { EXPECT_CALL(*hasher, blake2b_256(_)) .WillRepeatedly(Return(genesis_block_hash)); - EXPECT_OUTCOME_TRUE( - new_block_storage, - BlockStorageImpl::create(root_hash, spaced_storage, hasher)); + auto new_block_storage = + EXPECT_OK(BlockStorageImpl::create(root_hash, spaced_storage, hasher)); return new_block_storage; } @@ -118,8 +117,7 @@ TEST_F(BlockStorageTest, CreateWithEmptyStorage) { EXPECT_CALL(*empty_storage, put(_, _)) .WillRepeatedly(Return(outcome::success())); - ASSERT_OUTCOME_SUCCESS_TRY( - BlockStorageImpl::create(root_hash, spaced_storage, hasher)); + EXPECT_OK(BlockStorageImpl::create(root_hash, spaced_storage, hasher)); } /** @@ -137,8 +135,7 @@ TEST_F(BlockStorageTest, CreateWithExistingGenesis) { // trying to get header of block number 0 (genesis block) .WillOnce(Return(Buffer{genesis_block_hash})); - ASSERT_OUTCOME_SUCCESS_TRY( - BlockStorageImpl::create(root_hash, spaced_storage, hasher)); + EXPECT_OK(BlockStorageImpl::create(root_hash, spaced_storage, hasher)); } /** @@ -152,10 +149,8 @@ TEST_F(BlockStorageTest, CreateWithStorageError) { EXPECT_CALL(*(spaces[Space::kLookupKey]), tryGetMock(_)) .WillOnce(Return(kagome::storage::DatabaseError::IO_ERROR)); - EXPECT_OUTCOME_ERROR( - res, - BlockStorageImpl::create(root_hash, spaced_storage, hasher), - kagome::storage::DatabaseError::IO_ERROR); + EXPECT_EC(BlockStorageImpl::create(root_hash, spaced_storage, hasher), + kagome::storage::DatabaseError::IO_ERROR); } /** @@ -171,7 +166,7 @@ TEST_F(BlockStorageTest, PutBlock) { block.header.parent_hash = genesis_block_hash; block.header.hash_opt = regular_block_hash; - ASSERT_OUTCOME_SUCCESS_TRY(block_storage->putBlock(block)); + EXPECT_OK(block_storage->putBlock(block)); } /** @@ -193,8 +188,8 @@ TEST_F(BlockStorageTest, PutWithStorageError) { EXPECT_CALL(*(spaces[Space::kBlockBody]), put(key.view(), _)) .WillOnce(Return(kagome::storage::DatabaseError::IO_ERROR)); - ASSERT_OUTCOME_ERROR(block_storage->putBlock(block), - kagome::storage::DatabaseError::IO_ERROR); + EXPECT_EC(block_storage->putBlock(block), + kagome::storage::DatabaseError::IO_ERROR); } /** @@ -219,10 +214,10 @@ TEST_F(BlockStorageTest, Remove) { EXPECT_CALL(*(spaces[Space::kJustification]), remove(hash)) .WillOnce(Return(outcome::success())); - ASSERT_OUTCOME_SUCCESS_TRY(block_storage->removeBlock(genesis_block_hash)); + EXPECT_OK(block_storage->removeBlock(genesis_block_hash)); EXPECT_CALL(*(spaces[Space::kHeader]), tryGetMock(hash)) .WillOnce(Return(std::nullopt)); - ASSERT_OUTCOME_SUCCESS_TRY(block_storage->removeBlock(genesis_block_hash)); + EXPECT_OK(block_storage->removeBlock(genesis_block_hash)); } diff --git a/test/core/blockchain/block_tree_test.cpp b/test/core/blockchain/block_tree_test.cpp index bb98ff2d8e..f59306d0d3 100644 --- a/test/core/blockchain/block_tree_test.cpp +++ b/test/core/blockchain/block_tree_test.cpp @@ -5,9 +5,11 @@ */ #include +#include #include "blockchain/impl/block_tree_impl.hpp" +#include #include "blockchain/block_tree_error.hpp" #include "blockchain/impl/cached_tree.hpp" #include "common/main_thread_pool.hpp" @@ -22,9 +24,7 @@ #include "mock/core/storage/trie_pruner/trie_pruner_mock.hpp" #include "mock/core/transaction_pool/transaction_pool_mock.hpp" #include "network/impl/extrinsic_observer_impl.hpp" -#include "scale/scale.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using namespace kagome; @@ -394,8 +394,7 @@ TEST_F(BlockTreeTest, GetBody) { .WillOnce(Return(finalized_block_body_)); // THEN - ASSERT_OUTCOME_SUCCESS(body, - block_tree_->getBlockBody(kFinalizedBlockInfo.hash)) + auto body = EXPECT_OK(block_tree_->getBlockBody(kFinalizedBlockInfo.hash)); ASSERT_EQ(body, finalized_block_body_); } @@ -449,8 +448,7 @@ TEST_F(BlockTreeTest, AddBlockNoParent) { Block new_block{header, body}; // WHEN-THEN - ASSERT_OUTCOME_ERROR(block_tree_->addBlock(new_block), - BlockTreeError::NO_PARENT); + EXPECT_EC(block_tree_->addBlock(new_block), BlockTreeError::NO_PARENT); } /** @@ -488,7 +486,7 @@ TEST_F(BlockTreeTest, Finalize) { .WillOnce(Return(outcome::success(false))); // WHEN - EXPECT_OUTCOME_TRUE_1(block_tree_->finalize(hash, justification)); + EXPECT_OK(block_tree_->finalize(hash, justification)); // THEN ASSERT_EQ(block_tree_->getLastFinalized().hash, hash); @@ -677,8 +675,8 @@ TEST_F(BlockTreeTest, GetChainByBlockAscending) { std::vector expected_chain{kFinalizedBlockInfo.hash, hash1, hash2}; // WHEN - ASSERT_OUTCOME_SUCCESS( - chain, block_tree_->getBestChainFromBlock(kFinalizedBlockInfo.hash, 5)); + auto chain = EXPECT_OK( + block_tree_->getBestChainFromBlock(kFinalizedBlockInfo.hash, 5)); // THEN ASSERT_EQ(chain, expected_chain); @@ -711,8 +709,7 @@ TEST_F(BlockTreeTest, GetChainByBlockDescending) { std::vector expected_chain{hash2, hash1}; // WHEN - ASSERT_OUTCOME_SUCCESS(chain, - block_tree_->getDescendingChainToBlock(hash2, 5)); + auto chain = EXPECT_OK(block_tree_->getDescendingChainToBlock(hash2, 5)); // THEN ASSERT_EQ(chain, expected_chain); @@ -729,8 +726,8 @@ TEST_F(BlockTreeTest, GetBestChain_BlockNotFound) { EXPECT_CALL(*header_repo_, getNumberByHash(target.hash)) .WillRepeatedly(Return(BlockTreeError::EXISTING_BLOCK_NOT_FOUND)); - ASSERT_OUTCOME_ERROR(block_tree_->getBestContaining(target.hash), - BlockTreeError::EXISTING_BLOCK_NOT_FOUND); + EXPECT_EC(block_tree_->getBestContaining(target.hash), + BlockTreeError::EXISTING_BLOCK_NOT_FOUND); } /** @@ -747,8 +744,8 @@ TEST_F(BlockTreeTest, GetBestChain_DiscardedBlock) { EXPECT_CALL(*header_repo_, getHashByNumber(target.number)) .WillRepeatedly(Return(other.hash)); - ASSERT_OUTCOME_ERROR(block_tree_->getBestContaining(target.hash), - BlockTreeError::BLOCK_ON_DEAD_END); + EXPECT_EC(block_tree_->getBestContaining(target.hash), + BlockTreeError::BLOCK_ON_DEAD_END); } /** @@ -759,8 +756,7 @@ TEST_F(BlockTreeTest, GetBestChain_DiscardedBlock) { TEST_F(BlockTreeTest, GetBestChain_ShortChain) { auto target_hash = addHeaderToRepository(kFinalizedBlockInfo.hash, 1337); - ASSERT_OUTCOME_SUCCESS(best_info, - block_tree_->getBestContaining(target_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(target_hash)); ASSERT_EQ(best_info.hash, target_hash); } @@ -790,7 +786,7 @@ TEST_F(BlockTreeTest, GetBestChain_TwoChains) { auto C2_hash = addHeaderToRepository(B_hash, 46); auto D2_hash = addHeaderToRepository(C2_hash, 47); - ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(T_hash)); ASSERT_EQ(best_info.hash, D2_hash); // test grandpa best chain selection when target block is not on best chain @@ -854,7 +850,7 @@ TEST_F(BlockTreeTest, Reorganize) { shouldStoreFor(finalized_block_header_, _)) .WillOnce(Return(outcome::success(false))); - ASSERT_OUTCOME_SUCCESS_TRY(block_tree_->finalize(C2_hash, {})); + EXPECT_OK(block_tree_->finalize(C2_hash, {})); // 42 43 44 45 46 47 // @@ -882,7 +878,7 @@ TEST_F(BlockTreeTest, CleanupObsoleteJustificationOnFinalized) { // remove old justification EXPECT_CALL(*storage_, removeJustification(kFinalizedBlockInfo.hash)) .WillOnce(Return(outcome::success())); - EXPECT_OUTCOME_TRUE_1(block_tree_->finalize(b56, new_justification)); + EXPECT_OK(block_tree_->finalize(b56, new_justification)); } TEST_F(BlockTreeTest, KeepLastFinalizedJustificationIfItShouldBeStored) { @@ -900,7 +896,7 @@ TEST_F(BlockTreeTest, KeepLastFinalizedJustificationIfItShouldBeStored) { // store new justification EXPECT_CALL(*storage_, putJustification(new_justification, b56)) .WillOnce(Return(outcome::success())); - EXPECT_OUTCOME_TRUE_1(block_tree_->finalize(b56, new_justification)); + EXPECT_OK(block_tree_->finalize(b56, new_justification)); } /** @@ -935,7 +931,7 @@ TEST_F(BlockTreeTest, GetBestBlock) { // C3 - D3 - E3 - F3 { - ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(T_hash)); ASSERT_EQ(best_info.hash, F3_hash); } @@ -952,7 +948,7 @@ TEST_F(BlockTreeTest, GetBestBlock) { // C3 - D3 - E3 - F3 { - ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(T_hash)); ASSERT_EQ(best_info.hash, E2_hash); } @@ -969,13 +965,13 @@ TEST_F(BlockTreeTest, GetBestBlock) { // C3 - D3 - E3 - F3 - G3** { - ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(T_hash)); ASSERT_EQ(best_info.hash, G3_hash); } // --------------------------------------------------------------------------- - ASSERT_OUTCOME_SUCCESS_TRY(block_tree_->markAsRevertedBlocks({E3_hash})); + EXPECT_OK(block_tree_->markAsRevertedBlocks({E3_hash})); // 42 43 44 45 46 47 48 49 50 // @@ -986,7 +982,7 @@ TEST_F(BlockTreeTest, GetBestBlock) { // C3 - D3 - E3 - F3 - G3** { - ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash)); + auto best_info = EXPECT_OK(block_tree_->getBestContaining(T_hash)); ASSERT_EQ(best_info.hash, E2_hash); } } diff --git a/test/core/consensus/babe/babe_block_validator_test.cpp b/test/core/consensus/babe/babe_block_validator_test.cpp index 4d1e796714..54d96cd1eb 100644 --- a/test/core/consensus/babe/babe_block_validator_test.cpp +++ b/test/core/consensus/babe/babe_block_validator_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include "consensus/babe/impl/babe_block_validator_impl.hpp" #include "consensus/babe/impl/babe_digests_util.hpp" @@ -17,7 +18,6 @@ #include "mock/core/crypto/vrf_provider_mock.hpp" #include "mock/core/runtime/babe_api_mock.hpp" #include "testutil/lazy.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/sr25519_utils.hpp" @@ -213,7 +213,7 @@ TEST_F(BabeBlockValidatorTest, Success) { .WillOnce(Return(VRFVerifyOutput{.is_valid = true, .is_less = true})); auto validate_res = block_validator->validateHeader(valid_block_.header); - EXPECT_OUTCOME_TRUE_1(validate_res); + EXPECT_OK(validate_res); } /** @@ -226,9 +226,8 @@ TEST_F(BabeBlockValidatorTest, LessDigestsThanNeeded) { authorities.emplace_back(authority); // for this test we can just not seal the block - it's the second digest - EXPECT_OUTCOME_FALSE(err, - block_validator->validateHeader(valid_block_.header)); - ASSERT_EQ(err, DigestError::REQUIRED_DIGESTS_NOT_FOUND); + EXPECT_EC(block_validator->validateHeader(valid_block_.header), + DigestError::REQUIRED_DIGESTS_NOT_FOUND); } /** @@ -254,9 +253,8 @@ TEST_F(BabeBlockValidatorTest, NoBabeHeader) { authorities.emplace_back(); authorities.emplace_back(Authority{pubkey, 42}); - EXPECT_OUTCOME_FALSE(err, - block_validator->validateHeader(valid_block_.header)); - ASSERT_EQ(err, DigestError::REQUIRED_DIGESTS_NOT_FOUND); + EXPECT_EC(block_validator->validateHeader(valid_block_.header), + DigestError::REQUIRED_DIGESTS_NOT_FOUND); } /** @@ -285,9 +283,8 @@ TEST_F(BabeBlockValidatorTest, SignatureVerificationFail) { EXPECT_CALL(*sr25519_provider, verify(_, _, _)).WillOnce(Return(false)); // WHEN-THEN - EXPECT_OUTCOME_FALSE(err, - block_validator->validateHeader(valid_block_.header)); - ASSERT_EQ(err, ValidatingError::INVALID_SIGNATURE); + EXPECT_EC(block_validator->validateHeader(valid_block_.header), + ValidatingError::INVALID_SIGNATURE); } /** @@ -320,9 +317,8 @@ TEST_F(BabeBlockValidatorTest, VRFFail) { .WillOnce(Return(VRFVerifyOutput{.is_valid = false, .is_less = true})); // THEN - EXPECT_OUTCOME_FALSE(err, - block_validator->validateHeader(valid_block_.header)); - ASSERT_EQ(err, ValidatingError::INVALID_VRF); + EXPECT_EC(block_validator->validateHeader(valid_block_.header), + ValidatingError::INVALID_VRF); } /** @@ -359,7 +355,6 @@ TEST_F(BabeBlockValidatorTest, ThresholdGreater) { .WillOnce(Return(VRFVerifyOutput{.is_valid = true, .is_less = false})); // THEN - EXPECT_OUTCOME_FALSE(err, - block_validator->validateHeader(valid_block_.header)); - ASSERT_EQ(err, ValidatingError::INVALID_VRF); + EXPECT_EC(block_validator->validateHeader(valid_block_.header), + ValidatingError::INVALID_VRF); } diff --git a/test/core/consensus/babe/babe_test.cpp b/test/core/consensus/babe/babe_test.cpp index 20114a13c9..52cb6faf15 100644 --- a/test/core/consensus/babe/babe_test.cpp +++ b/test/core/consensus/babe/babe_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include @@ -44,7 +45,6 @@ #include "storage/trie/serialization/ordered_trie_hash.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/sr25519_utils.hpp" #include "utils/watchdog.hpp" @@ -389,10 +389,10 @@ TEST_F(BabeTest, Setup) { EXPECT_CALL(*babe_api, disabled_validators(_)) .WillOnce(Return(std::vector{})); - ASSERT_OUTCOME_ERROR(babe->getSlot(genesis_block_header), - DigestError::GENESIS_BLOCK_CAN_NOT_HAVE_DIGESTS); + EXPECT_EC(babe->getSlot(genesis_block_header), + DigestError::GENESIS_BLOCK_CAN_NOT_HAVE_DIGESTS); - ASSERT_OUTCOME_SUCCESS(actual_slot, babe->getSlot(best_block_header)); + auto actual_slot = EXPECT_OK(babe->getSlot(best_block_header)); EXPECT_EQ(actual_slot, best_block_slot); EXPECT_EQ(babe->getValidatorStatus(best_block_info, 0), @@ -418,8 +418,8 @@ TEST_F(BabeTest, NonValidator) { EXPECT_EQ(babe->getValidatorStatus(best_block_info, slot), ValidatorStatus::NonValidator); - ASSERT_OUTCOME_ERROR(babe->processSlot(slot, best_block_info), - SlotLeadershipError::NON_VALIDATOR); + EXPECT_EC(babe->processSlot(slot, best_block_info), + SlotLeadershipError::NON_VALIDATOR); } TEST_F(BabeTest, DisabledValidator) { @@ -442,8 +442,8 @@ TEST_F(BabeTest, DisabledValidator) { EXPECT_EQ(babe->getValidatorStatus(best_block_info, slot), ValidatorStatus::DisabledValidator); - ASSERT_OUTCOME_ERROR(babe->processSlot(slot, best_block_info), - SlotLeadershipError::DISABLED_VALIDATOR); + EXPECT_EC(babe->processSlot(slot, best_block_info), + SlotLeadershipError::DISABLED_VALIDATOR); } TEST_F(BabeTest, NoSlotLeader) { @@ -468,8 +468,8 @@ TEST_F(BabeTest, NoSlotLeader) { EXPECT_EQ(babe->getValidatorStatus(best_block_info, slot), ValidatorStatus::Validator); - ASSERT_OUTCOME_ERROR(babe->processSlot(slot, best_block_info), - SlotLeadershipError::NO_SLOT_LEADER); + EXPECT_EC(babe->processSlot(slot, best_block_info), + SlotLeadershipError::NO_SLOT_LEADER); } TEST_F(BabeTest, SlotLeader) { @@ -508,7 +508,7 @@ TEST_F(BabeTest, SlotLeader) { std::latch latch(1); babe->on_proposed = [&] { latch.count_down(); }; - ASSERT_OUTCOME_SUCCESS_TRY(babe->processSlot(slot, best_block_info)); + EXPECT_OK(babe->processSlot(slot, best_block_info)); latch.wait(); } @@ -559,6 +559,5 @@ TEST_F(BabeTest, EquivocationReport) { "parent"_hash256, equivocation_proof, ownership_proof)) .WillOnce(Return(outcome::success())); - ASSERT_OUTCOME_SUCCESS_TRY( - babe->reportEquivocation(first.hash(), second.hash())); + EXPECT_OK(babe->reportEquivocation(first.hash(), second.hash())); } diff --git a/test/core/consensus/grandpa/chain_test.cpp b/test/core/consensus/grandpa/chain_test.cpp index 076fdd1481..1da6a37752 100644 --- a/test/core/consensus/grandpa/chain_test.cpp +++ b/test/core/consensus/grandpa/chain_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include @@ -27,7 +28,6 @@ #include "mock/core/runtime/parachain_host_mock.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::Watchdog; @@ -180,7 +180,7 @@ TEST_F(ChainTest, GetAncestry) { auto h4 = "040404"_hash256; EXPECT_CALL(*tree, getChainByBlocks(h1, h4)) .WillOnce(Return(std::vector{h1, h2, h3, h4})); - ASSERT_OUTCOME_SUCCESS(blocks, chain->getAncestry(h1, h4)); + auto blocks = EXPECT_OK(chain->getAncestry(h1, h4)); std::vector expected{h4, h3, h2, h1}; ASSERT_EQ(blocks, expected); } @@ -197,7 +197,7 @@ TEST_F(ChainTest, GetAncestryOfChild) { EXPECT_CALL(*tree, getChainByBlocks(h1, h2)) .WillOnce(Return(std::vector{h1, h2})); - ASSERT_OUTCOME_SUCCESS(blocks, chain->getAncestry(h1, h2)); + auto blocks = EXPECT_OK(chain->getAncestry(h1, h2)); std::vector expected{h2, h1}; ASSERT_EQ(blocks, expected); } @@ -211,7 +211,7 @@ TEST_F(ChainTest, GetAncestryOfItself) { auto h1 = "010101"_hash256; EXPECT_CALL(*tree, getChainByBlocks(_, _)).Times(0); - ASSERT_OUTCOME_SUCCESS(blocks, chain->getAncestry(h1, h1)); + auto blocks = EXPECT_OK(chain->getAncestry(h1, h1)); std::vector expected{h1}; ASSERT_EQ(blocks, expected); } @@ -266,7 +266,7 @@ TEST_F(ChainTest, BestChainContaining) { .WillOnce(testing::Invoke( [&](auto base, auto, auto &&cb) { return cb(base); })); - ASSERT_OUTCOME_SUCCESS(r, chain->bestChainContaining(h[2], std::nullopt)); + auto r = EXPECT_OK(chain->bestChainContaining(h[2], std::nullopt)); ASSERT_EQ(h[3], r.hash); } diff --git a/test/core/consensus/grandpa/vote_graph/adjust_base_test.cpp b/test/core/consensus/grandpa/vote_graph/adjust_base_test.cpp index c94cc35567..2d0cded603 100644 --- a/test/core/consensus/grandpa/vote_graph/adjust_base_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/adjust_base_test.cpp @@ -30,7 +30,7 @@ TEST_F(VoteGraphFixture, AdjustBase) { })"); expect_getAncestry("E"_H, "FC"_H, vec("FC"_H, "FB"_H, "FA"_H, "F"_H, "E"_H)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {9, "FC"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {9, "FC"_H}, "w5_a"_ID)); SCOPED_TRACE(2); AssertGraphCorrect(*graph, R"({ @@ -63,7 +63,7 @@ TEST_F(VoteGraphFixture, AdjustBase) { })"); expect_getAncestry("E"_H, "ED"_H, vec("ED"_H, "EC"_H, "EB"_H, "EA"_H, "E"_H)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {9, "ED"_H}, "w7_a"_ID)); + EXPECT_OK(graph->insert(vt, {9, "ED"_H}, "w7_a"_ID)); SCOPED_TRACE(3); AssertGraphCorrect(*graph, R"({ @@ -242,7 +242,7 @@ TEST_F(VoteGraphFixture, AdjustBase) { expect_getAncestry( GENESIS_HASH, "4"_H, vec("4"_H, "3"_H, "2"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {4, "4"_H}, "w3_a"_ID)); + EXPECT_OK(graph->insert(vt, {4, "4"_H}, "w3_a"_ID)); SCOPED_TRACE(6); AssertGraphCorrect(*graph, diff --git a/test/core/consensus/grandpa/vote_graph/duplicate_vote_test.cpp b/test/core/consensus/grandpa/vote_graph/duplicate_vote_test.cpp index f065b9248c..37e25dc318 100644 --- a/test/core/consensus/grandpa/vote_graph/duplicate_vote_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/duplicate_vote_test.cpp @@ -38,7 +38,7 @@ TEST_F(VoteGraphFixture, DuplicateVote) { expect_getAncestry( GENESIS_HASH, "C"_H, vec("C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, voter)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, voter)); AssertGraphCorrect(*graph, R"( { @@ -74,7 +74,7 @@ TEST_F(VoteGraphFixture, DuplicateVote) { expect_getAncestry( GENESIS_HASH, "D"_H, vec("D"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {4, "D"_H}, voter)); + EXPECT_OK(graph->insert(vt, {4, "D"_H}, voter)); // WHEN.1 @@ -120,7 +120,7 @@ TEST_F(VoteGraphFixture, DuplicateVote) { // WHEN.2 - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, voter)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, voter)); // THEN.2 diff --git a/test/core/consensus/grandpa/vote_graph/fixture.hpp b/test/core/consensus/grandpa/vote_graph/fixture.hpp index c476e2cb27..0ba0f02624 100644 --- a/test/core/consensus/grandpa/vote_graph/fixture.hpp +++ b/test/core/consensus/grandpa/vote_graph/fixture.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include #include @@ -14,7 +15,6 @@ #include "consensus/grandpa/voter_set.hpp" #include "core/consensus/grandpa/literals.hpp" #include "mock/core/consensus/grandpa/chain_mock.hpp" -#include "testutil/outcome.hpp" using namespace kagome; using namespace consensus; @@ -31,27 +31,27 @@ struct VoteGraphFixture : public testing::Test { std::shared_ptr voter_set = [] { auto vs = std::make_shared(); - EXPECT_OUTCOME_TRUE_1(vs->insert("w0_a"_ID, 0)); + EXPECT_OK(vs->insert("w0_a"_ID, 0)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w1_a"_ID, 1)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w1_b"_ID, 1)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w1_c"_ID, 1)); + EXPECT_OK(vs->insert("w1_a"_ID, 1)); + EXPECT_OK(vs->insert("w1_b"_ID, 1)); + EXPECT_OK(vs->insert("w1_c"_ID, 1)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w3_a"_ID, 3)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w3_b"_ID, 3)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w3_c"_ID, 3)); + EXPECT_OK(vs->insert("w3_a"_ID, 3)); + EXPECT_OK(vs->insert("w3_b"_ID, 3)); + EXPECT_OK(vs->insert("w3_c"_ID, 3)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w5_a"_ID, 5)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w5_b"_ID, 5)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w5_c"_ID, 5)); + EXPECT_OK(vs->insert("w5_a"_ID, 5)); + EXPECT_OK(vs->insert("w5_b"_ID, 5)); + EXPECT_OK(vs->insert("w5_c"_ID, 5)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w7_a"_ID, 7)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w7_b"_ID, 7)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w7_c"_ID, 7)); + EXPECT_OK(vs->insert("w7_a"_ID, 7)); + EXPECT_OK(vs->insert("w7_b"_ID, 7)); + EXPECT_OK(vs->insert("w7_c"_ID, 7)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w10_a"_ID, 10)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w10_b"_ID, 10)); - EXPECT_OUTCOME_TRUE_1(vs->insert("w10_c"_ID, 10)); + EXPECT_OK(vs->insert("w10_a"_ID, 10)); + EXPECT_OK(vs->insert("w10_b"_ID, 10)); + EXPECT_OK(vs->insert("w10_c"_ID, 10)); return vs; }(); diff --git a/test/core/consensus/grandpa/vote_graph/ghost_introduce_branch_test.cpp b/test/core/consensus/grandpa/vote_graph/ghost_introduce_branch_test.cpp index 06052f9a66..e4c6bd59e1 100644 --- a/test/core/consensus/grandpa/vote_graph/ghost_introduce_branch_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/ghost_introduce_branch_test.cpp @@ -39,7 +39,7 @@ TEST_F(VoteGraphFixture, GhostIntroduceBranch) { "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {9, "FC"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {9, "FC"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -88,7 +88,7 @@ TEST_F(VoteGraphFixture, GhostIntroduceBranch) { "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {9, "ED"_H}, "w7_a"_ID)); + EXPECT_OK(graph->insert(vt, {9, "ED"_H}, "w7_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -162,7 +162,7 @@ TEST_F(VoteGraphFixture, GhostIntroduceBranch) { { // introduce branch in the middle // do not expect that insert is calling getAncestry - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {5, "E"_H}, "w3_a"_ID)); + EXPECT_OK(graph->insert(vt, {5, "E"_H}, "w3_a"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/ghost_merge_at_node_test.cpp b/test/core/consensus/grandpa/vote_graph/ghost_merge_at_node_test.cpp index 4c391df5bb..2f2df7bdfe 100644 --- a/test/core/consensus/grandpa/vote_graph/ghost_merge_at_node_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/ghost_merge_at_node_test.cpp @@ -28,7 +28,7 @@ TEST_F(VoteGraphFixture, GhostMergeAtNodes) { })"); expect_getAncestry(GENESIS_HASH, "B"_H, vec("B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {2, "B"_H}, "w0_a"_ID)); + EXPECT_OK(graph->insert(vt, {2, "B"_H}, "w0_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -60,7 +60,7 @@ TEST_F(VoteGraphFixture, GhostMergeAtNodes) { expect_getAncestry( GENESIS_HASH, "C"_H, vec("C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -103,7 +103,7 @@ TEST_F(VoteGraphFixture, GhostMergeAtNodes) { expect_getAncestry(GENESIS_HASH, "E1"_H, vec("E1"_H, "D1"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ @@ -158,7 +158,7 @@ TEST_F(VoteGraphFixture, GhostMergeAtNodes) { GENESIS_HASH, "F2"_H, vec("F2"_H, "E2"_H, "D2"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/ghost_merge_not_at_node_one_side_weighted_test.cpp b/test/core/consensus/grandpa/vote_graph/ghost_merge_not_at_node_one_side_weighted_test.cpp index b38f0abc20..e1caa0f5ee 100644 --- a/test/core/consensus/grandpa/vote_graph/ghost_merge_not_at_node_one_side_weighted_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/ghost_merge_not_at_node_one_side_weighted_test.cpp @@ -28,7 +28,7 @@ TEST_F(VoteGraphFixture, GhostMergeNotAtNodeOneSideWeighted) { })"); expect_getAncestry(GENESIS_HASH, "B"_H, vec("B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {2, "B"_H}, "w0_a"_ID)); + EXPECT_OK(graph->insert(vt, {2, "B"_H}, "w0_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -62,7 +62,7 @@ TEST_F(VoteGraphFixture, GhostMergeNotAtNodeOneSideWeighted) { GENESIS_HASH, "G1"_H, vec("G1"_H, "F"_H, "E"_H, "D"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {7, "G1"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {7, "G1"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -117,7 +117,7 @@ TEST_F(VoteGraphFixture, GhostMergeNotAtNodeOneSideWeighted) { "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {8, "H2"_H}, "w7_a"_ID)); + EXPECT_OK(graph->insert(vt, {8, "H2"_H}, "w7_a"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/graph_fork_test.cpp b/test/core/consensus/grandpa/vote_graph/graph_fork_test.cpp index 4fa7f4f23a..d679b0cca7 100644 --- a/test/core/consensus/grandpa/vote_graph/graph_fork_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/graph_fork_test.cpp @@ -28,7 +28,7 @@ TEST_F(VoteGraphFixture, GraphForkAtNode) { expect_getAncestry( GENESIS_HASH, "C"_H, vec("C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -62,7 +62,7 @@ TEST_F(VoteGraphFixture, GraphForkAtNode) { expect_getAncestry(GENESIS_HASH, "E1"_H, vec("E1"_H, "D1"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ @@ -108,7 +108,7 @@ TEST_F(VoteGraphFixture, GraphForkAtNode) { GENESIS_HASH, "F2"_H, vec("F2"_H, "E2"_H, "D2"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); AssertGraphCorrect(*graph, R"({ @@ -185,7 +185,7 @@ TEST_F(VoteGraphFixture, GraphForkNotAtNode) { })"); expect_getAncestry(GENESIS_HASH, "A"_H, vec("A"_H, GENESIS_HASH) /* empty */); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {1, "A"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {1, "A"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -217,7 +217,7 @@ TEST_F(VoteGraphFixture, GraphForkNotAtNode) { expect_getAncestry(GENESIS_HASH, "E1"_H, vec("E1"_H, "D1"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {5, "E1"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ @@ -263,7 +263,7 @@ TEST_F(VoteGraphFixture, GraphForkNotAtNode) { GENESIS_HASH, "F2"_H, vec("F2"_H, "E2"_H, "D2"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F2"_H}, "w5_c"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/remove_vote_test.cpp b/test/core/consensus/grandpa/vote_graph/remove_vote_test.cpp index 7f71769b7d..e704da3edc 100644 --- a/test/core/consensus/grandpa/vote_graph/remove_vote_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/remove_vote_test.cpp @@ -36,7 +36,7 @@ TEST_F(VoteGraphFixture, RetractVote) { )"); expect_getAncestry(GENESIS_HASH, "A"_H, vec("A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {1, "A"_H}, "w1_a"_ID)); + EXPECT_OK(graph->insert(vt, {1, "A"_H}, "w1_a"_ID)); AssertGraphCorrect(*graph, R"( { @@ -67,7 +67,7 @@ TEST_F(VoteGraphFixture, RetractVote) { )"); expect_getAncestry(GENESIS_HASH, "B"_H, vec("B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {2, "B"_H}, "w3_a"_ID)); + EXPECT_OK(graph->insert(vt, {2, "B"_H}, "w3_a"_ID)); AssertGraphCorrect(*graph, R"( { @@ -109,7 +109,7 @@ TEST_F(VoteGraphFixture, RetractVote) { expect_getAncestry( GENESIS_HASH, "C"_H, vec("C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, "w7_a"_ID)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, "w7_a"_ID)); AssertGraphCorrect(*graph, R"( { diff --git a/test/core/consensus/grandpa/vote_graph/small_block_number_test.cpp b/test/core/consensus/grandpa/vote_graph/small_block_number_test.cpp index b7356af349..7b6d12339c 100644 --- a/test/core/consensus/grandpa/vote_graph/small_block_number_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/small_block_number_test.cpp @@ -43,8 +43,8 @@ TEST_F(VoteGraphFixture, InsertBlockLessThanBaseTest) { // WHEN - ASSERT_OUTCOME_ERROR(graph->insert(vt, {1, "A"_H}, voter), - VoteGraphError::RECEIVED_BLOCK_LESS_THAN_BASE); + EXPECT_EC(graph->insert(vt, {1, "A"_H}, voter), + VoteGraphError::RECEIVED_BLOCK_LESS_THAN_BASE); // THEN diff --git a/test/core/consensus/grandpa/vote_graph/walk_back_at_node_test.cpp b/test/core/consensus/grandpa/vote_graph/walk_back_at_node_test.cpp index d047eb61cf..f584b6d262 100644 --- a/test/core/consensus/grandpa/vote_graph/walk_back_at_node_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/walk_back_at_node_test.cpp @@ -32,7 +32,7 @@ struct WalkBackAtNode : public VoteGraphFixture, expect_getAncestry( GENESIS_HASH, "C"_H, vec("C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {3, "C"_H}, "w10_a"_ID)); + EXPECT_OK(graph->insert(vt, {3, "C"_H}, "w10_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -67,7 +67,7 @@ struct WalkBackAtNode : public VoteGraphFixture, GENESIS_HASH, "F1"_H, vec("F1"_H, "E1"_H, "D1"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -114,7 +114,7 @@ struct WalkBackAtNode : public VoteGraphFixture, GENESIS_HASH, "F2"_H, vec("F2"_H, "E2"_H, "D2"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F2"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F2"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ @@ -181,7 +181,7 @@ struct WalkBackAtNode : public VoteGraphFixture, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {9, "I1"_H}, "w1_a"_ID)); + EXPECT_OK(graph->insert(vt, {9, "I1"_H}, "w1_a"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/walk_back_from_block_in_edge_fork_below_test.cpp b/test/core/consensus/grandpa/vote_graph/walk_back_from_block_in_edge_fork_below_test.cpp index 202d693fa6..984b150656 100644 --- a/test/core/consensus/grandpa/vote_graph/walk_back_from_block_in_edge_fork_below_test.cpp +++ b/test/core/consensus/grandpa/vote_graph/walk_back_from_block_in_edge_fork_below_test.cpp @@ -32,7 +32,7 @@ struct WalkBackFromBlockInEdgeForkBelow })"); expect_getAncestry(GENESIS_HASH, "B"_H, vec("B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {2, "B"_H}, "w10_a"_ID)); + EXPECT_OK(graph->insert(vt, {2, "B"_H}, "w10_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -66,7 +66,7 @@ struct WalkBackFromBlockInEdgeForkBelow GENESIS_HASH, "F1"_H, vec("F1"_H, "E1"_H, "D1"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -113,7 +113,7 @@ struct WalkBackFromBlockInEdgeForkBelow GENESIS_HASH, "G2"_H, vec("G2"_H, "F2"_H, "E2"_H, "D2"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {7, "G2"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {7, "G2"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/vote_graph/walk_back_from_fork_block_node_below_tests.cpp b/test/core/consensus/grandpa/vote_graph/walk_back_from_fork_block_node_below_tests.cpp index 33dfd94811..3dcea10462 100644 --- a/test/core/consensus/grandpa/vote_graph/walk_back_from_fork_block_node_below_tests.cpp +++ b/test/core/consensus/grandpa/vote_graph/walk_back_from_fork_block_node_below_tests.cpp @@ -30,7 +30,7 @@ struct WalkBackFromBlockNodeBelow })"); expect_getAncestry(GENESIS_HASH, "B"_H, vec("B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {2, "B"_H}, "w10_a"_ID)); + EXPECT_OK(graph->insert(vt, {2, "B"_H}, "w10_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -64,7 +64,7 @@ struct WalkBackFromBlockNodeBelow GENESIS_HASH, "F1"_H, vec("F1"_H, "E1"_H, "D"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); + EXPECT_OK(graph->insert(vt, {6, "F1"_H}, "w5_a"_ID)); AssertGraphCorrect(*graph, R"({ @@ -111,7 +111,7 @@ struct WalkBackFromBlockNodeBelow GENESIS_HASH, "G2"_H, vec("G2"_H, "F2"_H, "E2"_H, "D"_H, "C"_H, "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {7, "G2"_H}, "w5_b"_ID)); + EXPECT_OK(graph->insert(vt, {7, "G2"_H}, "w5_b"_ID)); AssertGraphCorrect(*graph, R"({ @@ -179,7 +179,7 @@ struct WalkBackFromBlockNodeBelow "B"_H, "A"_H, GENESIS_HASH)); - EXPECT_OUTCOME_TRUE_1(graph->insert(vt, {8, "H2"_H}, "w1_a"_ID)); + EXPECT_OK(graph->insert(vt, {8, "H2"_H}, "w1_a"_ID)); AssertGraphCorrect(*graph, R"({ diff --git a/test/core/consensus/grandpa/voter_set_test.cpp b/test/core/consensus/grandpa/voter_set_test.cpp index bf38643d1f..68577b9303 100644 --- a/test/core/consensus/grandpa/voter_set_test.cpp +++ b/test/core/consensus/grandpa/voter_set_test.cpp @@ -5,10 +5,10 @@ */ #include +#include #include "consensus/grandpa/voter_set.hpp" #include "core/consensus/grandpa/literals.hpp" -#include "testutil/outcome.hpp" using kagome::consensus::grandpa::Id; using kagome::consensus::grandpa::VoterSet; @@ -47,14 +47,13 @@ TEST_F(VoterSetTest, AddExistingVoters) { // GIVEN for (auto &[voter, weight] : voters) { - ASSERT_OUTCOME_SUCCESS_TRY(testee->insert(voter, weight)); + EXPECT_OK(testee->insert(voter, weight)); } for (auto &[voter, weight] : voters) { // WHEN+THEN - EXPECT_OUTCOME_ERROR(res, - testee->insert(voter, weight), - VoterSet::Error::VOTER_ALREADY_EXISTS); + EXPECT_EC(testee->insert(voter, weight), + VoterSet::Error::VOTER_ALREADY_EXISTS); } } @@ -62,7 +61,7 @@ TEST_F(VoterSetTest, GetIndex) { // GIVEN for (auto &[voter, weight] : voters) { - ASSERT_OUTCOME_SUCCESS_TRY(testee->insert(voter, weight)); + EXPECT_OK(testee->insert(voter, weight)); } for (auto &[voter, weight] : voters) { @@ -78,7 +77,7 @@ TEST_F(VoterSetTest, GetWeight) { // GIVEN for (auto &[voter, weight] : voters) { - ASSERT_OUTCOME_SUCCESS_TRY(testee->insert(voter, weight)); + EXPECT_OK(testee->insert(voter, weight)); } size_t index = 0; @@ -92,8 +91,7 @@ TEST_F(VoterSetTest, GetWeight) { } { // WHEN+THEN.2 - EXPECT_OUTCOME_SUCCESS(actual_weight_res, testee->voterWeight(index)); - auto &actual_weight = actual_weight_res.value(); + auto actual_weight = EXPECT_OK(testee->voterWeight(index)); EXPECT_EQ(weight, actual_weight); } ++index; @@ -105,9 +103,8 @@ TEST_F(VoterSetTest, GetWeight) { } { // WHEN+THEN.4 - EXPECT_OUTCOME_ERROR(res, - testee->voterWeight(voters.size()), - VoterSet::Error::INDEX_OUTBOUND); + EXPECT_EC(testee->voterWeight(voters.size()), + VoterSet::Error::INDEX_OUTBOUND); } } @@ -115,18 +112,17 @@ TEST_F(VoterSetTest, GetVoter) { // GIVEN for (auto &[voter, weight] : voters) { - ASSERT_OUTCOME_SUCCESS_TRY(testee->insert(voter, weight)); + EXPECT_OK(testee->insert(voter, weight)); } for (size_t index = 0; index < voters.size(); ++index) { // WHEN+THEN.1 - EXPECT_OUTCOME_SUCCESS(voter, testee->voterId(index)); + EXPECT_OK(testee->voterId(index)); } { // WHEN+THEN.2 - EXPECT_OUTCOME_ERROR( - res, testee->voterId(voters.size()), VoterSet::Error::INDEX_OUTBOUND); + EXPECT_EC(testee->voterId(voters.size()), VoterSet::Error::INDEX_OUTBOUND); } } @@ -134,7 +130,7 @@ TEST_F(VoterSetTest, GetIndexAndWeight) { // GIVEN for (auto &[voter, weight] : voters) { - ASSERT_OUTCOME_SUCCESS_TRY(testee->insert(voter, weight)); + EXPECT_OK(testee->insert(voter, weight)); } size_t index = 0; diff --git a/test/core/consensus/timeline/block_executor_test.cpp b/test/core/consensus/timeline/block_executor_test.cpp index 829a236e09..6ab783b52b 100644 --- a/test/core/consensus/timeline/block_executor_test.cpp +++ b/test/core/consensus/timeline/block_executor_test.cpp @@ -7,8 +7,8 @@ #include "consensus/timeline/impl/block_executor_impl.hpp" #include -#include #include +#include #include "blockchain/block_tree_error.hpp" #include "common/main_thread_pool.hpp" @@ -29,7 +29,6 @@ #include "mock/core/transaction_pool/transaction_pool_mock.hpp" #include "testutil/lazy.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "utils/watchdog.hpp" @@ -308,7 +307,7 @@ TEST_F(BlockExecutorTest, JustificationFollowDigests) { block_executor_->applyBlock( Block{block_data.header.value(), block_data.body.value()}, justification, - [&](auto &&result) { ASSERT_OUTCOME_SUCCESS_TRY(result); }); + [&](auto &&result) { EXPECT_OK(result); }); latch.wait(); } diff --git a/test/core/crypto/bandersnatch/bandersnatch_test.cpp b/test/core/crypto/bandersnatch/bandersnatch_test.cpp index 1ae3906f09..05f68c81fa 100644 --- a/test/core/crypto/bandersnatch/bandersnatch_test.cpp +++ b/test/core/crypto/bandersnatch/bandersnatch_test.cpp @@ -5,14 +5,12 @@ */ #include - -#include +#include #include "crypto/bandersnatch/bandersnatch_provider_impl.hpp" #include "crypto/bandersnatch/vrf.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::common::Blob; @@ -68,8 +66,8 @@ struct BandersnatchTest : public ::testing::Test { */ TEST_F(BandersnatchTest, GenerateKeysNotEqual) { for (auto i = 0; i < 10; ++i) { - ASSERT_OUTCOME_SUCCESS(kp1, generate()); - ASSERT_OUTCOME_SUCCESS(kp2, generate()); + auto kp1 = EXPECT_OK(generate()); + auto kp2 = EXPECT_OK(generate()); ASSERT_NE(kp1.public_key, kp2.public_key); ASSERT_NE(kp1.secret_key, kp2.secret_key); } @@ -81,10 +79,9 @@ TEST_F(BandersnatchTest, GenerateKeysNotEqual) { * @then */ TEST_F(BandersnatchTest, PlainSignVerifySuccess) { - ASSERT_OUTCOME_SUCCESS(kp, generate()); - ASSERT_OUTCOME_SUCCESS(signature, bandersnatch_provider->sign(kp, message)); - EXPECT_OUTCOME_SUCCESS( - is_valid, + auto kp = EXPECT_OK(generate()); + auto signature = EXPECT_OK(bandersnatch_provider->sign(kp, message)); + auto is_valid = EXPECT_OK( bandersnatch_provider->verify(signature, message, kp.public_key)); ASSERT_TRUE(is_valid); } @@ -115,7 +112,7 @@ TEST_F(BandersnatchTest, VrfSignVerifySuccess) { }; for (auto i = 0; i < 3; ++i) { - ASSERT_OUTCOME_SUCCESS(kp, generate()); + auto kp = EXPECT_OK(generate()); SL_INFO(log(), "PUB={}", kp.public_key); for (auto &label : labels) { diff --git a/test/core/crypto/bip39/bip39_integration_test.cpp b/test/core/crypto/bip39/bip39_integration_test.cpp index 6e5a3c77b6..be3d8f87d8 100644 --- a/test/core/crypto/bip39/bip39_integration_test.cpp +++ b/test/core/crypto/bip39/bip39_integration_test.cpp @@ -9,9 +9,10 @@ #include "crypto/bip39/mnemonic.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" -#include "testutil/outcome.hpp" #include +#include + #include "testutil/prepare_loggers.hpp" using namespace kagome::common; @@ -41,14 +42,13 @@ struct Bip39IntegrationTest : public ::testing::TestWithParam { TEST_P(Bip39IntegrationTest, DeriveEntropyAndSeedSuccess) { const TestItem &item = GetParam(); - EXPECT_OUTCOME_TRUE(mnemonic, Mnemonic::parse(item.mnemonic)); + auto mnemonic = EXPECT_OK(Mnemonic::parse(item.mnemonic)); auto joined_words = boost::algorithm::join(*mnemonic.words(), " "); ASSERT_EQ(joined_words, item.mnemonic); - EXPECT_OUTCOME_TRUE(entropy, - bip39_provider->calculateEntropy(*mnemonic.words())); + auto entropy = EXPECT_OK(bip39_provider->calculateEntropy(*mnemonic.words())); - EXPECT_OUTCOME_TRUE(seed, bip39_provider->makeSeed(entropy, "Substrate")); + auto seed = EXPECT_OK(bip39_provider->makeSeed(entropy, "Substrate")); ASSERT_EQ(seed, unhex(item.seed).value()); } diff --git a/test/core/crypto/bip39/entropy_calculation_test.cpp b/test/core/crypto/bip39/entropy_calculation_test.cpp index 282f436c88..0842509216 100644 --- a/test/core/crypto/bip39/entropy_calculation_test.cpp +++ b/test/core/crypto/bip39/entropy_calculation_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include "common/blob.hpp" @@ -13,7 +14,6 @@ #include "crypto/bip39/mnemonic.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using namespace kagome; @@ -53,14 +53,13 @@ struct Bip39EntropyTest : public ::testing::Test { * @then entropy and seed come up with predefined values */ TEST_F(Bip39EntropyTest, DecodeSuccess) { - EXPECT_OUTCOME_TRUE(mnemonic, Mnemonic::parse(phrase)); + auto mnemonic = EXPECT_OK(Mnemonic::parse(phrase)); auto joined_words = boost::algorithm::join(*mnemonic.words(), " "); ASSERT_EQ(joined_words, phrase); - EXPECT_OUTCOME_TRUE(entropy, - bip39_provider->calculateEntropy(*mnemonic.words())); + auto entropy = EXPECT_OK(bip39_provider->calculateEntropy(*mnemonic.words())); ASSERT_EQ(common::Buffer(entropy).toHex(), entropy_hex); - EXPECT_OUTCOME_TRUE(seed, bip39_provider->makeSeed(entropy, "Substrate")); + auto seed = EXPECT_OK(bip39_provider->makeSeed(entropy, "Substrate")); ASSERT_EQ(seed, common::unhex(seed_hex).value()); } diff --git a/test/core/crypto/ecdsa/ecdsa_provider_test.cpp b/test/core/crypto/ecdsa/ecdsa_provider_test.cpp index bdcf567119..a1b32b1b0e 100644 --- a/test/core/crypto/ecdsa/ecdsa_provider_test.cpp +++ b/test/core/crypto/ecdsa/ecdsa_provider_test.cpp @@ -5,15 +5,13 @@ */ #include - -#include +#include #include "crypto/bip39/impl/bip39_provider_impl.hpp" #include "crypto/ecdsa/ecdsa_provider_impl.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::crypto::Bip39ProviderImpl; @@ -76,10 +74,9 @@ TEST_F(EcdsaProviderTest, GenerateKeysNotEqual) { */ TEST_F(EcdsaProviderTest, SignVerifySuccess) { auto key_pair = generate(); - EXPECT_OUTCOME_TRUE(signature, - ecdsa_provider_->sign(message, key_pair.secret_key)); - EXPECT_OUTCOME_TRUE( - verify_res, + auto signature = + EXPECT_OK(ecdsa_provider_->sign(message, key_pair.secret_key)); + auto verify_res = EXPECT_OK( ecdsa_provider_->verify(message, signature, key_pair.public_key, false)); ASSERT_EQ(verify_res, true); } @@ -92,14 +89,12 @@ TEST_F(EcdsaProviderTest, SignVerifySuccess) { */ TEST_F(EcdsaProviderTest, VerifyWrongKeyFail) { auto key_pair = generate(); - EXPECT_OUTCOME_TRUE(signature, - ecdsa_provider_->sign(message, key_pair.secret_key)); + auto signature = + EXPECT_OK(ecdsa_provider_->sign(message, key_pair.secret_key)); // generate another valid key pair and take public one auto another_keypair = generate(); - EXPECT_OUTCOME_TRUE( - ver_res, - ecdsa_provider_->verify( - message, signature, another_keypair.public_key, false)); + auto ver_res = EXPECT_OK(ecdsa_provider_->verify( + message, signature, another_keypair.public_key, false)); ASSERT_FALSE(ver_res); } diff --git a/test/core/crypto/ed25519/ed25519_provider_test.cpp b/test/core/crypto/ed25519/ed25519_provider_test.cpp index f15e642283..500676bbeb 100644 --- a/test/core/crypto/ed25519/ed25519_provider_test.cpp +++ b/test/core/crypto/ed25519/ed25519_provider_test.cpp @@ -5,15 +5,13 @@ */ #include - -#include +#include #include "crypto/bip39/impl/bip39_provider_impl.hpp" #include "crypto/ed25519/ed25519_provider_impl.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::common::Hash256; @@ -87,9 +85,9 @@ TEST_F(Ed25519ProviderTest, GenerateKeysNotEqual) { */ TEST_F(Ed25519ProviderTest, SignVerifySuccess) { auto kp = generate(); - EXPECT_OUTCOME_TRUE(signature, ed25519_provider->sign(kp, message_span)); - EXPECT_OUTCOME_TRUE( - res, ed25519_provider->verify(signature, message_span, kp.public_key)); + auto signature = EXPECT_OK(ed25519_provider->sign(kp, message_span)); + auto res = EXPECT_OK( + ed25519_provider->verify(signature, message_span, kp.public_key)); ASSERT_EQ(res, true); } @@ -105,7 +103,7 @@ TEST_F(Ed25519ProviderTest, SignVerifySuccess) { TEST_F(Ed25519ProviderTest, SignWithInvalidKeyFails) { auto kp = generate(); kp.public_key.fill(1); - EXPECT_OUTCOME_FALSE_1(ed25519_provider->sign(kp, message_span)); + EXPECT_HAS_ERROR(ed25519_provider->sign(kp, message_span)); } /** @@ -117,11 +115,10 @@ TEST_F(Ed25519ProviderTest, SignWithInvalidKeyFails) { */ TEST_F(Ed25519ProviderTest, VerifyWrongKeyFail) { auto kp = generate(); - EXPECT_OUTCOME_TRUE(signature, ed25519_provider->sign(kp, message_span)); + auto signature = EXPECT_OK(ed25519_provider->sign(kp, message_span)); // generate another valid key pair and take public one auto kp1 = generate(); - EXPECT_OUTCOME_TRUE( - ver_res, + auto ver_res = EXPECT_OK( ed25519_provider->verify(signature, message_span, kp1.public_key)); ASSERT_FALSE(ver_res); @@ -140,10 +137,10 @@ TEST_F(Ed25519ProviderTest, VerifyWrongKeyFail) { */ TEST_F(Ed25519ProviderTest, DISABLED_VerifyInvalidKeyFail) { auto kp = generate(); - EXPECT_OUTCOME_TRUE(signature, ed25519_provider->sign(kp, message_span)); + auto signature = EXPECT_OK(ed25519_provider->sign(kp, message_span)); // make public key invalid kp.public_key.fill(1); - EXPECT_OUTCOME_FALSE_1( + EXPECT_HAS_ERROR( ed25519_provider->verify(signature, message_span, kp.public_key)); } @@ -153,13 +150,12 @@ TEST_F(Ed25519ProviderTest, DISABLED_VerifyInvalidKeyFail) { * @then public and private keys come up with predefined values */ TEST_F(Ed25519ProviderTest, GenerateBySeedSuccess) { - EXPECT_OUTCOME_TRUE( - seed, Ed25519Seed::fromHex(SecureCleanGuard(std::string(hex_seed)))); - EXPECT_OUTCOME_TRUE(public_key, Ed25519PublicKey::fromHex(hex_public_key)); + auto seed = + EXPECT_OK(Ed25519Seed::fromHex(SecureCleanGuard(std::string(hex_seed)))); + auto public_key = EXPECT_OK(Ed25519PublicKey::fromHex(hex_public_key)); // private key is the same as seed - EXPECT_OUTCOME_TRUE( - private_key, + auto private_key = EXPECT_OK( Ed25519PrivateKey::fromHex(SecureCleanGuard(std::string(hex_seed)))); auto kp = ed25519_provider->generateKeypair(seed, {}).value(); diff --git a/test/core/crypto/key_store/key_store_test.cpp b/test/core/crypto/key_store/key_store_test.cpp index 8e28300f3e..e93ce2d198 100644 --- a/test/core/crypto/key_store/key_store_test.cpp +++ b/test/core/crypto/key_store/key_store_test.cpp @@ -7,7 +7,7 @@ #include "crypto/key_store/key_store_impl.hpp" #include -#include +#include #include "crypto/bandersnatch/bandersnatch_provider_impl.hpp" #include "crypto/bip39/impl/bip39_provider_impl.hpp" @@ -20,7 +20,6 @@ #include "mock/core/application/app_state_manager_mock.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/storage/base_fs_test.hpp" @@ -122,23 +121,20 @@ struct KeyStoreTest : public test::BaseFS_Test { mnemonic = "ozone drill grab fiber curtain grace pudding thank cruise elder eight " "picnic"; - EXPECT_OUTCOME_TRUE(e, Buffer::fromHex("9e885d952ad362caeb4efe34a8e91bd2")); + auto e = EXPECT_OK(Buffer::fromHex("9e885d952ad362caeb4efe34a8e91bd2")); entropy = std::move(e); - EXPECT_OUTCOME_TRUE(s, - Blob<32>::fromHex("a4681403ba5b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto s = + EXPECT_OK(Blob<32>::fromHex("a4681403ba5b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); seed = s; key_type = KeyTypes::BABE; - EXPECT_OUTCOME_TRUE( - sr_publ, + auto sr_publ = EXPECT_OK( Sr25519PublicKey::fromHex("56a03c8afc0e7a3a8b1d53bcc875ba5b6364754f9045" "16009b57ef3adf96f61f")); - EXPECT_OUTCOME_TRUE( - sr_secr, - Sr25519SecretKey::fromHex(SecureCleanGuard{ - "ec96cb0816b67b045baae21841952a61ecb0612a109293e10c5453b950659c0a8b" - "35b6d6196f33169334e36a05d624d9996d07243f9f71e638e3bc29a5330ec9"s})); + auto sr_secr = EXPECT_OK(Sr25519SecretKey::fromHex(SecureCleanGuard{ + "ec96cb0816b67b045baae21841952a61ecb0612a109293e10c5453b950659c0a8b" + "35b6d6196f33169334e36a05d624d9996d07243f9f71e638e3bc29a5330ec9"s})); sr_pair = {sr_secr, sr_publ}; } @@ -169,8 +165,8 @@ TEST_F(KeyStoreTest, generateEd25519KeypairMnemonicSuccess) { auto res = key_store->ed25519().findKeypair(key_type, ed_pair.public_key); ASSERT_EQ(res, std::nullopt); - EXPECT_OUTCOME_TRUE(pair, - key_store->ed25519().generateKeypair(key_type, mnemonic)); + auto pair = + EXPECT_OK(key_store->ed25519().generateKeypair(key_type, mnemonic)); ASSERT_EQ(pair, ed_pair); // check that created pair is now contained in memory @@ -188,8 +184,8 @@ TEST_F(KeyStoreTest, generateEd25519KeypairMnemonicSuccess) { * @and generated key pair is stored in memory */ TEST_F(KeyStoreTest, generateSr25519KeypairMnemonicSuccess) { - EXPECT_OUTCOME_TRUE(pair, - key_store->sr25519().generateKeypair(key_type, mnemonic)); + auto pair = + EXPECT_OK(key_store->sr25519().generateKeypair(key_type, mnemonic)); ASSERT_EQ(pair, sr_pair); // check that created pair is now contained in memory @@ -209,9 +205,8 @@ TEST_F(KeyStoreTest, generateEd25519KeypairSeedSuccess) { auto res = key_store->ed25519().findKeypair(key_type, ed_pair.public_key); ASSERT_EQ(res, std::nullopt); - EXPECT_OUTCOME_TRUE(pair, - key_store->ed25519().generateKeypair( - key_type, Ed25519Seed::from(SecureCleanGuard{seed}))); + auto pair = EXPECT_OK(key_store->ed25519().generateKeypair( + key_type, Ed25519Seed::from(SecureCleanGuard{seed}))); ASSERT_EQ(pair, ed_pair); // check that created pair is now contained in memory @@ -231,9 +226,8 @@ TEST_F(KeyStoreTest, generateSr25519KeypairSeedSuccess) { auto res = key_store->sr25519().findKeypair(key_type, sr_pair.public_key); ASSERT_EQ(res, std::nullopt); - EXPECT_OUTCOME_TRUE(pair, - key_store->sr25519().generateKeypair( - key_type, Sr25519Seed::from(SecureCleanGuard{seed}))); + auto pair = EXPECT_OK(key_store->sr25519().generateKeypair( + key_type, Sr25519Seed::from(SecureCleanGuard{seed}))); ASSERT_EQ(pair, sr_pair); // check that created pair is now contained in memory @@ -250,8 +244,7 @@ TEST_F(KeyStoreTest, generateSr25519KeypairSeedSuccess) { * @then a new ed25519 key pair is generated and stored on disk */ TEST_F(KeyStoreTest, generateEd25519KeypairStoreSuccess) { - EXPECT_OUTCOME_TRUE(pair, - key_store->ed25519().generateKeypairOnDisk(key_type)); + auto pair = EXPECT_OK(key_store->ed25519().generateKeypairOnDisk(key_type)); // check that created pair is contained in the storage on disk auto found = key_store->ed25519().findKeypair(key_type, pair.public_key); @@ -267,8 +260,7 @@ TEST_F(KeyStoreTest, generateEd25519KeypairStoreSuccess) { * @then a new ed25519 key pair is generated and stored on disk */ TEST_F(KeyStoreTest, generateSr25519KeypairStoreSuccess) { - EXPECT_OUTCOME_TRUE(pair, - key_store->sr25519().generateKeypairOnDisk(key_type)); + auto pair = EXPECT_OK(key_store->sr25519().generateKeypairOnDisk(key_type)); // check that created pair is contained in the storage on disk auto found = key_store->sr25519().findKeypair(key_type, pair.public_key); @@ -284,14 +276,14 @@ TEST_F(KeyStoreTest, generateSr25519KeypairStoreSuccess) { * @then collection of all ed25519 public keys of provided type is returned */ TEST_F(KeyStoreTest, getEd25519PublicKeysSuccess) { - EXPECT_OUTCOME_TRUE( - pair1, key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_TRUE( - pair2, key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_SUCCESS( - pair4, key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_SUCCESS( - pair5, key_store->sr25519().generateKeypairOnDisk(KeyTypes::ACCOUNT)); + auto pair1 = + EXPECT_OK(key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair2 = + EXPECT_OK(key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair4 = + EXPECT_OK(key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair5 = + EXPECT_OK(key_store->sr25519().generateKeypairOnDisk(KeyTypes::ACCOUNT)); std::set ed_babe_keys_set = {pair1.public_key, pair2.public_key}; @@ -307,14 +299,14 @@ TEST_F(KeyStoreTest, getEd25519PublicKeysSuccess) { * @then collection of all sr25519 public keys of provided type is returned */ TEST_F(KeyStoreTest, getSr25519PublicKeysSuccess) { - EXPECT_OUTCOME_TRUE( - pair1, key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_TRUE( - pair2, key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_SUCCESS( - pair4, key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); - EXPECT_OUTCOME_SUCCESS( - pair5, key_store->ed25519().generateKeypairOnDisk(KeyTypes::ACCOUNT)); + auto pair1 = + EXPECT_OK(key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair2 = + EXPECT_OK(key_store->sr25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair4 = + EXPECT_OK(key_store->ed25519().generateKeypairOnDisk(KeyTypes::BABE)); + auto pair5 = + EXPECT_OK(key_store->ed25519().generateKeypairOnDisk(KeyTypes::ACCOUNT)); std::set sr_babe_keys_set = {pair1.public_key, pair2.public_key}; diff --git a/test/core/crypto/secp256k1/secp256k1_provider_test.cpp b/test/core/crypto/secp256k1/secp256k1_provider_test.cpp index 26db5fa229..528c68de9e 100644 --- a/test/core/crypto/secp256k1/secp256k1_provider_test.cpp +++ b/test/core/crypto/secp256k1/secp256k1_provider_test.cpp @@ -10,7 +10,7 @@ #include "crypto/hasher/hasher_impl.hpp" #include -#include "testutil/outcome.hpp" +#include using kagome::common::Blob; using kagome::common::Buffer; @@ -41,26 +41,24 @@ struct Secp256k1ProviderTest : public ::testing::Test { void SetUp() override { // message: "this is a message" - EXPECT_OUTCOME_TRUE(secp_message_vector, - Buffer::fromHex("746869732069732061206d657373616765")); + auto secp_message_vector = + EXPECT_OK(Buffer::fromHex("746869732069732061206d657373616765")); secp_message_hash = hasher->blake2s_256(secp_message_vector); - EXPECT_OUTCOME_TRUE( - secp_public_key_expanded_bytes, + auto secp_public_key_expanded_bytes = EXPECT_OK( Buffer::fromHex("04f821bc128a43d9b0516969111e19a40bab417f45181d692d0519" "a3b35573cb63178403d12eb41d7702913a70ebc1c64438002a1474" "e1328276b7dcdacb511fc3")); secp_public_key_expanded = UncompressedPublicKey::fromSpan(secp_public_key_expanded_bytes).value(); - EXPECT_OUTCOME_TRUE(secp_public_key_compressed_bytes, - Buffer::fromHex("03f821bc128a43d9b0516969111e19a40bab41" - "7f45181d692d0519a3b35573cb63")); + auto secp_public_key_compressed_bytes = + EXPECT_OK(Buffer::fromHex("03f821bc128a43d9b0516969111e19a40bab41" + "7f45181d692d0519a3b35573cb63")); secp_public_key_compressed = CompressedPublicKey::fromSpan(secp_public_key_compressed_bytes).value(); - EXPECT_OUTCOME_TRUE( - secp_signature_bytes, + auto secp_signature_bytes = EXPECT_OK( Buffer::fromHex("ebdedee38bcf530f13c1b5c8717d974a6f8bd25a7e3707ca36c7ee" "7efd5aa6c557bcc67906975696cbb28a556b649e5fbf5ce5183157" "2cd54add248c4d023fcf01")); @@ -77,10 +75,9 @@ struct Secp256k1ProviderTest : public ::testing::Test { TEST_F(Secp256k1ProviderTest, RecoverInvalidRecidFailure) { RSVSignature wrong_signature = secp_signature; *wrong_signature.rbegin() = 0xFF; - EXPECT_OUTCOME_ERROR(res, - secp256K1_provider->recoverPublickeyUncompressed( - wrong_signature, secp_message_hash, false), - Secp256k1ProviderError::INVALID_V_VALUE); + EXPECT_EC(secp256K1_provider->recoverPublickeyUncompressed( + wrong_signature, secp_message_hash, false), + Secp256k1ProviderError::INVALID_V_VALUE); } /** @@ -99,7 +96,7 @@ TEST_F(Secp256k1ProviderTest, RecoverInvalidSignatureFailure) { ASSERT_NE(res.value(), secp_public_key_expanded); } else { // otherwise the operation should result in failure - EXPECT_OUTCOME_ERROR(err, res, Secp256k1ProviderError::INVALID_SIGNATURE); + EXPECT_EC(res, Secp256k1ProviderError::INVALID_SIGNATURE); } } @@ -109,9 +106,8 @@ TEST_F(Secp256k1ProviderTest, RecoverInvalidSignatureFailure) { * @then Recovery is successful, public key returned */ TEST_F(Secp256k1ProviderTest, RecoverUncompressedSuccess) { - EXPECT_OUTCOME_TRUE(public_key, - secp256K1_provider->recoverPublickeyUncompressed( - secp_signature, secp_message_hash, false)); + auto public_key = EXPECT_OK(secp256K1_provider->recoverPublickeyUncompressed( + secp_signature, secp_message_hash, false)); EXPECT_EQ(public_key, secp_public_key_expanded); } @@ -121,8 +117,7 @@ TEST_F(Secp256k1ProviderTest, RecoverUncompressedSuccess) { * @then Recovery is successful, public key is returned */ TEST_F(Secp256k1ProviderTest, RecoverCompressedSuccess) { - EXPECT_OUTCOME_TRUE(public_key, - secp256K1_provider->recoverPublickeyCompressed( - secp_signature, secp_message_hash, false)); + auto public_key = EXPECT_OK(secp256K1_provider->recoverPublickeyCompressed( + secp_signature, secp_message_hash, false)); EXPECT_EQ(public_key, secp_public_key_compressed); } diff --git a/test/core/crypto/sr25519/sr25519_provider_test.cpp b/test/core/crypto/sr25519/sr25519_provider_test.cpp index 7faf470bd7..e956c58ae5 100644 --- a/test/core/crypto/sr25519/sr25519_provider_test.cpp +++ b/test/core/crypto/sr25519/sr25519_provider_test.cpp @@ -7,13 +7,12 @@ #include "crypto/sr25519/sr25519_provider_impl.hpp" #include -#include +#include #include "crypto/bip39/impl/bip39_provider_impl.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::crypto::Bip39ProviderImpl; @@ -77,8 +76,8 @@ struct Sr25519ProviderTest : public ::testing::Test { */ TEST_F(Sr25519ProviderTest, GenerateKeysNotEqual) { for (auto i = 0; i < 10; ++i) { - EXPECT_OUTCOME_TRUE(kp1, generate()); - EXPECT_OUTCOME_TRUE(kp2, generate()); + auto kp1 = EXPECT_OK(generate()); + auto kp2 = EXPECT_OK(generate()); ASSERT_NE(kp1.public_key, kp2.public_key); ASSERT_NE(kp1.secret_key, kp2.secret_key); } @@ -92,10 +91,10 @@ TEST_F(Sr25519ProviderTest, GenerateKeysNotEqual) { * @then verification succeeds */ TEST_F(Sr25519ProviderTest, SignVerifySuccess) { - EXPECT_OUTCOME_TRUE(kp, generate()); - EXPECT_OUTCOME_TRUE(signature, sr25519_provider->sign(kp, message_span)); - EXPECT_OUTCOME_TRUE( - res, sr25519_provider->verify(signature, message_span, kp.public_key)); + auto kp = EXPECT_OK(generate()); + auto signature = EXPECT_OK(sr25519_provider->sign(kp, message_span)); + auto res = EXPECT_OK( + sr25519_provider->verify(signature, message_span, kp.public_key)); ASSERT_EQ(res, true); } @@ -109,9 +108,9 @@ TEST_F(Sr25519ProviderTest, SignVerifySuccess) { * @then sign fails */ TEST_F(Sr25519ProviderTest, DISABLED_SignWithInvalidKeyFails) { - EXPECT_OUTCOME_TRUE(kp, generate()); + auto kp = EXPECT_OK(generate()); kp.public_key.fill(1); - EXPECT_OUTCOME_FALSE_1(sr25519_provider->sign(kp, message_span)); + EXPECT_HAS_ERROR(sr25519_provider->sign(kp, message_span)); } /** @@ -122,12 +121,11 @@ TEST_F(Sr25519ProviderTest, DISABLED_SignWithInvalidKeyFails) { * @then verification succeeds, but verification result is false */ TEST_F(Sr25519ProviderTest, VerifyWrongKeyFail) { - EXPECT_OUTCOME_TRUE(kp, generate()); - EXPECT_OUTCOME_TRUE(signature, sr25519_provider->sign(kp, message_span)); + auto kp = EXPECT_OK(generate()); + auto signature = EXPECT_OK(sr25519_provider->sign(kp, message_span)); // generate another valid key pair and take public one - EXPECT_OUTCOME_TRUE(kp1, generate()); - EXPECT_OUTCOME_TRUE( - ver_res, + auto kp1 = EXPECT_OK(generate()); + auto ver_res = EXPECT_OK( sr25519_provider->verify(signature, message_span, kp1.public_key)); ASSERT_FALSE(ver_res); @@ -145,11 +143,11 @@ TEST_F(Sr25519ProviderTest, VerifyWrongKeyFail) { * @then verification fails */ TEST_F(Sr25519ProviderTest, DISABLED_VerifyInvalidKeyFail) { - EXPECT_OUTCOME_TRUE(kp, generate()); - EXPECT_OUTCOME_TRUE(signature, sr25519_provider->sign(kp, message_span)); + auto kp = EXPECT_OK(generate()); + auto signature = EXPECT_OK(sr25519_provider->sign(kp, message_span)); // make public key invalid kp.public_key.fill(1); - EXPECT_OUTCOME_FALSE_1( + EXPECT_HAS_ERROR( sr25519_provider->verify(signature, message_span, kp.public_key)); } @@ -159,16 +157,15 @@ TEST_F(Sr25519ProviderTest, DISABLED_VerifyInvalidKeyFail) { * @then verifying and secret keys come up with predefined values */ TEST_F(Sr25519ProviderTest, GenerateBySeedSuccess) { - EXPECT_OUTCOME_TRUE( - seed, Sr25519Seed::fromHex(SecureCleanGuard{std::string(hex_seed)})); - EXPECT_OUTCOME_TRUE(public_key, Sr25519PublicKey::fromHex(hex_vk)); + auto seed = + EXPECT_OK(Sr25519Seed::fromHex(SecureCleanGuard{std::string(hex_seed)})); + auto public_key = EXPECT_OK(Sr25519PublicKey::fromHex(hex_vk)); // private key is the same as seed - EXPECT_OUTCOME_TRUE( - secret_key, + auto secret_key = EXPECT_OK( Sr25519SecretKey::fromHex(SecureCleanGuard{std::string{hex_sk}})); - EXPECT_OUTCOME_TRUE(kp, sr25519_provider->generateKeypair(seed, {})); + auto kp = EXPECT_OK(sr25519_provider->generateKeypair(seed, {})); ASSERT_EQ(kp.secret_key, secret_key); ASSERT_EQ(kp.public_key, public_key); diff --git a/test/core/host_api/child_storage_extension_test.cpp b/test/core/host_api/child_storage_extension_test.cpp index 58f55deaaf..dc168ded35 100644 --- a/test/core/host_api/child_storage_extension_test.cpp +++ b/test/core/host_api/child_storage_extension_test.cpp @@ -10,19 +10,18 @@ #include #include +#include #include "common/monadic_utils.hpp" #include "mock/core/runtime/memory_provider_mock.hpp" #include "mock/core/runtime/trie_storage_provider_mock.hpp" #include "mock/core/storage/trie/polkadot_trie_cursor_mock.h" #include "mock/core/storage/trie/trie_batches_mock.hpp" #include "runtime/ptr_size.hpp" -#include "scale/encode_append.hpp" #include "scale/kagome_scale.hpp" #include "storage/predefined_keys.hpp" #include "storage/trie/polkadot_trie/trie_error.hpp" #include "storage/trie/types.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/outcome/dummy_error.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/memory.hpp" diff --git a/test/core/host_api/crypto_extension_test.cpp b/test/core/host_api/crypto_extension_test.cpp index d9c1853641..accff4c112 100644 --- a/test/core/host_api/crypto_extension_test.cpp +++ b/test/core/host_api/crypto_extension_test.cpp @@ -9,8 +9,9 @@ #include #include -#include +#include +#include #include "crypto/ecdsa/ecdsa_provider_impl.hpp" #include "crypto/ed25519/ed25519_provider_impl.hpp" #include "crypto/hasher/hasher_impl.hpp" @@ -21,9 +22,7 @@ #include "mock/core/crypto/key_store_mock.hpp" #include "mock/core/runtime/memory_provider_mock.hpp" #include "runtime/ptr_size.hpp" -#include "scale/scale.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/memory.hpp" @@ -108,8 +107,8 @@ class CryptoExtensionTest : public ::testing::Test { hasher_, key_store_); - EXPECT_OUTCOME_TRUE(seed_tmp, - kagome::common::Blob<32>::fromHexWithPrefix(seed_hex)); + auto seed_tmp = + EXPECT_OK(kagome::common::Blob<32>::fromHexWithPrefix(seed_hex)); std::copy_n(seed_tmp.begin(), Blob<32>::size(), seed.begin()); // scale-encoded string @@ -322,7 +321,7 @@ TEST_F(CryptoExtensionTest, Ed25519VerifySuccess) { random_generator_->fillRandomly(seed_buf); auto seed = Ed25519Seed::from(std::move(seed_buf)).value(); auto keypair = ed25519_provider_->generateKeypair(seed, {}).value(); - EXPECT_OUTCOME_TRUE(signature, ed25519_provider_->sign(keypair, input)); + auto signature = EXPECT_OK(ed25519_provider_->sign(keypair, input)); ASSERT_EQ( crypto_ext_->ext_crypto_ed25519_verify_version_1( diff --git a/test/core/host_api/misc_extension_test.cpp b/test/core/host_api/misc_extension_test.cpp index ac2718ccb7..ecb95a9874 100644 --- a/test/core/host_api/misc_extension_test.cpp +++ b/test/core/host_api/misc_extension_test.cpp @@ -8,11 +8,11 @@ #include +#include #include "mock/core/crypto/hasher_mock.hpp" #include "mock/core/runtime/core_api_factory_mock.hpp" #include "mock/core/runtime/core_mock.hpp" #include "mock/core/runtime/memory_provider_mock.hpp" -#include "scale/scale.hpp" #include "testutil/literals.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/memory.hpp" diff --git a/test/core/host_api/offchain_extension_test.cpp b/test/core/host_api/offchain_extension_test.cpp index 1358491842..25424c47bf 100644 --- a/test/core/host_api/offchain_extension_test.cpp +++ b/test/core/host_api/offchain_extension_test.cpp @@ -8,6 +8,7 @@ #include +#include #include "mock/core/offchain/offchain_persistent_storage_mock.hpp" #include "mock/core/offchain/offchain_worker_mock.hpp" #include "mock/core/offchain/offchain_worker_pool_mock.hpp" @@ -17,9 +18,7 @@ #include "mock/core/storage/trie/trie_batches_mock.hpp" #include "offchain/types.hpp" #include "runtime/ptr_size.hpp" -#include "scale/encode_append.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/outcome/dummy_error.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/memory.hpp" diff --git a/test/core/host_api/storage_extension_test.cpp b/test/core/host_api/storage_extension_test.cpp index 064521c792..634de7ed42 100644 --- a/test/core/host_api/storage_extension_test.cpp +++ b/test/core/host_api/storage_extension_test.cpp @@ -12,17 +12,16 @@ #include #include +#include #include "crypto/hasher/hasher_impl.hpp" #include "mock/core/runtime/memory_provider_mock.hpp" #include "mock/core/runtime/trie_storage_provider_mock.hpp" #include "mock/core/storage/trie/polkadot_trie_cursor_mock.h" #include "mock/core/storage/trie/trie_batches_mock.hpp" #include "runtime/ptr_size.hpp" -#include "scale/encode_append.hpp" #include "scale/kagome_scale.hpp" #include "storage/predefined_keys.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/outcome/dummy_error.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/memory.hpp" diff --git a/test/core/network/rpc_libp2p_test.cpp b/test/core/network/rpc_libp2p_test.cpp index ebe24f4d14..0fdc6af101 100644 --- a/test/core/network/rpc_libp2p_test.cpp +++ b/test/core/network/rpc_libp2p_test.cpp @@ -8,13 +8,13 @@ #include +#include #include "mock/libp2p/basic/read_writer_mock.hpp" #include "mock/libp2p/connection/stream_mock.hpp" #include "mock/libp2p/host/host_mock.hpp" #include "network/helpers/scale_message_read_writer.hpp" #include "network/types/blocks_response.hpp" #include "scale/kagome_scale.hpp" -#include "scale/scale.hpp" #include "testutil/libp2p/message_read_writer_helper.hpp" #include "testutil/literals.hpp" #include "testutil/prepare_loggers.hpp" diff --git a/test/core/network/state_protocol_observer_test.cpp b/test/core/network/state_protocol_observer_test.cpp index 7c2693fdfb..4817d7af05 100644 --- a/test/core/network/state_protocol_observer_test.cpp +++ b/test/core/network/state_protocol_observer_test.cpp @@ -7,7 +7,7 @@ #include "network/impl/state_protocol_observer_impl.hpp" #include -#include +#include #include "mock/core/blockchain/block_header_repository_mock.hpp" #include "mock/core/storage/trie_pruner/trie_pruner_mock.hpp" @@ -21,7 +21,6 @@ #include "storage/trie/trie_storage_backend.hpp" #include "storage/trie/types.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using namespace kagome; @@ -125,10 +124,10 @@ namespace kagome::network { * @then response with 2 entries */ TEST_F(StateProtocolObserverTest, Simple) { - EXPECT_OUTCOME_TRUE(batch, persistent_empty_batch()); + auto batch = EXPECT_OK(persistent_empty_batch()); std::ignore = batch->put("abc"_buf, "123"_buf); std::ignore = batch->put("cde"_buf, "345"_buf); - EXPECT_OUTCOME_TRUE(hash, batch->commit(storage::trie::StateVersion::V0)); + auto hash = EXPECT_OK(batch->commit(storage::trie::StateVersion::V0)); auto header = makeBlockHeader(hash); EXPECT_CALL(*headers_, getBlockHeader({"1"_hash256})) @@ -140,8 +139,7 @@ TEST_F(StateProtocolObserverTest, Simple) { .no_proof = true, }; - EXPECT_OUTCOME_TRUE(response, - state_protocol_observer_->onStateRequest(request)); + auto response = EXPECT_OK(state_protocol_observer_->onStateRequest(request)); StateResponse ref = { .entries = {{ diff --git a/test/core/network/sync_protocol_observer_test.cpp b/test/core/network/sync_protocol_observer_test.cpp index 5e6c9114a0..02431a2f0d 100644 --- a/test/core/network/sync_protocol_observer_test.cpp +++ b/test/core/network/sync_protocol_observer_test.cpp @@ -7,9 +7,7 @@ #include "network/impl/sync_protocol_observer_impl.hpp" #include - -#include -#include +#include #include "application/app_configuration.hpp" #include "mock/core/blockchain/block_header_repository_mock.hpp" @@ -20,7 +18,6 @@ #include "primitives/block.hpp" #include "testutil/gmock_actions.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using namespace kagome; @@ -108,9 +105,8 @@ TEST_F(SyncProtocolObserverTest, ProcessRequest) { }); // WHEN - EXPECT_OUTCOME_TRUE(response, - sync_protocol_observer_->onBlocksRequest(received_request, - peer_info_.id)); + auto response = EXPECT_OK(sync_protocol_observer_->onBlocksRequest( + received_request, peer_info_.id)); // THEN const auto &received_blocks = response.blocks; diff --git a/test/core/network/types/block_announce_test.cpp b/test/core/network/types/block_announce_test.cpp index 361589ebf8..f3f4b939c6 100644 --- a/test/core/network/types/block_announce_test.cpp +++ b/test/core/network/types/block_announce_test.cpp @@ -5,12 +5,11 @@ */ #include "network/types/block_announce.hpp" -#include - #include -#include "scale/scale.hpp" +#include + +#include #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/primitives/mp_utils.hpp" using kagome::common::Buffer; @@ -55,7 +54,7 @@ struct BlockAnnounceTest : public ::testing::Test { * @then decoded block announce matches initial one */ TEST_F(BlockAnnounceTest, EncodeSuccess) { - ASSERT_OUTCOME_SUCCESS(buffer, encode(block_announce)); - ASSERT_OUTCOME_SUCCESS(ba, decode(buffer)); + auto buffer = EXPECT_OK(encode(block_announce)); + auto ba = EXPECT_OK(decode(buffer)); ASSERT_EQ(block_announce, ba); } diff --git a/test/core/network/types/block_attributes_test.cpp b/test/core/network/types/block_attributes_test.cpp index a0b0da45d1..ede3b2d85e 100644 --- a/test/core/network/types/block_attributes_test.cpp +++ b/test/core/network/types/block_attributes_test.cpp @@ -7,8 +7,9 @@ #include "network/types/block_attributes.hpp" #include -#include "scale/scale.hpp" -#include "testutil/outcome.hpp" +#include +#include + #include "testutil/testparam.hpp" using kagome::network::BlockAttribute; @@ -37,7 +38,7 @@ TEST_P(BlockAttributesTest, DecodeBlockAttributes) { EXPECT_EC(decode(encoded_value), scale::DecodeError::UNEXPECTED_VALUE); } else { - EXPECT_OUTCOME_TRUE(val, decode(encoded_value)); + auto val = EXPECT_OK(decode(encoded_value)); ASSERT_EQ(val, value); } } diff --git a/test/core/network/types/block_direction_test.cpp b/test/core/network/types/block_direction_test.cpp index 0b7b023109..42ce7a8b4b 100644 --- a/test/core/network/types/block_direction_test.cpp +++ b/test/core/network/types/block_direction_test.cpp @@ -7,9 +7,9 @@ #include "network/types/block_direction.hpp" #include +#include #include -#include "testutil/outcome.hpp" #include "testutil/testparam.hpp" using kagome::network::Direction; @@ -35,7 +35,7 @@ TEST_P(DirectionTest, DecodeDirection) { EXPECT_EC(decode(encoded_value), scale::DecodeError::INVALID_ENUM_VALUE); } else { - EXPECT_OUTCOME_TRUE(val, decode(encoded_value)); + auto val = EXPECT_OK(decode(encoded_value)); ASSERT_EQ(val, value); } } diff --git a/test/core/network/types/message_read_writer_test.cpp b/test/core/network/types/message_read_writer_test.cpp index 81d7fc2116..24ac858def 100644 --- a/test/core/network/types/message_read_writer_test.cpp +++ b/test/core/network/types/message_read_writer_test.cpp @@ -8,7 +8,6 @@ #include #include "mock/core/network/adapter_mock.hpp" -#include "testutil/outcome.hpp" using AdapterType_0 = kagome::network::AdapterMock; using AdapterMockPtrType = std::shared_ptr; diff --git a/test/core/network/types/protobuf_block_request_test.cpp b/test/core/network/types/protobuf_block_request_test.cpp index 9e843c303d..d801c0048d 100644 --- a/test/core/network/types/protobuf_block_request_test.cpp +++ b/test/core/network/types/protobuf_block_request_test.cpp @@ -6,8 +6,7 @@ #include "network/adapters/protobuf_block_request.hpp" #include - -#include "testutil/outcome.hpp" +#include using kagome::network::BlockAttribute; using kagome::network::BlocksRequest; @@ -25,10 +24,9 @@ struct ProtobufBlockRequestAdapterTest : public ::testing::Test { request.direction = Direction::DESCENDING; request.fields = toBlockAttribute(0x19); - EXPECT_OUTCOME_TRUE( - hash_from, - BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto hash_from = + EXPECT_OK(BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); request.from = hash_from; } @@ -47,7 +45,7 @@ TEST_F(ProtobufBlockRequestAdapterTest, Serialization) { AdapterType::write(request, data, data.end()); BlocksRequest r2; - EXPECT_OUTCOME_TRUE(it_read, AdapterType::read(r2, data, data.begin())); + auto it_read = EXPECT_OK(AdapterType::read(r2, data, data.begin())); ASSERT_EQ(it_read, data.end()); ASSERT_EQ(r2.max, request.max); diff --git a/test/core/network/types/protobuf_block_response_test.cpp b/test/core/network/types/protobuf_block_response_test.cpp index e067442ae2..a126fe3d75 100644 --- a/test/core/network/types/protobuf_block_response_test.cpp +++ b/test/core/network/types/protobuf_block_response_test.cpp @@ -6,8 +6,7 @@ #include "network/adapters/protobuf_block_response.hpp" #include - -#include "testutil/outcome.hpp" +#include using kagome::network::BlocksResponse; using kagome::network::ProtobufMessageAdapter; @@ -23,29 +22,25 @@ struct ProtobufBlockResponseAdapterTest : public ::testing::Test { using AdapterType = ProtobufMessageAdapter; void SetUp() { - EXPECT_OUTCOME_TRUE( - hash, - BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto hash = + EXPECT_OK(BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); - EXPECT_OUTCOME_TRUE( - parent_hash, - BlockHash::fromHex("22111403ba5b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto parent_hash = + EXPECT_OK(BlockHash::fromHex("22111403ba5b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); - EXPECT_OUTCOME_TRUE( - root_hash, - BlockHash::fromHex("23648236745b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto root_hash = + EXPECT_OK(BlockHash::fromHex("23648236745b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); - EXPECT_OUTCOME_TRUE( - ext_hash, - BlockHash::fromHex("2364823674278726578628756faad1a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto ext_hash = + EXPECT_OK(BlockHash::fromHex("2364823674278726578628756faad1a78244" + "c7d43b127ec35cd8325602dd47fd")); - EXPECT_OUTCOME_TRUE(ext, Buffer::fromHex("11223344")); - EXPECT_OUTCOME_TRUE(receipt, Buffer::fromHex("55ffddeeaa")); - EXPECT_OUTCOME_TRUE(message_queue, Buffer::fromHex("1a2b3c4d5e6f")); + auto ext = EXPECT_OK(Buffer::fromHex("11223344")); + auto receipt = EXPECT_OK(Buffer::fromHex("55ffddeeaa")); + auto message_queue = EXPECT_OK(Buffer::fromHex("1a2b3c4d5e6f")); response.blocks.emplace_back(BlockData{.hash = hash, .header = @@ -76,7 +71,7 @@ TEST_F(ProtobufBlockResponseAdapterTest, Serialization) { AdapterType::write(response, data, data.end()); BlocksResponse r2; - EXPECT_OUTCOME_TRUE(it_read, AdapterType::read(r2, data, data.begin())); + auto it_read = EXPECT_OK(AdapterType::read(r2, data, data.begin())); ASSERT_EQ(it_read, data.end()); for (size_t ix = 0; ix < response.blocks.size(); ++ix) { diff --git a/test/core/network/types/protobuf_state_request_test.cpp b/test/core/network/types/protobuf_state_request_test.cpp index 61314ca2fe..7eaf98dc64 100644 --- a/test/core/network/types/protobuf_state_request_test.cpp +++ b/test/core/network/types/protobuf_state_request_test.cpp @@ -6,8 +6,7 @@ #include "network/adapters/protobuf_state_request.hpp" #include - -#include "testutil/outcome.hpp" +#include using kagome::network::ProtobufMessageAdapter; using kagome::network::StateRequest; @@ -19,10 +18,9 @@ struct ProtobufStateRequestAdapterTest : public ::testing::Test { using AdapterType = ProtobufMessageAdapter; void SetUp() { - EXPECT_OUTCOME_TRUE( - hash_from, - BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" - "c7d43b127ec35cd8325602dd47fd")); + auto hash_from = + EXPECT_OK(BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244" + "c7d43b127ec35cd8325602dd47fd")); request.hash = hash_from; request.start = {Buffer::fromString("bua"), Buffer::fromString("b")}; request.no_proof = true; @@ -43,7 +41,7 @@ TEST_F(ProtobufStateRequestAdapterTest, Serialization) { AdapterType::write(request, data, data.end()); StateRequest r2; - EXPECT_OUTCOME_TRUE(it_read, AdapterType::read(r2, data, data.begin())); + auto it_read = EXPECT_OK(AdapterType::read(r2, data, data.begin())); ASSERT_EQ(it_read, data.end()); ASSERT_EQ(r2.hash, request.hash); diff --git a/test/core/network/types/protobuf_state_response_test.cpp b/test/core/network/types/protobuf_state_response_test.cpp index fb7890b013..eac93798b2 100644 --- a/test/core/network/types/protobuf_state_response_test.cpp +++ b/test/core/network/types/protobuf_state_response_test.cpp @@ -6,9 +6,9 @@ #include "network/adapters/protobuf_state_response.hpp" #include +#include #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::common::Buffer; using kagome::common::Hash256; @@ -42,7 +42,7 @@ TEST_F(ProtobufStateResponseAdapterTest, Serialization) { AdapterType::write(response, data, data.end()); StateResponse r2; - EXPECT_OUTCOME_TRUE(it_read, AdapterType::read(r2, data, data.begin())); + auto it_read = EXPECT_OK(AdapterType::read(r2, data, data.begin())); ASSERT_EQ(it_read, data.end()); } diff --git a/test/core/network/types/uvar_adapter_test.cpp b/test/core/network/types/uvar_adapter_test.cpp index 4e080db4fa..4df9c9bc8c 100644 --- a/test/core/network/types/uvar_adapter_test.cpp +++ b/test/core/network/types/uvar_adapter_test.cpp @@ -6,8 +6,7 @@ #include "network/adapters/uvar.hpp" #include - -#include "testutil/outcome.hpp" +#include using kagome::network::UVarMessageAdapter; @@ -30,7 +29,7 @@ TEST_F(UVarAdapterTest, ZeroDataTest) { ASSERT_EQ(data.size() - std::distance(data.begin(), it), 1); ASSERT_EQ(*it, 0); - EXPECT_OUTCOME_TRUE(it_read, UVarMessageAdapter::read(d, data, it)); + auto it_read = EXPECT_OK(UVarMessageAdapter::read(d, data, it)); ASSERT_EQ(it_read, data.end()); } @@ -49,7 +48,7 @@ TEST_F(UVarAdapterTest, DataSize_7f) { ASSERT_EQ(data.size() - std::distance(data.begin(), it), 0x80); ASSERT_EQ(*it, 0x7f); - EXPECT_OUTCOME_TRUE(it_read, UVarMessageAdapter::read(d, data, it)); + auto it_read = EXPECT_OK(UVarMessageAdapter::read(d, data, it)); ASSERT_EQ(it_read.base() - data.begin().base(), (uint64_t)UVarMessageAdapter::size(Dummy{})); } @@ -70,7 +69,7 @@ TEST_F(UVarAdapterTest, DataSize_1) { ASSERT_EQ(data.size() - std::distance(data.begin(), it), 2); ASSERT_EQ(*it, 0x1); - EXPECT_OUTCOME_TRUE(it_read, UVarMessageAdapter::read(d, data, it)); + auto it_read = EXPECT_OK(UVarMessageAdapter::read(d, data, it)); ASSERT_EQ(it_read.base() - data.begin().base(), (uint64_t)UVarMessageAdapter::size(Dummy{})); } @@ -92,7 +91,7 @@ TEST_F(UVarAdapterTest, DataSize_fd) { ASSERT_EQ(*it, 0xfd); ASSERT_EQ(*(it + 1), 0x1); - EXPECT_OUTCOME_TRUE(it_read, UVarMessageAdapter::read(d, data, it)); + auto it_read = EXPECT_OK(UVarMessageAdapter::read(d, data, it)); ASSERT_EQ(it_read.base() - data.begin().base(), (uint64_t)UVarMessageAdapter::size(Dummy{})); } diff --git a/test/core/parachain/prospective_parachains.cpp b/test/core/parachain/prospective_parachains.cpp index c6f8c7c298..07ee57badc 100644 --- a/test/core/parachain/prospective_parachains.cpp +++ b/test/core/parachain/prospective_parachains.cpp @@ -5,11 +5,12 @@ */ #include +#include #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" +#include #include "crypto/hasher/hasher_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" #include "crypto/sr25519/sr25519_provider_impl.hpp" @@ -24,7 +25,6 @@ #include "parachain/validator/signer.hpp" #include "runtime/runtime_api/parachain_host_types.hpp" #include "scale/kagome_scale.hpp" -#include "scale/scale.hpp" #include "testutil/scale_test_comparator.hpp" using namespace kagome::primitives; @@ -462,11 +462,10 @@ class ProspectiveParachainsTest : public testing::Test { } } - ASSERT_OUTCOME_SUCCESS_TRY( - prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{ - .new_head = {update.new_head}, - .lost = update.lost, - })); + EXPECT_OK(prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{ + .new_head = {update.new_head}, + .lost = update.lost, + })); auto resp = prospective_parachain_->answerMinimumRelayParentsRequest(hash); std::sort(resp.begin(), resp.end(), [](const auto &l, const auto &r) { return l.first < r.first; diff --git a/test/core/parachain/pvf_test.cpp b/test/core/parachain/pvf_test.cpp index 6230d553a0..027cc65d03 100644 --- a/test/core/parachain/pvf_test.cpp +++ b/test/core/parachain/pvf_test.cpp @@ -4,9 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include +#include -#include "gmock/gmock.h" #include "mock/core/runtime/memory_provider_mock.hpp" #include "mock/core/runtime/trie_storage_provider_mock.hpp" #include "parachain/pvf/pvf_impl.hpp" @@ -32,7 +33,6 @@ #include "runtime/executor.hpp" #include "runtime/instance_environment.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::TestThreadPool; @@ -155,7 +155,7 @@ class PvfTest : public testing::Test { scale::encode(Pvf::CandidateCommitments{}).value()); testing::MockFunction)> cb; EXPECT_CALL(cb, Call(_)).WillOnce([](outcome::result r) { - EXPECT_OUTCOME_TRUE_1(r); + EXPECT_OK(r); }); pvf_->pvfValidate(pvd, pov, receipt, code, cb.AsStdFunction()); io_->restart(); diff --git a/test/core/parachain/secure_mode.cpp b/test/core/parachain/secure_mode.cpp index d2b78beaf8..b004fcfb0a 100644 --- a/test/core/parachain/secure_mode.cpp +++ b/test/core/parachain/secure_mode.cpp @@ -15,8 +15,6 @@ #include "parachain/pvf/secure_mode.hpp" -#include "testutil/outcome.hpp" - using namespace kagome::parachain; template @@ -32,7 +30,7 @@ void test_syscall_works(int call, Ts... args) { template void test_syscall_fails(int call, Ts... args) { EXPECT_EXIT(([=]() { - EXPECT_OUTCOME_TRUE_1(enableSeccomp()); + EXPECT_OK(enableSeccomp()); std::ignore = ::syscall(call, args...); std::exit(0); }()), @@ -67,7 +65,7 @@ TEST(SecureMode, ChangeRootWorks) { auto dir = std::filesystem::temp_directory_path() / "kagome_secure_mode_test/chroot"; std::filesystem::create_directories(dir); - ASSERT_OUTCOME_SUCCESS_TRY(changeRoot(dir)); + EXPECT_OK(changeRoot(dir)); ASSERT_EQ(std::filesystem::current_path(), "/"); ASSERT_EQ( std::distance(std::filesystem::directory_iterator{"/"}, @@ -127,6 +125,6 @@ TEST(SecureMode, DISABLED_LandlockWorks) { std::filesystem::create_directories(dir); std::filesystem::current_path(dir); accessFs(dir, true); - ASSERT_OUTCOME_SUCCESS_TRY(enableLandlock(dir)); + EXPECT_OK(enableLandlock(dir)); accessFs(dir, false); } diff --git a/test/core/primitives/primitives_codec_test.cpp b/test/core/primitives/primitives_codec_test.cpp index d68740f01c..4acfe0fb1d 100644 --- a/test/core/primitives/primitives_codec_test.cpp +++ b/test/core/primitives/primitives_codec_test.cpp @@ -5,6 +5,8 @@ */ #include +#include +#include #include "common/blob.hpp" #include "primitives/block.hpp" @@ -14,8 +16,6 @@ #include "primitives/inherent_data.hpp" #include "primitives/transaction_validity.hpp" #include "primitives/version.hpp" -#include "scale/scale.hpp" -#include "testutil/outcome.hpp" #include "testutil/primitives/mp_utils.hpp" using kagome::common::Blob; @@ -100,8 +100,8 @@ class Primitives : public testing::Test { * @then decoded block is equal to predefined block */ TEST_F(Primitives, EncodeBlockHeaderSuccess) { - EXPECT_OUTCOME_TRUE(val, encode(block_header_)); - EXPECT_OUTCOME_TRUE(decoded_header, decode(val)); + auto val = EXPECT_OK(encode(block_header_)); + auto decoded_header = EXPECT_OK(decode(val)); ASSERT_EQ(block_header_, decoded_header); } @@ -111,8 +111,8 @@ TEST_F(Primitives, EncodeBlockHeaderSuccess) { * @then the same expected buffer obtained {12, 1, 2, 3} */ TEST_F(Primitives, EncodeExtrinsicSuccess) { - EXPECT_OUTCOME_TRUE(val, encode(extrinsic_)); - EXPECT_OUTCOME_TRUE(decoded_extrinsic, decode(val)); + auto val = EXPECT_OK(encode(extrinsic_)); + auto decoded_extrinsic = EXPECT_OK(decode(val)); ASSERT_EQ(extrinsic_, decoded_extrinsic); } @@ -122,8 +122,8 @@ TEST_F(Primitives, EncodeExtrinsicSuccess) { * @then expected result obtained */ TEST_F(Primitives, EncodeBlockSuccess) { - EXPECT_OUTCOME_TRUE(res, encode(block_)); - EXPECT_OUTCOME_TRUE(decoded_block, decode(res)); + auto res = EXPECT_OK(encode(block_)); + auto decoded_block = EXPECT_OK(decode(res)); ASSERT_EQ(block_, decoded_block); } @@ -135,8 +135,8 @@ TEST_F(Primitives, EncodeBlockSuccess) { * @then obtained result equal to predefined match */ TEST_F(Primitives, EncodeVersionSuccess) { - EXPECT_OUTCOME_TRUE(val, encode(version_)); - EXPECT_OUTCOME_TRUE(decoded_version, decode(val)); + auto val = EXPECT_OK(encode(version_)); + auto decoded_version = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_version, version_); } @@ -148,8 +148,8 @@ TEST_F(Primitives, EncodeVersionSuccess) { * @then obtained result matches predefined value */ TEST_F(Primitives, EncodeBlockIdHash256Success) { - EXPECT_OUTCOME_TRUE(val, encode(block_id_hash_)) - EXPECT_OUTCOME_TRUE(decoded_block_id, decode(val)); + auto val = EXPECT_OK(encode(block_id_hash_)); + auto decoded_block_id = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_block_id, block_id_hash_); } @@ -159,8 +159,8 @@ TEST_F(Primitives, EncodeBlockIdHash256Success) { * @then obtained result matches predefined value */ TEST_F(Primitives, EncodeBlockIdBlockNumberSuccess) { - EXPECT_OUTCOME_TRUE(val, encode(block_id_number_)) - EXPECT_OUTCOME_TRUE(decoded_block_id, decode(val)); + auto val = EXPECT_OK(encode(block_id_number_)); + auto decoded_block_id = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_block_id, block_id_number_); } @@ -173,8 +173,8 @@ TEST_F(Primitives, EncodeBlockIdBlockNumberSuccess) { */ TEST_F(Primitives, EncodeTransactionValidityInvalidSuccess) { InvalidTransaction invalid{InvalidTransaction::Call}; - EXPECT_OUTCOME_TRUE(val, encode(invalid)) - EXPECT_OUTCOME_TRUE(decoded_validity, decode(val)); + auto val = EXPECT_OK(encode(invalid)); + auto decoded_validity = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_validity, invalid); } @@ -185,8 +185,8 @@ TEST_F(Primitives, EncodeTransactionValidityInvalidSuccess) { */ TEST_F(Primitives, EncodeTransactionValidityUnknown) { UnknownTransaction unknown{UnknownTransaction::Kind::Custom, 42}; - EXPECT_OUTCOME_TRUE(val, encode(unknown)) - EXPECT_OUTCOME_TRUE(decoded_validity, decode(val)); + auto val = EXPECT_OK(encode(unknown)); + auto decoded_validity = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_validity, unknown); } @@ -197,8 +197,8 @@ TEST_F(Primitives, EncodeTransactionValidityUnknown) { */ TEST_F(Primitives, EncodeTransactionValiditySuccess) { ValidTransaction t = valid_transaction_; // make it variant type - EXPECT_OUTCOME_TRUE(val, encode(t)) - EXPECT_OUTCOME_TRUE(decoded_validity, decode(val)); + auto val = EXPECT_OK(encode(t)); + auto decoded_validity = EXPECT_OK(decode(val)); ASSERT_EQ(decoded_validity, valid_transaction_); } @@ -212,9 +212,9 @@ TEST_F(Primitives, EncodeDecodeAuthorityIdsSuccess) { id1.fill(1u); id2.fill(2u); std::vector original{id1, id2}; - EXPECT_OUTCOME_TRUE(res, encode(original)) + auto res = EXPECT_OK(encode(original)); - EXPECT_OUTCOME_TRUE(decoded, decode>(res)) + auto decoded = EXPECT_OK(decode>(res)); ASSERT_EQ(original, decoded); } @@ -225,19 +225,19 @@ TEST_F(Primitives, EncodeInherentSampleFromSubstrate) { 'e', 's', 't', 'i', 'n', 'h', '1', '\x10', '\a', '\0', '\0', '\0'}; - EXPECT_OUTCOME_TRUE(test_id1, InherentIdentifier::fromString("testinh0")); + auto test_id1 = EXPECT_OK(InherentIdentifier::fromString("testinh0")); std::vector data1{1, 2, 3}; - EXPECT_OUTCOME_TRUE(test_id2, InherentIdentifier::fromString("testinh1")); + auto test_id2 = EXPECT_OK(InherentIdentifier::fromString("testinh1")); uint32_t data2 = 7; auto encoded_buf = Buffer().put(encoded_str); - EXPECT_OUTCOME_TRUE(dec_data, decode(encoded_buf)); + auto dec_data = EXPECT_OK(decode(encoded_buf)); - EXPECT_OUTCOME_TRUE(dec_data1, dec_data.getData(test_id1)); + auto dec_data1 = EXPECT_OK(dec_data.getData(test_id1)); EXPECT_EQ(data1, dec_data1); - EXPECT_OUTCOME_TRUE(dec_data2, dec_data.getData(test_id2)); + auto dec_data2 = EXPECT_OK(dec_data.getData(test_id2)); EXPECT_EQ(data2, dec_data2); } @@ -249,16 +249,16 @@ TEST_F(Primitives, EncodeInherentSampleFromSubstrate) { TEST_F(Primitives, EncodeInherentDataSuccess) { using array = std::array; InherentData data; - EXPECT_OUTCOME_TRUE(id1, InherentIdentifier::fromString("testinh0")); - EXPECT_OUTCOME_TRUE(id2, InherentIdentifier::fromString("testinh1")); + auto id1 = EXPECT_OK(InherentIdentifier::fromString("testinh0")); + auto id2 = EXPECT_OK(InherentIdentifier::fromString("testinh1")); InherentIdentifier id3{array{3}}; std::vector data1{1, 2, 3}; uint32_t data2 = 7; Buffer data3{1, 2, 3, 4}; - EXPECT_OUTCOME_TRUE_void(r1, data.putData(id1, data1)); - EXPECT_OUTCOME_TRUE_void(r2, data.putData(id2, data2)); - EXPECT_OUTCOME_TRUE_void(r3, data.putData(id3, data3)); - EXPECT_OUTCOME_FALSE_void(_, data.putData(id1, data2)); + EXPECT_OK(data.putData(id1, data1)); + EXPECT_OK(data.putData(id2, data2)); + EXPECT_OK(data.putData(id3, data3)); + EXPECT_HAS_ERROR(data.putData(id1, data2)); ASSERT_EQ(data.getData(id1).value(), data1); ASSERT_EQ(data.getData(id2).value(), data2); @@ -268,8 +268,8 @@ TEST_F(Primitives, EncodeInherentDataSuccess) { data.replaceData(id3, data4); ASSERT_EQ(data.getData(id3).value(), data4); - EXPECT_OUTCOME_TRUE(enc_data, encode(data)) - EXPECT_OUTCOME_TRUE(dec_data, decode(enc_data)) + auto enc_data = EXPECT_OK(encode(data)); + auto dec_data = EXPECT_OK(decode(enc_data)); ASSERT_EQ(dec_data.getData(id1).value(), data1); diff --git a/test/core/primitives/ss58_codec_test.cpp b/test/core/primitives/ss58_codec_test.cpp index 6eda9a879b..897a97131b 100644 --- a/test/core/primitives/ss58_codec_test.cpp +++ b/test/core/primitives/ss58_codec_test.cpp @@ -5,10 +5,10 @@ */ #include +#include #include "crypto/hasher/hasher_impl.hpp" #include "primitives/ss58_codec.hpp" -#include "testutil/outcome.hpp" using kagome::crypto::HasherImpl; @@ -23,7 +23,6 @@ class Ss58Codec : public testing::Test { }; TEST_F(Ss58Codec, EncodeSs58) { - EXPECT_OUTCOME_SUCCESS( - decoded, + EXPECT_OK( decodeSs58("cnRbTBxzRs4zmzJiqWkuBLMGCkkcq3FidZMvsj7kPgCfvGSsY", hasher_)); } diff --git a/test/core/runtime/binaryen/block_builder_api_test.cpp b/test/core/runtime/binaryen/block_builder_api_test.cpp index c3ab1d339c..f6c73bfbfd 100644 --- a/test/core/runtime/binaryen/block_builder_api_test.cpp +++ b/test/core/runtime/binaryen/block_builder_api_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include "core/runtime/binaryen/binaryen_runtime_test.hpp" #include "host_api/impl/host_api_impl.hpp" @@ -12,7 +13,6 @@ #include "runtime/binaryen/memory_impl.hpp" #include "runtime/common/trie_storage_provider_impl.hpp" #include "runtime/runtime_api/impl/block_builder.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::common::Buffer; @@ -52,8 +52,8 @@ class BlockBuilderApiTest : public BinaryenRuntimeTest { TEST_F(BlockBuilderApiTest, CheckInherents) { prepareEphemeralStorageExpects(); SCOPED_TRACE("CheckInherents"); - EXPECT_OUTCOME_TRUE_1(builder_->check_inherents( - createBlock("block_42"_hash256, 42), InherentData{})) + EXPECT_OK(builder_->check_inherents(createBlock("block_42"_hash256, 42), + InherentData{})); } /** @@ -68,8 +68,7 @@ TEST_F(BlockBuilderApiTest, ApplyExtrinsic) { createBlock("block_hash_43"_hash256, 43); auto ctx = ctx_factory_->persistentAt("block_hash_43"_hash256, std::nullopt).value(); - EXPECT_OUTCOME_FALSE_1( - builder_->apply_extrinsic(ctx, Extrinsic{Buffer{1, 2, 3}})); + EXPECT_HAS_ERROR(builder_->apply_extrinsic(ctx, Extrinsic{Buffer{1, 2, 3}})); } /** @@ -78,8 +77,9 @@ TEST_F(BlockBuilderApiTest, ApplyExtrinsic) { * @then the result of the check is obtained given that the provided arguments * were valid */ -TEST_F(BlockBuilderApiTest, DISABLED_RandomSeed){ - EXPECT_OUTCOME_FALSE_1(builder_->random_seed("block_hash"_hash256))} +TEST_F(BlockBuilderApiTest, DISABLED_RandomSeed) { + EXPECT_HAS_ERROR(builder_->random_seed("block_hash"_hash256)); +} /** * @given block builder @@ -93,7 +93,7 @@ TEST_F(BlockBuilderApiTest, InherentExtrinsics) { createBlock("block_hash_44"_hash256, 44); auto ctx = ctx_factory_->persistentAt("block_hash_44"_hash256, std::nullopt).value(); - EXPECT_OUTCOME_FALSE_1(builder_->inherent_extrinsics(ctx, InherentData{})); + EXPECT_HAS_ERROR(builder_->inherent_extrinsics(ctx, InherentData{})); } /** @@ -107,5 +107,5 @@ TEST_F(BlockBuilderApiTest, DISABLED_FinalizeBlock) { createBlock("block_hash"_hash256, 42); auto ctx = ctx_factory_->persistentAt("block_hash"_hash256, std::nullopt).value(); - EXPECT_OUTCOME_FALSE_1(builder_->finalize_block(ctx)); + EXPECT_HAS_ERROR(builder_->finalize_block(ctx)); } diff --git a/test/core/runtime/binaryen/metadata_test.cpp b/test/core/runtime/binaryen/metadata_test.cpp index df3a09d588..32a4096440 100644 --- a/test/core/runtime/binaryen/metadata_test.cpp +++ b/test/core/runtime/binaryen/metadata_test.cpp @@ -13,7 +13,6 @@ #include "mock/core/runtime/runtime_upgrade_tracker_mock.hpp" #include "runtime/binaryen/memory_impl.hpp" #include "runtime/runtime_api/impl/metadata.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using ::testing::_; diff --git a/test/core/runtime/binaryen/parachain_test.cpp b/test/core/runtime/binaryen/parachain_test.cpp index 7bf5b8af81..dfa3a66286 100644 --- a/test/core/runtime/binaryen/parachain_test.cpp +++ b/test/core/runtime/binaryen/parachain_test.cpp @@ -11,7 +11,6 @@ #include "core/runtime/binaryen/binaryen_runtime_test.hpp" #include "host_api/impl/host_api_impl.hpp" #include "runtime/binaryen/memory_impl.hpp" -#include "testutil/outcome.hpp" using kagome::common::Buffer; using kagome::host_api::HostApiImpl; diff --git a/test/core/runtime/binaryen/tagged_transaction_queue_test.cpp b/test/core/runtime/binaryen/tagged_transaction_queue_test.cpp index 7e5c45a2ae..2a9c495db8 100644 --- a/test/core/runtime/binaryen/tagged_transaction_queue_test.cpp +++ b/test/core/runtime/binaryen/tagged_transaction_queue_test.cpp @@ -7,11 +7,11 @@ #include "runtime/runtime_api/impl/tagged_transaction_queue.hpp" #include +#include #include "core/runtime/binaryen/binaryen_runtime_test.hpp" #include "mock/core/blockchain/block_tree_mock.hpp" #include "testutil/lazy.hpp" -#include "testutil/outcome.hpp" #include "testutil/runtime/common/basic_code_provider.hpp" using namespace testing; @@ -51,6 +51,5 @@ TEST_F(TTQTest, DISABLED_ValidateTransactionSuccess) { // we test now that the functions above are called sequentially // unfortunately, we don't have valid data for validate_transaction to succeed - EXPECT_OUTCOME_TRUE_1( - ttq_->validate_transaction(TransactionSource::External, ext)); + EXPECT_OK(ttq_->validate_transaction(TransactionSource::External, ext)); } diff --git a/test/core/runtime/executor_test.cpp b/test/core/runtime/executor_test.cpp index 4e74f3fd6e..d5c01de697 100644 --- a/test/core/runtime/executor_test.cpp +++ b/test/core/runtime/executor_test.cpp @@ -7,6 +7,8 @@ #include "runtime/executor.hpp" #include +#include + #include "filesystem/common.hpp" #include "mock/core/blockchain/block_header_repository_mock.hpp" @@ -20,7 +22,6 @@ #include "mock/core/storage/trie/trie_batches_mock.hpp" #include "mock/core/storage/trie/trie_storage_mock.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "testutil/runtime/common/basic_code_provider.hpp" #include "testutil/runtime/memory.hpp" @@ -154,60 +155,36 @@ TEST_F(ExecutorTest, LatestStateSwitchesCorrectly) { kagome::primitives::BlockInfo block_info3{44, "block_hash3"_hash256}; Buffer enc_args{scale::encode(2, 3).value()}; - EXPECT_OUTCOME_TRUE(ctx1, - prepareCall(block_info1, - "state_hash1"_hash256, - CallType::Persistent, - enc_args, - 5)); + auto ctx1 = EXPECT_OK(prepareCall( + block_info1, "state_hash1"_hash256, CallType::Persistent, enc_args, 5)); auto res = executor.call(ctx1, "addTwo", 2, 3).value(); EXPECT_EQ(res, 5); enc_args = scale::encode(7, 10).value(); - EXPECT_OUTCOME_TRUE(ctx2, - prepareCall(block_info1, - "state_hash2"_hash256, - CallType::Ephemeral, - enc_args, - 17)); - EXPECT_OUTCOME_TRUE(res2, executor.call(ctx2, "addTwo", 7, 10)); + auto ctx2 = EXPECT_OK(prepareCall( + block_info1, "state_hash2"_hash256, CallType::Ephemeral, enc_args, 17)); + auto res2 = EXPECT_OK(executor.call(ctx2, "addTwo", 7, 10)); ASSERT_EQ(res2, 17); enc_args = scale::encode(0, 0).value(); - EXPECT_OUTCOME_TRUE(ctx3, - prepareCall(block_info1, - "state_hash2"_hash256, - CallType::Persistent, - enc_args, - 0)); + auto ctx3 = EXPECT_OK(prepareCall( + block_info1, "state_hash2"_hash256, CallType::Persistent, enc_args, 0)); EXPECT_EQ(executor.call(ctx3, "addTwo", 0, 0).value(), 0); enc_args = scale::encode(7, 10).value(); - EXPECT_OUTCOME_TRUE(ctx4, - prepareCall(block_info1, - "state_hash3"_hash256, - CallType::Ephemeral, - enc_args, - 17)); - EXPECT_OUTCOME_TRUE(res4, executor.call(ctx4, "addTwo", 7, 10)); + auto ctx4 = EXPECT_OK(prepareCall( + block_info1, "state_hash3"_hash256, CallType::Ephemeral, enc_args, 17)); + auto res4 = EXPECT_OK(executor.call(ctx4, "addTwo", 7, 10)); ASSERT_EQ(res4, 17); enc_args = scale::encode(-5, 5).value(); - EXPECT_OUTCOME_TRUE(ctx5, - prepareCall(block_info2, - "state_hash4"_hash256, - CallType::Persistent, - enc_args, - 0)); + auto ctx5 = EXPECT_OK(prepareCall( + block_info2, "state_hash4"_hash256, CallType::Persistent, enc_args, 0)); EXPECT_EQ(executor.call(ctx5, "addTwo", -5, 5).value(), 0); enc_args = scale::encode(7, 10).value(); - EXPECT_OUTCOME_TRUE(ctx6, - prepareCall(block_info2, - "state_hash5"_hash256, - CallType::Ephemeral, - enc_args, - 17)); - EXPECT_OUTCOME_TRUE(res6, executor.call(ctx6, "addTwo", 7, 10)); + auto ctx6 = EXPECT_OK(prepareCall( + block_info2, "state_hash5"_hash256, CallType::Ephemeral, enc_args, 17)); + auto res6 = EXPECT_OK(executor.call(ctx6, "addTwo", 7, 10)); ASSERT_EQ(res6, 17); } diff --git a/test/core/runtime/instance_pool_test.cpp b/test/core/runtime/instance_pool_test.cpp index 470c746ac4..c1f68e7287 100644 --- a/test/core/runtime/instance_pool_test.cpp +++ b/test/core/runtime/instance_pool_test.cpp @@ -4,13 +4,13 @@ */ #include +#include #include #include #include #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" #include "runtime/common/runtime_instances_pool.hpp" @@ -82,7 +82,7 @@ TEST(InstancePoolTest, HeavilyMultithreadedCompilation) { std::vector threads; for (int i = 0; i < THREAD_NUM; i++) { threads.emplace_back([&pool, &code, i]() { - ASSERT_OUTCOME_SUCCESS_TRY(pool->instantiateFromCode( + EXPECT_OK(pool->instantiateFromCode( make_code_hash(i % POOL_SIZE), [&] { return code; }, {})); }); } @@ -95,7 +95,7 @@ TEST(InstancePoolTest, HeavilyMultithreadedCompilation) { // check that all POOL_SIZE instances are in cache for (int i = 0; i < POOL_SIZE; i++) { - ASSERT_OUTCOME_SUCCESS_TRY(pool->instantiateFromCode( + EXPECT_OK(pool->instantiateFromCode( make_code_hash(i), []() -> decltype(code) { throw std::logic_error{"already compiled"}; }, {})); diff --git a/test/core/runtime/runtime_test_base.hpp b/test/core/runtime/runtime_test_base.hpp index a2429c6221..4684bb7dae 100644 --- a/test/core/runtime/runtime_test_base.hpp +++ b/test/core/runtime/runtime_test_base.hpp @@ -51,7 +51,6 @@ #include "runtime/wabt/instrument.hpp" #include "storage/in_memory/in_memory_storage.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/runtime/common/basic_code_provider.hpp" using kagome::application::AppConfigurationMock; diff --git a/test/core/runtime/runtime_upgrade_tracker_test.cpp b/test/core/runtime/runtime_upgrade_tracker_test.cpp index 0800720d20..eed0436f39 100644 --- a/test/core/runtime/runtime_upgrade_tracker_test.cpp +++ b/test/core/runtime/runtime_upgrade_tracker_test.cpp @@ -7,6 +7,7 @@ #include "runtime/common/runtime_upgrade_tracker_impl.hpp" #include +#include #include "mock/core/blockchain/block_header_repository_mock.hpp" #include "mock/core/blockchain/block_storage_mock.hpp" @@ -14,7 +15,6 @@ #include "mock/core/storage/spaced_storage_mock.hpp" #include "storage/in_memory/in_memory_storage.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::common::Hash256; @@ -115,7 +115,7 @@ class RuntimeUpgradeTrackerTest : public testing::Test { TEST_F(RuntimeUpgradeTrackerTest, NullBlockTree) { EXPECT_CALL(*header_repo_, getBlockHeader({block_42.hash})) .WillOnce(testing::Return(block_42_header)); - EXPECT_OUTCOME_TRUE(state, tracker_->getLastCodeUpdateState(block_42)); + auto state = EXPECT_OK(tracker_->getLastCodeUpdateState(block_42)); ASSERT_EQ(state, block_42_header.state_root); } @@ -130,7 +130,7 @@ TEST_F(RuntimeUpgradeTrackerTest, EmptyUpdatesCache) { EXPECT_CALL(*header_repo_, getBlockHeader(block_42.hash)) .WillOnce(testing::Return(block_42_header)); - EXPECT_OUTCOME_TRUE(state, tracker_->getLastCodeUpdateState(block_42)); + auto state = EXPECT_OK(tracker_->getLastCodeUpdateState(block_42)); ASSERT_EQ(state, block_42_header.state_root); } @@ -144,12 +144,12 @@ TEST_F(RuntimeUpgradeTrackerTest, AutoUpgradeAfterEmpty) { EXPECT_CALL(*header_repo_, getBlockHeader(block_2.hash)) .WillRepeatedly(testing::Return(block_2_header)); - EXPECT_OUTCOME_TRUE(state, tracker_->getLastCodeUpdateState(block_2)); + auto state = EXPECT_OK(tracker_->getLastCodeUpdateState(block_2)); ASSERT_EQ(state, block_2_header.state_root); EXPECT_CALL(*block_tree_, getLastFinalized()) .WillRepeatedly(testing::Return(block_42)); - EXPECT_OUTCOME_TRUE(state42, tracker_->getLastCodeUpdateState(block_42)); + auto state42 = EXPECT_OK(tracker_->getLastCodeUpdateState(block_42)); // picking 2 instead of 42 because that's the latest known upgrade ASSERT_EQ(state42, block_2_header.state_root); } @@ -163,7 +163,7 @@ TEST_F(RuntimeUpgradeTrackerTest, CorrectUpgradeScenario) { EXPECT_CALL(*header_repo_, getBlockHeader(genesis_block.hash)) .WillRepeatedly(testing::Return(genesis_block_header)); - EXPECT_OUTCOME_TRUE(state1, tracker_->getLastCodeUpdateState(genesis_block)); + auto state1 = EXPECT_OK(tracker_->getLastCodeUpdateState(genesis_block)); ASSERT_EQ(state1, genesis_block_header.state_root); // then we upgrade in block #42 @@ -174,7 +174,7 @@ TEST_F(RuntimeUpgradeTrackerTest, CorrectUpgradeScenario) { EXPECT_CALL(*header_repo_, getBlockHeader(block_42.hash)) .WillRepeatedly(testing::Return(block_42_header)); - EXPECT_OUTCOME_TRUE(state42, tracker_->getLastCodeUpdateState(block_41)); + auto state42 = EXPECT_OK(tracker_->getLastCodeUpdateState(block_41)); ASSERT_EQ(state42, genesis_block_header.state_root); // during execution of 42 we upgrade the code sub_engine_->notify( @@ -190,11 +190,11 @@ TEST_F(RuntimeUpgradeTrackerTest, CorrectUpgradeScenario) { EXPECT_CALL(*header_repo_, getBlockHeader(block_42.hash)) .WillRepeatedly(testing::Return(block_42_header)); - EXPECT_OUTCOME_TRUE(state43, tracker_->getLastCodeUpdateState(block_42)); + auto state43 = EXPECT_OK(tracker_->getLastCodeUpdateState(block_42)); ASSERT_EQ(state43, block_42_header.state_root); // then block #44 - EXPECT_OUTCOME_TRUE(state44, tracker_->getLastCodeUpdateState(block_43)); + auto state44 = EXPECT_OK(tracker_->getLastCodeUpdateState(block_43)); ASSERT_EQ(state44, block_42_header.state_root); } @@ -231,7 +231,7 @@ TEST_F(RuntimeUpgradeTrackerTest, CodeSubstituteAndStore) { .value(); tracker_->subscribeToBlockchainEvents(sub_engine_, block_tree_); - EXPECT_OUTCOME_TRUE(state2, tracker_->getLastCodeUpdateState(block2)); + auto state2 = EXPECT_OK(tracker_->getLastCodeUpdateState(block2)); ASSERT_EQ(state2, block2_header.state_root); // reset tracker @@ -242,7 +242,7 @@ TEST_F(RuntimeUpgradeTrackerTest, CodeSubstituteAndStore) { tracker_->subscribeToBlockchainEvents(sub_engine_, block_tree_); auto block3 = makeBlockInfo(5203204); - EXPECT_OUTCOME_TRUE(state3, tracker_->getLastCodeUpdateState(block3)); + auto state3 = EXPECT_OK(tracker_->getLastCodeUpdateState(block3)); ASSERT_EQ(state3, block2_header.state_root); } @@ -265,7 +265,7 @@ TEST_F(RuntimeUpgradeTrackerTest, UpgradeAfterCodeSubstitute) { EXPECT_CALL(*header_repo_, getBlockHeader(block1.hash)) .WillOnce(testing::Return(block1_header)); - EXPECT_OUTCOME_TRUE_1(tracker_->getLastCodeUpdateState(block1)); + EXPECT_OK(tracker_->getLastCodeUpdateState(block1)); // @see https://polkadot.subscan.io/event?module=system&event=codeupdated auto block2 = makeBlockInfo(5661442); @@ -276,11 +276,11 @@ TEST_F(RuntimeUpgradeTrackerTest, UpgradeAfterCodeSubstitute) { kagome::primitives::events::ChainEventType::kNewRuntime, kagome::primitives::events::NewRuntimeEventParams{block2.hash}); - EXPECT_OUTCOME_TRUE(state2, tracker_->getLastCodeUpdateState(block2)); + auto state2 = EXPECT_OK(tracker_->getLastCodeUpdateState(block2)); ASSERT_EQ(state2, block2_header.state_root); auto block3 = makeBlockInfo(5661443); - EXPECT_OUTCOME_TRUE(state3, tracker_->getLastCodeUpdateState(block3)); + auto state3 = EXPECT_OK(tracker_->getLastCodeUpdateState(block3)); ASSERT_EQ(state3, block2_header.state_root); } @@ -310,8 +310,7 @@ TEST_F(RuntimeUpgradeTrackerTest, OrphanBlock) { EXPECT_CALL(*block_tree_, hasDirectChain(block_34f2.hash, block_35f1.hash)) .WillOnce(testing::Return(false)); - EXPECT_OUTCOME_TRUE(state_for_35f1, - tracker_->getLastCodeUpdateState(block_35f1)); + auto state_for_35f1 = EXPECT_OK(tracker_->getLastCodeUpdateState(block_35f1)); // we have no information on upgrades, related to this block, so we fall back // to returning its state root @@ -328,8 +327,8 @@ TEST_F(RuntimeUpgradeTrackerTest, OrphanBlock) { .WillOnce(testing::Return(false)); EXPECT_CALL(*block_tree_, hasDirectChain(block_33f1.hash, block_35f1.hash)) .WillOnce(testing::Return(true)); - EXPECT_OUTCOME_TRUE(state_for_35f1_again, - tracker_->getLastCodeUpdateState(block_35f1)); + auto state_for_35f1_again = + EXPECT_OK(tracker_->getLastCodeUpdateState(block_35f1)); // now we pick the runtime upgrade ASSERT_EQ(state_for_35f1_again, block_33f1_header.state_root); diff --git a/test/core/runtime/stack_limiter_test.cpp b/test/core/runtime/stack_limiter_test.cpp index c94407bd6e..ff9ca57374 100644 --- a/test/core/runtime/stack_limiter_test.cpp +++ b/test/core/runtime/stack_limiter_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -20,7 +21,6 @@ #include "runtime/wabt/instrument.hpp" #include "runtime/wabt/stack_limiter.hpp" #include "runtime/wabt/util.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" static constexpr uint32_t ACTIVATION_FRAME_COST = 2; @@ -86,11 +86,10 @@ void expectWasm(const wabt::Module &actual, std::string_view expected) { uint32_t compute_cost(std::string_view data) { auto module = fromWat(data); - EXPECT_OUTCOME_TRUE(cost, - kagome::runtime::detail::compute_stack_cost( - kagome::log::createLogger("StackLimiterTest"), - *module->funcs[0], - *module)); + auto cost = EXPECT_OK(kagome::runtime::detail::compute_stack_cost( + kagome::log::createLogger("StackLimiterTest"), + *module->funcs[0], + *module)); return cost; } @@ -226,8 +225,7 @@ TEST_P(StackLimiterCompareTest, output_matches_expected) { auto fixture_wasm = wat_to_wasm(fixture_wat); auto expected_module = wat_to_module(expected_wat); - EXPECT_OUTCOME_TRUE( - result_wasm, + auto result_wasm = EXPECT_OK( kagome::runtime::instrumentWithStackLimiter(fixture_wasm, 1024)); wabt::Module result_module; diff --git a/test/core/runtime/storage_code_provider_test.cpp b/test/core/runtime/storage_code_provider_test.cpp index e5dd1bbd59..63a2a9815e 100644 --- a/test/core/runtime/storage_code_provider_test.cpp +++ b/test/core/runtime/storage_code_provider_test.cpp @@ -7,6 +7,7 @@ #include "runtime/common/storage_code_provider.hpp" #include +#include #include "mock/core/application/chain_spec_mock.hpp" #include "mock/core/runtime/runtime_upgrade_tracker_mock.hpp" @@ -15,7 +16,6 @@ #include "primitives/common.hpp" #include "storage/predefined_keys.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using namespace kagome; // NOLINT @@ -69,8 +69,8 @@ TEST_F(StorageCodeProviderTest, GetCodeWhenNoStorageUpdates) { std::make_shared()); // when - EXPECT_OUTCOME_TRUE(obtained_state_code, - wasm_provider->getCodeAt(first_state_root)); + auto obtained_state_code = + EXPECT_OK(wasm_provider->getCodeAt(first_state_root)); // then EXPECT_EQ(*obtained_state_code, state_code_); @@ -111,8 +111,8 @@ TEST_F(StorageCodeProviderTest, GetCodeWhenStorageUpdates) { })); // when - EXPECT_OUTCOME_TRUE(obtained_state_code, - wasm_provider->getCodeAt(second_state_root)); + auto obtained_state_code = + EXPECT_OK(wasm_provider->getCodeAt(second_state_root)); // then ASSERT_EQ(*obtained_state_code, new_state_code); diff --git a/test/core/runtime/trie_storage_provider_test.cpp b/test/core/runtime/trie_storage_provider_test.cpp index 20429dfa56..3e7e96a8fa 100644 --- a/test/core/runtime/trie_storage_provider_test.cpp +++ b/test/core/runtime/trie_storage_provider_test.cpp @@ -5,6 +5,7 @@ */ #include +#include #include "runtime/common/trie_storage_provider_impl.hpp" @@ -18,7 +19,6 @@ #include "storage/trie/serialization/polkadot_codec.hpp" #include "storage/trie/serialization/trie_serializer_impl.hpp" #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" #include "testutil/prepare_loggers.hpp" using kagome::common::Buffer; @@ -57,7 +57,7 @@ class TrieStorageProviderTest : public ::testing::Test { std::make_shared( std::move(trieDb), serializer); - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->setToPersistentAt( + EXPECT_OK(storage_provider_->setToPersistentAt( serializer->getEmptyRootHash(), std::nullopt)); } @@ -67,15 +67,15 @@ class TrieStorageProviderTest : public ::testing::Test { }; TEST_F(TrieStorageProviderTest, StartTransaction) { - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); + EXPECT_OK(storage_provider_->startTransaction()); } TEST_F(TrieStorageProviderTest, FinishTransactionWithoutStart) { - ASSERT_OUTCOME_ERROR(storage_provider_->rollbackTransaction(), - RuntimeExecutionError::NO_TRANSACTIONS_WERE_STARTED); + EXPECT_EC(storage_provider_->rollbackTransaction(), + RuntimeExecutionError::NO_TRANSACTIONS_WERE_STARTED); - ASSERT_OUTCOME_ERROR(storage_provider_->commitTransaction(), - RuntimeExecutionError::NO_TRANSACTIONS_WERE_STARTED); + EXPECT_EC(storage_provider_->commitTransaction(), + RuntimeExecutionError::NO_TRANSACTIONS_WERE_STARTED); } // Concatenate values gotten by keys: A, B, C, D, E @@ -84,8 +84,8 @@ auto checkBatchValues(const kagome::storage::trie::TrieBatch &batch, std::string_view expected_view) { std::string actual_view; for (std::string_view key : {"A", "B", "C", "D", "E"}) { - ASSERT_OUTCOME_SUCCESS( - val, batch.get(Buffer(std::vector(key.begin(), key.end())))); + auto val = EXPECT_OK( + batch.get(Buffer(std::vector(key.begin(), key.end())))); actual_view += val.mut().asString(); } EXPECT_EQ(actual_view, expected_view); @@ -94,16 +94,16 @@ auto checkBatchValues(const kagome::storage::trie::TrieBatch &batch, TEST_F(TrieStorageProviderTest, NestedTransactions) { /// @given batch with cells A, B, C, D, E with value '-' (means is unchanged) auto batch0 = storage_provider_->getCurrentBatch(); - ASSERT_OUTCOME_SUCCESS_TRY(batch0->put("A"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(batch0->put("B"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(batch0->put("C"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(batch0->put("D"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(batch0->put("E"_buf, "-"_buf)); + EXPECT_OK(batch0->put("A"_buf, "-"_buf)); + EXPECT_OK(batch0->put("B"_buf, "-"_buf)); + EXPECT_OK(batch0->put("C"_buf, "-"_buf)); + EXPECT_OK(batch0->put("D"_buf, "-"_buf)); + EXPECT_OK(batch0->put("E"_buf, "-"_buf)); checkBatchValues(*batch0, "-----"); /// @when 1. start tx 1 { // Transaction 1 - will be committed - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); + EXPECT_OK(storage_provider_->startTransaction()); auto batch1 = storage_provider_->getCurrentBatch(); /// @that 1. top level state is not changed, tx1 state like top level state @@ -111,7 +111,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { checkBatchValues(*batch1, "-----"); /// @when 2. change one of values - ASSERT_OUTCOME_SUCCESS_TRY(batch1->put("A"_buf, "1"_buf)); + EXPECT_OK(batch1->put("A"_buf, "1"_buf)); /// @that 2. top level state is not changed, tx1 state is changed checkBatchValues(*batch0, "-----"); @@ -119,7 +119,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { { /// @when 3. start tx 2 - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); + EXPECT_OK(storage_provider_->startTransaction()); auto batch2 = storage_provider_->getCurrentBatch(); /// @that 3. top level and tx1 state are not changed, tx2 state like tx1 @@ -129,7 +129,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { checkBatchValues(*batch2, "1----"); /// @when 4. change next value - ASSERT_OUTCOME_SUCCESS_TRY(batch2->put("B"_buf, "2"_buf)); + EXPECT_OK(batch2->put("B"_buf, "2"_buf)); /// @that 4. top level and tx1 state are not changed, tx2 state is changed checkBatchValues(*batch0, "-----"); @@ -138,7 +138,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { { /// @when 5. start tx 3 - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); + EXPECT_OK(storage_provider_->startTransaction()); auto batch3 = storage_provider_->getCurrentBatch(); /// @that 5. top level, tx1, tx2 state are not changed, tx3 state like @@ -149,7 +149,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { checkBatchValues(*batch3, "12---"); /// @when 6. change next value - ASSERT_OUTCOME_SUCCESS_TRY(batch3->put("C"_buf, "3"_buf)); + EXPECT_OK(batch3->put("C"_buf, "3"_buf)); /// @that 6. top level, tx1 and tx2 state are not changed, tx3 state is /// changed @@ -159,7 +159,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { checkBatchValues(*batch3, "123--"); /// @when 7. commit tx3 - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->commitTransaction()); + EXPECT_OK(storage_provider_->commitTransaction()); /// @that 7. top level and tx1 state are not changed, tx2 state became /// like tx3 @@ -170,7 +170,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { } /// @when 8. change next value - ASSERT_OUTCOME_SUCCESS_TRY(batch2->put("D"_buf, "2"_buf)); + EXPECT_OK(batch2->put("D"_buf, "2"_buf)); /// @that 8. top level and tx1 state are not changed, tx2 state is changed checkBatchValues(*batch0, "-----"); @@ -178,7 +178,7 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { checkBatchValues(*batch2, "1232-"); /// @when 9. rollback tx2 - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->rollbackTransaction()); + EXPECT_OK(storage_provider_->rollbackTransaction()); /// @that 9. top level and tx1 state are not changed, tx2 state does not /// matter anymore @@ -187,14 +187,14 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { } /// @when 10. change next value - ASSERT_OUTCOME_SUCCESS_TRY(batch1->put("E"_buf, "1"_buf)); + EXPECT_OK(batch1->put("E"_buf, "1"_buf)); /// @that 10. top level is not changed, tx1 state is changed checkBatchValues(*batch0, "-----"); checkBatchValues(*batch1, "1---1"); /// @when 11. commit tx3 - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->commitTransaction()); + EXPECT_OK(storage_provider_->commitTransaction()); /// @that 11. top level became like tx1 state checkBatchValues(*batch0, "1---1"); @@ -203,57 +203,51 @@ TEST_F(TrieStorageProviderTest, NestedTransactions) { } TEST_F(TrieStorageProviderTest, ChildTreeTransactions) { - ASSERT_OUTCOME_SUCCESS( - base_batch_1, - storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_1.get().put("A"_buf, "1"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_1.get().put("B"_buf, "2"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_1.get().put("C"_buf, "3"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_1.get().put("D"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_1.get().put("E"_buf, "-"_buf)); + auto base_batch_1 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); + EXPECT_OK(base_batch_1.get().put("A"_buf, "1"_buf)); + EXPECT_OK(base_batch_1.get().put("B"_buf, "2"_buf)); + EXPECT_OK(base_batch_1.get().put("C"_buf, "3"_buf)); + EXPECT_OK(base_batch_1.get().put("D"_buf, "-"_buf)); + EXPECT_OK(base_batch_1.get().put("E"_buf, "-"_buf)); checkBatchValues(base_batch_1, "123--"); - ASSERT_OUTCOME_SUCCESS( - base_batch_2, - storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_2.get().put("A"_buf, "4"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_2.get().put("B"_buf, "5"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_2.get().put("C"_buf, "6"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_2.get().put("D"_buf, "-"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(base_batch_2.get().put("E"_buf, "-"_buf)); + auto base_batch_2 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); + EXPECT_OK(base_batch_2.get().put("A"_buf, "4"_buf)); + EXPECT_OK(base_batch_2.get().put("B"_buf, "5"_buf)); + EXPECT_OK(base_batch_2.get().put("C"_buf, "6"_buf)); + EXPECT_OK(base_batch_2.get().put("D"_buf, "-"_buf)); + EXPECT_OK(base_batch_2.get().put("E"_buf, "-"_buf)); checkBatchValues(base_batch_2, "456--"); // First transaction - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); - ASSERT_OUTCOME_SUCCESS( - tr1_batch_1, - storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); - ASSERT_OUTCOME_SUCCESS( - tr1_batch_2, - storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); + EXPECT_OK(storage_provider_->startTransaction()); + auto tr1_batch_1 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); + auto tr1_batch_2 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); checkBatchValues(tr1_batch_1, "123--"); checkBatchValues(tr1_batch_2, "456--"); - ASSERT_OUTCOME_SUCCESS_TRY(tr1_batch_1.get().put("A"_buf, "a"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(tr1_batch_2.get().put("A"_buf, "d"_buf)); + EXPECT_OK(tr1_batch_1.get().put("A"_buf, "a"_buf)); + EXPECT_OK(tr1_batch_2.get().put("A"_buf, "d"_buf)); checkBatchValues(tr1_batch_1, "a23--"); checkBatchValues(tr1_batch_2, "d56--"); checkBatchValues(base_batch_1, "123--"); checkBatchValues(base_batch_2, "456--"); // Nested transaction - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); - ASSERT_OUTCOME_SUCCESS( - tr2_batch_1, - storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); - ASSERT_OUTCOME_SUCCESS( - tr2_batch_2, - storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); + EXPECT_OK(storage_provider_->startTransaction()); + auto tr2_batch_1 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); + auto tr2_batch_2 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); checkBatchValues(tr2_batch_1, "a23--"); checkBatchValues(tr2_batch_2, "d56--"); - ASSERT_OUTCOME_SUCCESS_TRY(tr2_batch_1.get().put("A"_buf, "0"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(tr2_batch_2.get().put("A"_buf, "1"_buf)); + EXPECT_OK(tr2_batch_1.get().put("A"_buf, "0"_buf)); + EXPECT_OK(tr2_batch_2.get().put("A"_buf, "1"_buf)); checkBatchValues(tr2_batch_1, "023--"); checkBatchValues(tr2_batch_2, "156--"); checkBatchValues(tr1_batch_1, "a23--"); @@ -261,35 +255,33 @@ TEST_F(TrieStorageProviderTest, ChildTreeTransactions) { checkBatchValues(base_batch_1, "123--"); checkBatchValues(base_batch_2, "456--"); - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->commitTransaction()); + EXPECT_OK(storage_provider_->commitTransaction()); checkBatchValues(tr1_batch_1, "023--"); checkBatchValues(tr1_batch_2, "156--"); checkBatchValues(base_batch_1, "123--"); checkBatchValues(base_batch_2, "456--"); - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->commitTransaction()); + EXPECT_OK(storage_provider_->commitTransaction()); checkBatchValues(base_batch_1, "023--"); checkBatchValues(base_batch_2, "156--"); // Second transaction - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->startTransaction()); - ASSERT_OUTCOME_SUCCESS( - tr3_batch_1, - storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); - ASSERT_OUTCOME_SUCCESS( - tr3_batch_2, - storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); + EXPECT_OK(storage_provider_->startTransaction()); + auto tr3_batch_1 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_1"_buf)); + auto tr3_batch_2 = + EXPECT_OK(storage_provider_->getMutableChildBatchAt("child_root_2"_buf)); checkBatchValues(tr3_batch_1, "023--"); checkBatchValues(tr3_batch_2, "156--"); - ASSERT_OUTCOME_SUCCESS_TRY(tr3_batch_1.get().put("A"_buf, "a"_buf)); - ASSERT_OUTCOME_SUCCESS_TRY(tr3_batch_2.get().put("A"_buf, "d"_buf)); + EXPECT_OK(tr3_batch_1.get().put("A"_buf, "a"_buf)); + EXPECT_OK(tr3_batch_2.get().put("A"_buf, "d"_buf)); checkBatchValues(tr3_batch_1, "a23--"); checkBatchValues(tr3_batch_2, "d56--"); checkBatchValues(base_batch_1, "023--"); checkBatchValues(base_batch_2, "156--"); - ASSERT_OUTCOME_SUCCESS_TRY(storage_provider_->rollbackTransaction()); + EXPECT_OK(storage_provider_->rollbackTransaction()); checkBatchValues(base_batch_1, "023--"); checkBatchValues(base_batch_2, "156--"); } diff --git a/test/core/scale/big_fixed_integers_test.cpp b/test/core/scale/big_fixed_integers_test.cpp index a507d8eea8..3455fb058d 100644 --- a/test/core/scale/big_fixed_integers_test.cpp +++ b/test/core/scale/big_fixed_integers_test.cpp @@ -7,10 +7,10 @@ #include "scale/big_fixed_integers.hpp" #include +#include #include #include "testutil/literals.hpp" -#include "testutil/outcome.hpp" using kagome::common::Buffer; using scale::Compact; @@ -21,9 +21,9 @@ template