• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 15534516141

09 Jun 2025 12:28PM UTC coverage: 72.299% (-0.06%) from 72.363%
15534516141

push

github

web-flow
test: add ffi cucumber wallet balance test (#7189)

Description
---
- Added cucumber test to verify wallet balance with recovery into FFI
wallet.
- Fixed broken `As a client I want to be able to restore my ffi wallet
from seed words` cucumber test.

Motivation and Context
---
Trying to solve various balance query inconsistencies.

How Has This Been Tested?
---
Cucumber test: `As a client I want to be able to check my balance from
restored wallets`

What process can a PR reviewer use to test or verify this change?
---
Code review

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added the ability to restore FFI wallets from seed words and verify
balances in integration tests.
- Introduced support for storing and checking wallet balances within the
test environment.
- Enhanced wallet CLI test steps to support wallet recovery from seed
words and view/spend key export/import.
- Added detailed logging for transaction errors in the wallet gRPC
server.
- Extended wallet process and world state with new fields for base node
association, peer seeds, balances, and keys.

- **Bug Fixes**
- Improved type handling when collecting seed words during wallet
recovery.

- **Tests**
- Added critical scenarios to test wallet restoration and balance
checking for FFI wallets.
- Introduced new test steps for remembering and verifying walle... (continued)

81268 of 112405 relevant lines covered (72.3%)

242759.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.67
/base_layer/core/src/base_node/sync/hooks.rs
1
//  Copyright 2020, The Tari Project
2
//
3
//  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
//  following conditions are met:
5
//
6
//  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
//  disclaimer.
8
//
9
//  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
//  following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
//  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
//  products derived from this software without specific prior written permission.
14
//
15
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
//  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
//  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
//  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
//  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
#![allow(clippy::type_complexity)]
24

25
use std::sync::Arc;
26

27
use crate::{
28
    base_node::sync::{horizon_state_sync::HorizonSyncInfo, SyncPeer},
29
    blocks::ChainBlock,
30
};
31

32
#[derive(Default)]
33
pub(super) struct Hooks {
34
    on_starting: Vec<Box<dyn FnOnce(&SyncPeer) + Send + Sync>>,
35
    on_progress_header: Vec<Box<dyn Fn(u64, u64, &SyncPeer) + Send + Sync>>,
36
    on_progress_block: Vec<Box<dyn Fn(Arc<ChainBlock>, u64, &SyncPeer) + Send + Sync>>,
37
    on_progress_horizon_sync: Vec<Box<dyn Fn(HorizonSyncInfo) + Send + Sync>>,
38
    on_complete: Vec<Box<dyn Fn(Arc<ChainBlock>, u64) + Send + Sync>>,
39
    on_rewind: Vec<Box<dyn Fn(Vec<Arc<ChainBlock>>) + Send + Sync>>,
40
}
41

42
impl Hooks {
43
    pub fn add_on_starting_hook<H>(&mut self, hook: H)
12✔
44
    where H: FnOnce(&SyncPeer) + Send + Sync + 'static {
12✔
45
        self.on_starting.push(Box::new(hook));
12✔
46
    }
12✔
47

48
    pub fn call_on_starting_hook(&mut self, sync_peer: &SyncPeer) {
12✔
49
        self.on_starting.drain(..).for_each(|f| (f)(sync_peer));
12✔
50
    }
12✔
51

52
    pub fn add_on_progress_header_hook<H>(&mut self, hook: H)
12✔
53
    where H: Fn(u64, u64, &SyncPeer) + Send + Sync + 'static {
12✔
54
        self.on_progress_header.push(Box::new(hook));
12✔
55
    }
12✔
56

57
    pub fn call_on_progress_header_hooks(&self, local_height: u64, remote_height: u64, sync_peer: &SyncPeer) {
1✔
58
        self.on_progress_header
1✔
59
            .iter()
1✔
60
            .for_each(|f| (*f)(local_height, remote_height, sync_peer));
1✔
61
    }
1✔
62

63
    pub fn add_on_progress_block_hook<H>(&mut self, hook: H)
×
64
    where H: Fn(Arc<ChainBlock>, u64, &SyncPeer) + Send + Sync + 'static {
×
65
        self.on_progress_block.push(Box::new(hook));
×
66
    }
×
67

68
    pub fn call_on_progress_block_hooks(&self, block: Arc<ChainBlock>, remote_tip_height: u64, sync_peer: &SyncPeer) {
×
69
        self.on_progress_block
×
70
            .iter()
×
71
            .for_each(|f| (*f)(block.clone(), remote_tip_height, sync_peer));
×
72
    }
×
73

74
    pub fn add_on_progress_horizon_hook<H>(&mut self, hook: H)
×
75
    where H: Fn(HorizonSyncInfo) + Send + Sync + 'static {
×
76
        self.on_progress_horizon_sync.push(Box::new(hook));
×
77
    }
×
78

79
    pub fn call_on_progress_horizon_hooks(&self, info: HorizonSyncInfo) {
×
80
        self.on_progress_horizon_sync.iter().for_each(|f| (*f)(info.clone()));
×
81
    }
×
82

83
    pub fn add_on_complete_hook<H>(&mut self, hook: H)
×
84
    where H: Fn(Arc<ChainBlock>, u64) + Send + Sync + 'static {
×
85
        self.on_complete.push(Box::new(hook));
×
86
    }
×
87

88
    pub fn call_on_complete_hooks(&self, final_block: Arc<ChainBlock>, starting_height: u64) {
×
89
        self.on_complete
×
90
            .iter()
×
91
            .for_each(|f| (*f)(final_block.clone(), starting_height));
×
92
    }
×
93

94
    pub fn add_on_rewind_hook<H>(&mut self, hook: H)
12✔
95
    where H: Fn(Vec<Arc<ChainBlock>>) + Send + Sync + 'static {
12✔
96
        self.on_rewind.push(Box::new(hook));
12✔
97
    }
12✔
98

99
    pub fn call_on_rewind_hooks(&mut self, blocks: Vec<Arc<ChainBlock>>) {
×
100
        self.on_rewind.iter().for_each(|f| (*f)(blocks.clone()));
×
101
    }
×
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc