Skip to content

Commit 6f3c80c

Browse files
CopilotSteake
andcommitted
Address code review feedback for VRF integration tests
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
1 parent 33b90bc commit 6f3c80c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

tests/vrf_integration.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
//! including key derivation, proof generation/verification, and blockchain integration.
55
66
use bitcell_crypto::{PublicKey, SecretKey, Hash256};
7+
use bitcell_crypto::vrf::combine_vrf_outputs;
78
use bitcell_node::blockchain::Blockchain;
89
use bitcell_metrics::MetricsRegistry;
10+
use sha2::{Digest, Sha256};
911
use std::sync::Arc;
1012

1113
/// Test that VRF keys are correctly derived from secp256k1 keys
@@ -112,27 +114,27 @@ fn test_vrf_chaining_in_blockchain() {
112114
vec![],
113115
vec![],
114116
sk.public_key(),
115-
).expect(&format!("Should produce block {}", i + 1));
117+
).expect("Should produce block");
116118

117119
// Verify VRF output is non-zero
118120
assert_ne!(block.header.vrf_output, [0u8; 32],
119-
"Block {} VRF output should be non-zero", i + 1);
121+
"Block VRF output should be non-zero");
120122

121123
// Verify VRF proof exists
122124
assert!(!block.header.vrf_proof.is_empty(),
123-
"Block {} should have VRF proof", i + 1);
125+
"Block should have VRF proof");
124126

125127
// If not first block, verify VRF output differs from previous
126128
if i > 0 {
127129
assert_ne!(block.header.vrf_output, blocks[i - 1].header.vrf_output,
128-
"Block {} VRF should differ from block {} due to chaining", i + 1, i);
130+
"Block VRF should differ from previous block due to chaining");
129131
}
130132

131133
// Validate and add block
132134
blockchain.validate_block(&block)
133-
.expect(&format!("Block {} should be valid", i + 1));
135+
.expect("Block should be valid");
134136
blockchain.add_block(block.clone())
135-
.expect(&format!("Should add block {}", i + 1));
137+
.expect("Should add block");
136138

137139
blocks.push(block);
138140
}
@@ -202,15 +204,15 @@ fn test_vrf_multiple_validators() {
202204
vec![],
203205
vec![],
204206
validator.public_key(),
205-
).expect(&format!("Validator {} should produce block", i));
207+
).expect("Validator should produce block");
206208

207209
// Verify VRF output is unique and non-zero
208210
assert_ne!(block.header.vrf_output, [0u8; 32],
209-
"Validator {} block should have non-zero VRF", i);
211+
"Validator block should have non-zero VRF");
210212

211213
// Verify block is valid
212214
blockchain.validate_block(&block)
213-
.expect(&format!("Validator {} block should be valid", i));
215+
.expect("Validator block should be valid");
214216

215217
blockchain.add_block(block).expect("Should add block");
216218
}
@@ -238,9 +240,9 @@ fn test_vrf_output_distribution() {
238240
}
239241

240242
// Outputs should not be all zeros
241-
for (i, output) in outputs.iter().enumerate() {
243+
for output in outputs.iter() {
242244
assert_ne!(output.as_bytes(), &[0u8; 32],
243-
"VRF output {} should not be all zeros", i);
245+
"VRF output should not be all zeros");
244246
}
245247
}
246248

@@ -260,7 +262,7 @@ fn test_vrf_output_unpredictability() {
260262

261263
// Outputs should not be trivially related to the message
262264
let message_hash = Hash256::from_bytes(
263-
sha2::Sha256::digest(message).into()
265+
Sha256::digest(message).into()
264266
);
265267
assert_ne!(output1.as_bytes(), message_hash.as_bytes());
266268
assert_ne!(output2.as_bytes(), message_hash.as_bytes());
@@ -328,8 +330,6 @@ fn test_vrf_long_message() {
328330
/// Test combining multiple VRF outputs for tournament seeding
329331
#[test]
330332
fn test_vrf_output_combination() {
331-
use bitcell_crypto::vrf::combine_vrf_outputs;
332-
333333
let sk1 = SecretKey::generate();
334334
let sk2 = SecretKey::generate();
335335
let sk3 = SecretKey::generate();

0 commit comments

Comments
 (0)