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

tari-project / tari / 18097567115

29 Sep 2025 12:50PM UTC coverage: 58.554% (-2.3%) from 60.88%
18097567115

push

github

web-flow
chore(ci): switch rust toolchain to stable (#7524)

Description
switch rust toolchain to stable

Motivation and Context
use stable rust toolchain


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

## Summary by CodeRabbit

* **Chores**
* Standardized Rust toolchain on stable across CI workflows for more
predictable builds.
* Streamlined setup by removing unnecessary components and aligning
toolchain configuration with environment variables.
  * Enabled an environment flag to improve rustup behavior during CI.
* Improved coverage workflow consistency with dynamic toolchain
selection.

* **Tests**
* Removed nightly-only requirements, simplifying test commands and
improving compatibility.
* Expanded CI triggers to include ci-* branches for better pre-merge
validation.
* Maintained existing job logic while improving reliability and
maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

66336 of 113291 relevant lines covered (58.55%)

551641.45 hits per line

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

38.57
/base_layer/core/src/validation/mocks.rs
1
// Copyright 2019. 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
use std::sync::{
24
    atomic::{AtomicBool, Ordering},
25
    Arc,
26
};
27

28
use tari_common_types::{
29
    chain_metadata::ChainMetadata,
30
    types::{CompressedCommitment, FixedHash},
31
};
32
use tari_node_components::blocks::{Block, BlockHeader, ChainBlock};
33
use tari_transaction_components::{tari_proof_of_work::Difficulty, transaction_components::Transaction};
34
use tari_utilities::epoch_time::EpochTime;
35

36
use super::{
37
    traits::CandidateBlockValidator,
38
    BlockBodyValidator,
39
    HeaderChainLinkedValidator,
40
    InternalConsistencyValidator,
41
    TransactionValidator,
42
};
43
use crate::{
44
    chain_storage::BlockchainBackend,
45
    proof_of_work::{randomx_factory::RandomXFactory, AchievedTargetDifficulty},
46
    test_helpers::create_consensus_rules,
47
    validation::{error::ValidationError, DifficultyCalculator, FinalHorizonStateValidation},
48
};
49

50
#[derive(Clone)]
51
pub struct MockValidator {
52
    is_valid: Arc<AtomicBool>,
53
}
54

55
pub struct SharedFlag(Arc<AtomicBool>);
56

57
impl SharedFlag {
58
    pub fn set(&self, v: bool) {
×
59
        self.0.store(v, Ordering::SeqCst);
×
60
    }
×
61
}
62

63
impl MockValidator {
64
    pub fn new(is_valid: bool) -> Self {
281✔
65
        Self {
281✔
66
            is_valid: Arc::new(AtomicBool::new(is_valid)),
281✔
67
        }
281✔
68
    }
281✔
69

70
    pub fn shared_flag(&self) -> SharedFlag {
×
71
        SharedFlag(self.is_valid.clone())
×
72
    }
×
73
}
74

75
impl<B: BlockchainBackend> BlockBodyValidator<B> for MockValidator {
76
    fn validate_body(&self, _: &B, block: &Block) -> Result<Block, ValidationError> {
×
77
        if self.is_valid.load(Ordering::SeqCst) {
×
78
            Ok(block.clone())
×
79
        } else {
80
            Err(ValidationError::ConsensusError(
×
81
                "This mock validator always returns an error".to_string(),
×
82
            ))
×
83
        }
84
    }
×
85
}
86

87
impl<B: BlockchainBackend> CandidateBlockValidator<B> for MockValidator {
88
    fn validate_body_with_metadata(&self, _: &B, _: &ChainBlock, _: &ChainMetadata) -> Result<(), ValidationError> {
23✔
89
        if self.is_valid.load(Ordering::SeqCst) {
23✔
90
            Ok(())
23✔
91
        } else {
92
            Err(ValidationError::ConsensusError(
×
93
                "This mock validator always returns an error".to_string(),
×
94
            ))
×
95
        }
96
    }
23✔
97
}
98

99
// #[async_trait]
100
impl InternalConsistencyValidator for MockValidator {
101
    fn validate_internal_consistency(&self, _item: &Block) -> Result<(), ValidationError> {
×
102
        if self.is_valid.load(Ordering::SeqCst) {
×
103
            Ok(())
×
104
        } else {
105
            Err(ValidationError::ConsensusError(
×
106
                "This mock validator always returns an error".to_string(),
×
107
            ))
×
108
        }
109
    }
×
110
}
111

112
impl<B: BlockchainBackend> HeaderChainLinkedValidator<B> for MockValidator {
113
    fn validate(
23✔
114
        &self,
23✔
115
        db: &B,
23✔
116
        header: &BlockHeader,
23✔
117
        _: &BlockHeader,
23✔
118
        _: &[EpochTime],
23✔
119
        _: Option<Difficulty>,
23✔
120
        _: FixedHash,
23✔
121
    ) -> Result<AchievedTargetDifficulty, ValidationError> {
23✔
122
        if self.is_valid.load(Ordering::SeqCst) {
23✔
123
            // this assumes consensus rules are the same as the test rules which is a little brittle
124
            let difficulty_calculator = DifficultyCalculator::new(create_consensus_rules(), RandomXFactory::default());
23✔
125
            let achieved_target_diff = difficulty_calculator.check_achieved_and_target_difficulty(db, header)?;
23✔
126
            Ok(achieved_target_diff)
23✔
127
        } else {
128
            Err(ValidationError::ConsensusError(
×
129
                "This mock validator always returns an error".to_string(),
×
130
            ))
×
131
        }
132
    }
23✔
133
}
134

135
impl TransactionValidator for MockValidator {
136
    fn validate(&self, _transaction: &Transaction) -> Result<(), ValidationError> {
29✔
137
        if self.is_valid.load(Ordering::SeqCst) {
29✔
138
            Ok(())
29✔
139
        } else {
140
            Err(ValidationError::ConsensusError(
×
141
                "This mock validator always returns an error".to_string(),
×
142
            ))
×
143
        }
144
    }
29✔
145
}
146

147
impl<B: BlockchainBackend> FinalHorizonStateValidation<B> for MockValidator {
148
    fn validate(
×
149
        &self,
×
150
        _backend: &B,
×
151
        _height: u64,
×
152
        _total_utxo_sum: &CompressedCommitment,
×
153
        _total_kernel_sum: &CompressedCommitment,
×
154
        _total_burned_sum: &CompressedCommitment,
×
155
    ) -> Result<(), ValidationError> {
×
156
        if self.is_valid.load(Ordering::SeqCst) {
×
157
            Ok(())
×
158
        } else {
159
            Err(ValidationError::ConsensusError(
×
160
                "This mock validator always returns an error".to_string(),
×
161
            ))
×
162
        }
163
    }
×
164
}
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