@@ -5,6 +5,13 @@ mod tests {
55 use dashcore:: { BlockHash , ChainLock , Network } ;
66 use dashcore_hashes:: Hash ;
77
8+ /// Create a test block hash from a single byte (for distinct test hashes)
9+ fn test_block_hash ( id : u8 ) -> BlockHash {
10+ let mut bytes = [ 0u8 ; 32 ] ;
11+ bytes[ 0 ] = id;
12+ BlockHash :: from_byte_array ( bytes)
13+ }
14+
815 #[ tokio:: test]
916 async fn test_chainlock_processing ( ) {
1017 // Create storage and ChainLock manager
@@ -16,7 +23,7 @@ mod tests {
1623 // Create a test ChainLock
1724 let chainlock = ChainLock {
1825 block_height : 1000 ,
19- block_hash : BlockHash :: from_raw_hash ( dashcore_hashes :: hash_x11 :: Hash :: hash ( & [ 1 , 2 , 3 ] ) ) ,
26+ block_hash : test_block_hash ( 1 ) ,
2027 signature : dashcore:: bls_sig_utils:: BLSSignature :: from ( [ 0 ; 96 ] ) ,
2128 } ;
2229
@@ -49,7 +56,7 @@ mod tests {
4956 // Process first ChainLock at height 1000
5057 let chainlock1 = ChainLock {
5158 block_height : 1000 ,
52- block_hash : BlockHash :: from_raw_hash ( dashcore_hashes :: hash_x11 :: Hash :: hash ( & [ 1 , 2 , 3 ] ) ) ,
59+ block_hash : test_block_hash ( 1 ) ,
5360 signature : dashcore:: bls_sig_utils:: BLSSignature :: from ( [ 0 ; 96 ] ) ,
5461 } ;
5562 chainlock_manager
@@ -60,7 +67,7 @@ mod tests {
6067 // Process second ChainLock at height 2000
6168 let chainlock2 = ChainLock {
6269 block_height : 2000 ,
63- block_hash : BlockHash :: from_raw_hash ( dashcore_hashes :: hash_x11 :: Hash :: hash ( & [ 4 , 5 , 6 ] ) ) ,
70+ block_hash : test_block_hash ( 2 ) ,
6471 signature : dashcore:: bls_sig_utils:: BLSSignature :: from ( [ 1 ; 96 ] ) ,
6572 } ;
6673 chainlock_manager
@@ -85,12 +92,10 @@ mod tests {
8592 DiskStorageManager :: with_temp_dir ( ) . await . expect ( "Failed to create tmp storage" ) ;
8693
8794 // Add ChainLocks at heights 1000, 2000, 3000
88- for height in [ 1000 , 2000 , 3000 ] {
95+ for ( i , height) in [ 1000u32 , 2000 , 3000 ] . iter ( ) . enumerate ( ) {
8996 let chainlock = ChainLock {
90- block_height : height,
91- block_hash : BlockHash :: from_raw_hash ( dashcore_hashes:: hash_x11:: Hash :: hash (
92- & height. to_le_bytes ( ) ,
93- ) ) ,
97+ block_height : * height,
98+ block_hash : test_block_hash ( ( i + 10 ) as u8 ) ,
9499 signature : dashcore:: bls_sig_utils:: BLSSignature :: from ( [ 0 ; 96 ] ) ,
95100 } ;
96101 chainlock_manager
0 commit comments