@@ -6,6 +6,7 @@ pub mod v3;
66pub mod v4;
77pub mod v5;
88pub mod v6;
9+ pub mod v7;
910pub mod v8;
1011pub mod v9;
1112pub mod v10;
@@ -122,7 +123,7 @@ pub fn decode_full_report(payload: &[u8]) -> Result<(Vec<[u8; 32]>, Vec<u8>), Re
122123#[ cfg( test) ]
123124mod tests {
124125 use super :: * ;
125- use crate :: report:: { v1:: ReportDataV1 , v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 , v6:: ReportDataV6 , v8:: ReportDataV8 , v9:: ReportDataV9 , v10:: ReportDataV10 } ;
126+ use crate :: report:: { v1:: ReportDataV1 , v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 , v6:: ReportDataV6 , v7 :: ReportDataV7 , v8:: ReportDataV8 , v9:: ReportDataV9 , v10:: ReportDataV10 } ;
126127 use num_bigint:: BigInt ;
127128
128129 const V1_FEED_ID : ID = ID ( [
@@ -149,6 +150,10 @@ mod tests {
149150 00 , 06 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
150151 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
151152 ] ) ;
153+ const V7_FEED_ID : ID = ID ( [
154+ 00 , 07 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
155+ 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
156+ ] ) ;
152157 const V8_FEED_ID : ID = ID ( [
153158 00 , 08 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
154159 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
@@ -269,6 +274,20 @@ mod tests {
269274 report_data
270275 }
271276
277+ pub fn generate_mock_report_data_v7 ( ) -> ReportDataV7 {
278+ let report_data = ReportDataV7 {
279+ feed_id : V7_FEED_ID ,
280+ valid_from_timestamp : MOCK_TIMESTAMP ,
281+ observations_timestamp : MOCK_TIMESTAMP ,
282+ native_fee : BigInt :: from ( MOCK_FEE ) ,
283+ link_fee : BigInt :: from ( MOCK_FEE ) ,
284+ expires_at : MOCK_TIMESTAMP + 100 ,
285+ exchange_rate : BigInt :: from ( MOCK_PRICE ) ,
286+ } ;
287+
288+ report_data
289+ }
290+
272291 pub fn generate_mock_report_data_v8 ( ) -> ReportDataV8 {
273292 let report_data = ReportDataV8 {
274293 feed_id : V8_FEED_ID ,
@@ -551,6 +570,35 @@ mod tests {
551570 assert_eq ! ( decoded_report. feed_id, V6_FEED_ID ) ;
552571 }
553572
573+ #[ test]
574+ fn test_decode_report_v7 ( ) {
575+ let report_data = generate_mock_report_data_v7 ( ) ;
576+ let encoded_report_data = report_data. abi_encode ( ) . unwrap ( ) ;
577+
578+ let report = generate_mock_report ( & encoded_report_data) ;
579+
580+ let ( _report_context, report_blob) = decode_full_report ( & report) . unwrap ( ) ;
581+
582+ let expected_report_blob = vec ! [
583+ "00076b4aa7e57ca7b68ae1bf45653f56b656fd3aa335ef7fae696b663f1b8472" ,
584+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
585+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
586+ "000000000000000000000000000000000000000000000000000000000000000a" ,
587+ "000000000000000000000000000000000000000000000000000000000000000a" ,
588+ "0000000000000000000000000000000000000000000000000000000066741df0" ,
589+ "0000000000000000000000000000000000000000000000000000000000000064" , // Exchange Rate: 100
590+ ] ;
591+
592+ assert_eq ! (
593+ report_blob,
594+ bytes( & format!( "0x{}" , expected_report_blob. join( "" ) ) )
595+ ) ;
596+
597+ let decoded_report = ReportDataV7 :: decode ( & report_blob) . unwrap ( ) ;
598+
599+ assert_eq ! ( decoded_report. feed_id, V7_FEED_ID ) ;
600+ }
601+
554602 #[ test]
555603 fn test_decode_report_v8 ( ) {
556604 let report_data = generate_mock_report_data_v8 ( ) ;
0 commit comments