@@ -3,6 +3,7 @@ pub mod compress;
33pub mod v1;
44pub mod v10;
55pub mod v11;
6+ pub mod v12;
67pub mod v13;
78pub mod v2;
89pub mod v3;
@@ -126,9 +127,9 @@ pub fn decode_full_report(payload: &[u8]) -> Result<(Vec<[u8; 32]>, Vec<u8>), Re
126127mod tests {
127128 use super :: * ;
128129 use crate :: report:: {
129- v1:: ReportDataV1 , v10:: ReportDataV10 , v11:: ReportDataV11 , v13 :: ReportDataV13 ,
130- v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 , v6 :: ReportDataV6 ,
131- v7:: ReportDataV7 , v8:: ReportDataV8 , v9:: ReportDataV9 ,
130+ v1:: ReportDataV1 , v10:: ReportDataV10 , v11:: ReportDataV11 , v11 :: ReportDataV12 ,
131+ v13 :: ReportDataV13 , v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 ,
132+ v6 :: ReportDataV6 , v7:: ReportDataV7 , v8:: ReportDataV8 , v9:: ReportDataV9 ,
132133 } ;
133134 use num_bigint:: BigInt ;
134135
@@ -176,6 +177,10 @@ mod tests {
176177 00 , 11 , 251 , 109 , 19 , 88 , 151 , 228 , 170 , 245 , 101 , 123 , 255 , 211 , 176 , 180 , 143 , 142 , 42 ,
177178 81 , 49 , 33 , 76 , 158 , 194 , 214 , 46 , 172 , 93 , 83 , 32 , 103 ,
178179 ] ) ;
180+ const V12_FEED_ID : ID = ID ( [
181+ 00 , 12 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
182+ 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
183+ ] ) ;
179184 const V13_FEED_ID : ID = ID ( [
180185 00 , 13 , 19 , 169 , 185 , 197 , 227 , 122 , 9 , 159 , 55 , 78 , 146 , 195 , 121 , 20 , 175 , 92 , 38 , 143 ,
181186 58 , 138 , 151 , 33 , 241 , 114 , 81 , 53 , 191 , 180 , 203 , 184 ,
@@ -396,6 +401,27 @@ mod tests {
396401 report_data
397402 }
398403
404+ pub fn generate_mock_report_data_v12 ( ) -> ReportDataV12 {
405+ const MOCK_NAV_PER_SHARE : isize = 1 ;
406+ const MOCK_NEXT_NAV_PER_SHARE : isize = 2 ;
407+ const RIPCORD_NORMAL : u32 = 0 ;
408+
409+ let report_data = ReportDataV12 {
410+ feed_id : V12_FEED_ID ,
411+ valid_from_timestamp : MOCK_TIMESTAMP ,
412+ observations_timestamp : MOCK_TIMESTAMP ,
413+ native_fee : BigInt :: from ( MOCK_FEE ) ,
414+ link_fee : BigInt :: from ( MOCK_FEE ) ,
415+ expires_at : MOCK_TIMESTAMP + 100 ,
416+ nav_per_share : BigInt :: from ( MOCK_NAV_PER_SHARE ) ,
417+ next_nav_per_share : BigInt :: from ( MOCK_NEXT_NAV_PER_SHARE ) ,
418+ nav_date : MOCK_TIMESTAMP as i64 ,
419+ ripcord : RIPCORD_NORMAL ,
420+ } ;
421+
422+ report_data
423+ }
424+
399425 pub fn generate_mock_report_data_v13 ( ) -> ReportDataV13 {
400426 let multiplier: BigInt = "1000000000000000000" . parse :: < BigInt > ( ) . unwrap ( ) ; // 1.0 with 18 decimals
401427
@@ -808,6 +834,38 @@ mod tests {
808834 assert_eq ! ( decoded_report. feed_id, V11_FEED_ID ) ;
809835 }
810836
837+ #[ test]
838+ fn test_decode_report_v12 ( ) {
839+ let report_data = generate_mock_report_data_v12 ( ) ;
840+ let encoded_report_data = report_data. abi_encode ( ) . unwrap ( ) ;
841+
842+ let report = generate_mock_report ( & encoded_report_data) ;
843+
844+ let ( _report_context, report_blob) = decode_full_report ( & report) . unwrap ( ) ;
845+
846+ let expected_report_blob = vec ! [
847+ "000c6b4aa7e57ca7b68ae1bf45653f56b656fd3aa335ef7fae696b663f1b8472" ,
848+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
849+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
850+ "000000000000000000000000000000000000000000000000000000000000000a" ,
851+ "000000000000000000000000000000000000000000000000000000000000000a" ,
852+ "0000000000000000000000000000000000000000000000000000000066741df0" ,
853+ "0000000000000000000000000000000000000000000000000000000000000001" , // NAV per share
854+ "0000000000000000000000000000000000000000000000000000000000000002" , // Next NAV per share
855+ "0000000000000000000000000000000000000000000000000000000066741d8c" , // NAV date
856+ "0000000000000000000000000000000000000000000000000000000000000000" , // Ripcord: Normal
857+ ] ;
858+
859+ assert_eq ! (
860+ report_blob,
861+ bytes( & format!( "0x{}" , expected_report_blob. join( "" ) ) )
862+ ) ;
863+
864+ let decoded_report = ReportDataV12 :: decode ( & report_blob) . unwrap ( ) ;
865+
866+ assert_eq ! ( decoded_report. feed_id, V12_FEED_ID ) ;
867+ }
868+
811869 #[ test]
812870 fn test_decode_report_v13 ( ) {
813871 let report_data = generate_mock_report_data_v13 ( ) ;
0 commit comments