Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
cypt4 committed Dec 13, 2024
1 parent 3be9e86 commit 78df8ea
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
3 changes: 3 additions & 0 deletions components/brave_wallet/browser/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 8 additions & 2 deletions components/brave_wallet/browser/zcash/rust/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class OrchardShardTree {
static std::unique_ptr<OrchardShardTree> Create(
::brave_wallet::OrchardStorage& storage,
const mojom::AccountIdPtr& account_id);

// Creates a small tree height of 8 for testing purposes.
static std::unique_ptr<OrchardShardTree> CreateForTesting(
::brave_wallet::OrchardStorage& storage,
const mojom::AccountIdPtr& account_id);
};

} // namespace orchard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
#include <string>
#include <utility>

#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"
Expand All @@ -14,8 +19,7 @@ namespace brave_wallet::orchard {

class OrchardTestingShardTreeImpl : public OrchardShardTree {
public:
OrchardTestingShardTreeImpl(base::PassKey<class OrchardShardTree>,
::rust::Box<CxxOrchardTestingShardTree>);
explicit OrchardTestingShardTreeImpl(::rust::Box<CxxOrchardTestingShardTree>);
~OrchardTestingShardTreeImpl() override;

bool TruncateToCheckpoint(uint32_t checkpoint_id) override;
Expand Down Expand Up @@ -65,24 +69,23 @@ bool OrchardTestingShardTreeImpl::TruncateToCheckpoint(uint32_t checkpoint_id) {
}

OrchardTestingShardTreeImpl::OrchardTestingShardTreeImpl(
base::PassKey<class OrchardShardTree>,
rust::Box<CxxOrchardTestingShardTree> 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> OrchardShardTree::CreateForTesting(
std::unique_ptr<OrchardShardTree> 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<CxxOrchardShardTreeDelegate>(storage, account_id));
if (!shard_tree_result->is_ok()) {
return nullptr;
}
return std::make_unique<OrchardTestingShardTreeImpl>(
base::PassKey<class OrchardShardTree>(), shard_tree_result->unwrap());
shard_tree_result->unwrap());
}

} // namespace brave_wallet::orchard
Original file line number Diff line number Diff line change
@@ -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 <memory>

#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<OrchardShardTree> 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_

0 comments on commit 78df8ea

Please sign in to comment.