@@ -1139,10 +1139,7 @@ pub enum Hash {
11391139
11401140impl Default for Hash {
11411141 fn default ( ) -> Hash {
1142- Hash :: SHA256 ( [
1143- 227 , 176 , 196 , 66 , 152 , 252 , 28 , 20 , 154 , 251 , 244 , 200 , 153 , 111 , 185 , 36 , 39 , 174 ,
1144- 65 , 228 , 100 , 155 , 147 , 76 , 164 , 149 , 153 , 27 , 120 , 82 , 184 , 85 ,
1145- ] )
1142+ Hash :: SHA256 ( [ 0 ; 32 ] )
11461143 }
11471144}
11481145
@@ -4714,7 +4711,10 @@ mod tests {
47144711 . collect ( ) ;
47154712 let proof = InclusionProof :: sha256 ( result. index , lemma) ;
47164713 assert ! ( proof. verify(
4717- dr_txs[ index] . body. data_poi_hash( ) . into( ) ,
4714+ dr_txs[ index]
4715+ . body
4716+ . data_poi_hash( ProtocolVersion :: default ( ) )
4717+ . into( ) ,
47184718 sb. data_request_root. into( )
47194719 ) ) ;
47204720 }
@@ -4742,10 +4742,8 @@ mod tests {
47424742 } )
47434743 . collect ( ) ;
47444744 let proof = InclusionProof :: sha256 ( result. index , lemma) ;
4745- assert ! ( proof. verify(
4746- tally_txs[ index] . data_poi_hash( ) . into( ) ,
4747- sb. tally_root. into( )
4748- ) ) ;
4745+ let data_poi_hash = tally_txs[ index] . data_poi_hash ( ) ;
4746+ assert ! ( proof. verify( data_poi_hash. into( ) , sb. tally_root. into( ) ) ) ;
47494747 }
47504748 }
47514749
@@ -4793,7 +4791,82 @@ mod tests {
47934791 tally_txs
47944792 }
47954793
4796- #[ ignore]
4794+ #[ test]
4795+ fn test_block_header_serialization_across_protocol_versions ( ) {
4796+ let block = block_example ( ) ;
4797+ assert_ne ! (
4798+ hex:: encode(
4799+ block
4800+ . block_header
4801+ . to_versioned_pb_bytes( ProtocolVersion :: V1_7 )
4802+ . unwrap( )
4803+ ) ,
4804+ hex:: encode(
4805+ block
4806+ . block_header
4807+ . to_versioned_pb_bytes( ProtocolVersion :: V1_8 )
4808+ . unwrap( )
4809+ ) ,
4810+ ) ;
4811+ assert_eq ! (
4812+ hex:: encode(
4813+ block
4814+ . block_header
4815+ . to_versioned_pb_bytes( ProtocolVersion :: V1_8 )
4816+ . unwrap( )
4817+ ) ,
4818+ hex:: encode(
4819+ block
4820+ . block_header
4821+ . to_versioned_pb_bytes( ProtocolVersion :: V2_0 )
4822+ . unwrap( )
4823+ ) ,
4824+ ) ;
4825+ }
4826+
4827+ #[ test]
4828+ fn test_block_header_hashing_across_protocol_versions ( ) {
4829+ let block = block_example ( ) ;
4830+ assert_ne ! (
4831+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V1_7 ) ) ,
4832+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4833+ ) ;
4834+ assert_eq ! (
4835+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4836+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V2_0 ) ) ,
4837+ ) ;
4838+ }
4839+
4840+ #[ test]
4841+ fn test_block_hashing_across_protocol_versions ( ) {
4842+ let block = block_example ( ) ;
4843+ assert_ne ! (
4844+ hex:: encode( block. versioned_hash( ProtocolVersion :: V1_7 ) ) ,
4845+ hex:: encode( block. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4846+ ) ;
4847+ assert_eq ! (
4848+ hex:: encode( block. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4849+ hex:: encode( block. versioned_hash( ProtocolVersion :: V2_0 ) ) ,
4850+ ) ;
4851+ }
4852+
4853+ #[ test]
4854+ fn test_block_hashing_matches_block_header_hashing ( ) {
4855+ let block = block_example ( ) ;
4856+ assert_eq ! (
4857+ hex:: encode( block. versioned_hash( ProtocolVersion :: V1_7 ) ) ,
4858+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V1_7 ) ) ,
4859+ ) ;
4860+ assert_eq ! (
4861+ hex:: encode( block. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4862+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V1_8 ) ) ,
4863+ ) ;
4864+ assert_eq ! (
4865+ hex:: encode( block. versioned_hash( ProtocolVersion :: V2_0 ) ) ,
4866+ hex:: encode( block. block_header. versioned_hash( ProtocolVersion :: V2_0 ) ) ,
4867+ ) ;
4868+ }
4869+
47974870 #[ test]
47984871 fn test_block_hashable_trait ( ) {
47994872 let block = block_example ( ) ;
@@ -4814,7 +4887,6 @@ mod tests {
48144887 ) ;
48154888 }
48164889
4817- #[ ignore]
48184890 #[ test]
48194891 fn test_transaction_hashable_trait ( ) {
48204892 let transaction = transaction_example ( ) ;
0 commit comments