From 78df8ea27ad05237a363dd863f1ea0eb103afd0b Mon Sep 17 00:00:00 2001 From: oisupov Date: Fri, 13 Dec 2024 18:23:03 +0400 Subject: [PATCH] Fix build --- .../brave_wallet/browser/internal/BUILD.gn | 3 ++ .../browser/internal/orchard_sync_state.cc | 2 +- .../internal/orchard_sync_state_unittest.cc | 1 + .../brave_wallet/browser/zcash/rust/BUILD.gn | 10 +++++-- .../browser/zcash/rust/orchard_shard_tree.h | 5 ---- .../zcash/rust/orchard_testing_shard_tree.cc | 15 ++++++---- .../zcash/rust/orchard_testing_shard_tree.h | 29 +++++++++++++++++++ 7 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h diff --git a/components/brave_wallet/browser/internal/BUILD.gn b/components/brave_wallet/browser/internal/BUILD.gn index c535f9a7e721..e84322df0c9c 100644 --- a/components/brave_wallet/browser/internal/BUILD.gn +++ b/components/brave_wallet/browser/internal/BUILD.gn @@ -44,6 +44,9 @@ if (enable_orchard) { "orchard_test_utils.cc", "orchard_test_utils.h", ] + public_deps = [ + "//brave/components/brave_wallet/browser/zcash/rust:test_support_headers", + ] deps = [ ":orchard_bundle", "//brave/components/brave_wallet/browser/zcash/rust:test_support", diff --git a/components/brave_wallet/browser/internal/orchard_sync_state.cc b/components/brave_wallet/browser/internal/orchard_sync_state.cc index 516ed73aa709..387b9355b5c7 100644 --- a/components/brave_wallet/browser/internal/orchard_sync_state.cc +++ b/components/brave_wallet/browser/internal/orchard_sync_state.cc @@ -150,7 +150,7 @@ bool OrchardSyncState::Truncate(const mojom::AccountIdPtr& account_id, void OrchardSyncState::OverrideShardTreeForTesting( const mojom::AccountIdPtr& account_id) { shard_trees_[account_id->unique_key] = - orchard::OrchardShardTree::CreateForTesting(storage_, account_id); + orchard::CreateShardTreeForTesting(storage_, account_id); } OrchardStorage& OrchardSyncState::orchard_storage() { diff --git a/components/brave_wallet/browser/internal/orchard_sync_state_unittest.cc b/components/brave_wallet/browser/internal/orchard_sync_state_unittest.cc index 4f03754e768a..d0116c04f920 100644 --- a/components/brave_wallet/browser/internal/orchard_sync_state_unittest.cc +++ b/components/brave_wallet/browser/internal/orchard_sync_state_unittest.cc @@ -10,6 +10,7 @@ #include "base/files/scoped_temp_dir.h" #include "brave/components/brave_wallet/browser/internal/orchard_storage/orchard_shard_tree_types.h" #include "brave/components/brave_wallet/browser/internal/orchard_test_utils.h" +#include "brave/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h" #include "brave/components/brave_wallet/common/common_utils.h" #include "brave/components/brave_wallet/common/hex_utils.h" #include "brave/components/brave_wallet/common/zcash_utils.h" diff --git a/components/brave_wallet/browser/zcash/rust/BUILD.gn b/components/brave_wallet/browser/zcash/rust/BUILD.gn index 0d5d50d3d541..ccec4aee65ba 100644 --- a/components/brave_wallet/browser/zcash/rust/BUILD.gn +++ b/components/brave_wallet/browser/zcash/rust/BUILD.gn @@ -26,8 +26,14 @@ group("test_support") { } source_set("test_support_headers") { - visibility = [ ":*" ] - sources = [ "orchard_test_utils.h" ] + visibility = [ + ":*", + "//brave/components/brave_wallet/browser/internal:test_support", + ] + sources = [ + "orchard_test_utils.h", + "orchard_testing_shard_tree.h", + ] public_deps = [ ":orchard_headers" ] } diff --git a/components/brave_wallet/browser/zcash/rust/orchard_shard_tree.h b/components/brave_wallet/browser/zcash/rust/orchard_shard_tree.h index cdb4ba20af48..6211534979f6 100644 --- a/components/brave_wallet/browser/zcash/rust/orchard_shard_tree.h +++ b/components/brave_wallet/browser/zcash/rust/orchard_shard_tree.h @@ -40,11 +40,6 @@ class OrchardShardTree { static std::unique_ptr Create( ::brave_wallet::OrchardStorage& storage, const mojom::AccountIdPtr& account_id); - - // Creates a small tree height of 8 for testing purposes. - static std::unique_ptr CreateForTesting( - ::brave_wallet::OrchardStorage& storage, - const mojom::AccountIdPtr& account_id); }; } // namespace orchard diff --git a/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.cc b/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.cc index 5609224dd7a0..058435bb1ce7 100644 --- a/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.cc +++ b/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.cc @@ -3,8 +3,13 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. +#include "brave/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h" + #include +#include +#include +#include "base/check_is_test.h" #include "brave/components/brave_wallet/browser/zcash/rust/cxx_orchard_shard_tree_delegate.h" #include "brave/components/brave_wallet/browser/zcash/rust/lib.rs.h" #include "brave/components/brave_wallet/browser/zcash/rust/orchard_decoded_blocks_bundle_impl.h" @@ -14,8 +19,7 @@ namespace brave_wallet::orchard { class OrchardTestingShardTreeImpl : public OrchardShardTree { public: - OrchardTestingShardTreeImpl(base::PassKey, - ::rust::Box); + explicit OrchardTestingShardTreeImpl(::rust::Box); ~OrchardTestingShardTreeImpl() override; bool TruncateToCheckpoint(uint32_t checkpoint_id) override; @@ -65,24 +69,23 @@ bool OrchardTestingShardTreeImpl::TruncateToCheckpoint(uint32_t checkpoint_id) { } OrchardTestingShardTreeImpl::OrchardTestingShardTreeImpl( - base::PassKey, rust::Box cxx_orchard_testing_shard_tree) : cxx_orchard_testing_shard_tree_( std::move(cxx_orchard_testing_shard_tree)) {} OrchardTestingShardTreeImpl::~OrchardTestingShardTreeImpl() = default; -// static -std::unique_ptr OrchardShardTree::CreateForTesting( +std::unique_ptr CreateShardTreeForTesting( // IN-TEST ::brave_wallet::OrchardStorage& storage, const mojom::AccountIdPtr& account_id) { + CHECK_IS_TEST(); auto shard_tree_result = create_orchard_testing_shard_tree( std::make_unique(storage, account_id)); if (!shard_tree_result->is_ok()) { return nullptr; } return std::make_unique( - base::PassKey(), shard_tree_result->unwrap()); + shard_tree_result->unwrap()); } } // namespace brave_wallet::orchard diff --git a/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h b/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h new file mode 100644 index 000000000000..b7282a36bdaf --- /dev/null +++ b/components/brave_wallet/browser/zcash/rust/orchard_testing_shard_tree.h @@ -0,0 +1,29 @@ +// Copyright (c) 2024 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at https://mozilla.org/MPL/2.0/. + +#ifndef BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_ORCHARD_TESTING_SHARD_TREE_H_ +#define BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_ORCHARD_TESTING_SHARD_TREE_H_ + +#include + +#include "brave/components/brave_wallet/common/brave_wallet.mojom.h" + +namespace brave_wallet { + +class OrchardStorage; + +namespace orchard { + +class OrchardShardTree; + +// Creates a small tree height of 8 for testing purposes. +std::unique_ptr CreateShardTreeForTesting( // IN-TEST + ::brave_wallet::OrchardStorage& storage, + const mojom::AccountIdPtr& account_id); + +} // namespace orchard +} // namespace brave_wallet + +#endif // BRAVE_COMPONENTS_BRAVE_WALLET_BROWSER_ZCASH_RUST_ORCHARD_TESTING_SHARD_TREE_H_