@@ -5,6 +5,7 @@ pub mod v2;
55pub mod v3;
66pub mod v4;
77pub mod v5;
8+ pub mod v6;
89pub mod v8;
910pub mod v9;
1011pub mod v10;
@@ -121,7 +122,7 @@ pub fn decode_full_report(payload: &[u8]) -> Result<(Vec<[u8; 32]>, Vec<u8>), Re
121122#[ cfg( test) ]
122123mod tests {
123124 use super :: * ;
124- use crate :: report:: { v1:: ReportDataV1 , v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 , v8:: ReportDataV8 , v9:: ReportDataV9 , v10:: ReportDataV10 } ;
125+ use crate :: report:: { v1:: ReportDataV1 , v2:: ReportDataV2 , v3:: ReportDataV3 , v4:: ReportDataV4 , v5:: ReportDataV5 , v6 :: ReportDataV6 , v8:: ReportDataV8 , v9:: ReportDataV9 , v10:: ReportDataV10 } ;
125126 use num_bigint:: BigInt ;
126127
127128 const V1_FEED_ID : ID = ID ( [
@@ -144,6 +145,10 @@ mod tests {
144145 00 , 05 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
145146 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
146147 ] ) ;
148+ const V6_FEED_ID : ID = ID ( [
149+ 00 , 06 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
150+ 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
151+ ] ) ;
147152 const V8_FEED_ID : ID = ID ( [
148153 00 , 08 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 ,
149154 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 ,
@@ -246,6 +251,24 @@ mod tests {
246251 report_data
247252 }
248253
254+ pub fn generate_mock_report_data_v6 ( ) -> ReportDataV6 {
255+ let report_data = ReportDataV6 {
256+ feed_id : V6_FEED_ID ,
257+ valid_from_timestamp : MOCK_TIMESTAMP ,
258+ observations_timestamp : MOCK_TIMESTAMP ,
259+ native_fee : BigInt :: from ( MOCK_FEE ) ,
260+ link_fee : BigInt :: from ( MOCK_FEE ) ,
261+ expires_at : MOCK_TIMESTAMP + 100 ,
262+ price : BigInt :: from ( MOCK_PRICE ) ,
263+ price2 : BigInt :: from ( MOCK_PRICE + 10 ) ,
264+ price3 : BigInt :: from ( MOCK_PRICE + 20 ) ,
265+ price4 : BigInt :: from ( MOCK_PRICE + 30 ) ,
266+ price5 : BigInt :: from ( MOCK_PRICE + 40 ) ,
267+ } ;
268+
269+ report_data
270+ }
271+
249272 pub fn generate_mock_report_data_v8 ( ) -> ReportDataV8 {
250273 let report_data = ReportDataV8 {
251274 feed_id : V8_FEED_ID ,
@@ -495,6 +518,39 @@ mod tests {
495518 assert_eq ! ( decoded_report. feed_id, V5_FEED_ID ) ;
496519 }
497520
521+ #[ test]
522+ fn test_decode_report_v6 ( ) {
523+ let report_data = generate_mock_report_data_v6 ( ) ;
524+ let encoded_report_data = report_data. abi_encode ( ) . unwrap ( ) ;
525+
526+ let report = generate_mock_report ( & encoded_report_data) ;
527+
528+ let ( _report_context, report_blob) = decode_full_report ( & report) . unwrap ( ) ;
529+
530+ let expected_report_blob = vec ! [
531+ "00066b4aa7e57ca7b68ae1bf45653f56b656fd3aa335ef7fae696b663f1b8472" ,
532+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
533+ "0000000000000000000000000000000000000000000000000000000066741d8c" ,
534+ "000000000000000000000000000000000000000000000000000000000000000a" ,
535+ "000000000000000000000000000000000000000000000000000000000000000a" ,
536+ "0000000000000000000000000000000000000000000000000000000066741df0" ,
537+ "0000000000000000000000000000000000000000000000000000000000000064" , // Price: 100
538+ "000000000000000000000000000000000000000000000000000000000000006e" , // Price2: 110
539+ "0000000000000000000000000000000000000000000000000000000000000078" , // Price3: 120
540+ "0000000000000000000000000000000000000000000000000000000000000082" , // Price4: 130
541+ "000000000000000000000000000000000000000000000000000000000000008c" , // Price5: 140
542+ ] ;
543+
544+ assert_eq ! (
545+ report_blob,
546+ bytes( & format!( "0x{}" , expected_report_blob. join( "" ) ) )
547+ ) ;
548+
549+ let decoded_report = ReportDataV6 :: decode ( & report_blob) . unwrap ( ) ;
550+
551+ assert_eq ! ( decoded_report. feed_id, V6_FEED_ID ) ;
552+ }
553+
498554 #[ test]
499555 fn test_decode_report_v8 ( ) {
500556 let report_data = generate_mock_report_data_v8 ( ) ;
0 commit comments