Skip to content

Commit d621eb8

Browse files
committed
fix(consensus): correct test expectations for 33% default threshold
- test_consensus_threshold: update comments and expected values for 33% threshold - test_consensus_with_8_validators: use explicit 50% threshold config to match ChainState
1 parent 375ce2e commit d621eb8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

crates/consensus/src/state.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ mod tests {
156156
fn test_consensus_threshold() {
157157
let state = ConsensusState::new(ConsensusConfig::default());
158158

159-
// Test with 8 validators (50% = 4)
159+
// Default threshold is 33% (0.33)
160+
// Test with 8 validators: ceil(8 * 0.33) = ceil(2.64) = 3
160161
state.set_validator_count(8);
161-
assert_eq!(state.threshold(), 4);
162+
assert_eq!(state.threshold(), 3);
162163

163-
// Test with 4 validators (50% = 2)
164+
// Test with 4 validators: ceil(4 * 0.33) = ceil(1.32) = 2
164165
state.set_validator_count(4);
165166
assert_eq!(state.threshold(), 2);
166167
}

crates/consensus/tests/integration_test.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ async fn test_consensus_with_8_validators() {
3232
// Consensus threshold for 8 validators at 50% = 4
3333
assert_eq!(state.consensus_threshold(), 4);
3434

35-
// Create consensus state
36-
let consensus_state = ConsensusState::new(ConsensusConfig::default());
35+
// Create consensus state with 50% threshold to match ChainState behavior
36+
let config = ConsensusConfig {
37+
threshold: 0.5, // 50% to match ChainState.consensus_threshold()
38+
..Default::default()
39+
};
40+
let consensus_state = ConsensusState::new(config);
3741
consensus_state.set_validator_count(8);
3842

3943
// Create a proposal

0 commit comments

Comments
 (0)