Licklider Transmission Protocol (CCSDS 734.1-B) for reliable DTN links
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

irmin: value-oriented Heap + Schema + Cursor with 4 backends

+44 -52
+44 -52
test/interop/python/test.ml
··· 64 64 let value = Int64.of_string row.value in 65 65 let encoded = Ltp.encode_sdnv value in 66 66 let got_hex = string_to_hex encoded in 67 - Alcotest.(check string) 68 - (row.name ^ ": encode") row.encoded_hex got_hex 67 + Alcotest.(check string) (row.name ^ ": encode") row.encoded_hex got_hex 69 68 70 69 let test_sdnv_decode row () = 71 70 let ref_bytes = hex_to_string row.encoded_hex in ··· 88 87 let test_segment_decode row () = 89 88 let ref_bytes = hex_to_string row.segment_hex in 90 89 match Ltp.decode_segment ref_bytes with 91 - | Error e -> 92 - Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 90 + | Error e -> Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 93 91 | Ok seg -> 94 92 (* Re-encode and compare to reference *) 95 93 let re_encoded = Ltp.encode_segment seg in 96 94 let got_hex = string_to_hex re_encoded in 97 95 Alcotest.(check string) 98 - (row.name ^ ": decode-reencode roundtrip") row.segment_hex got_hex 96 + (row.name ^ ": decode-reencode roundtrip") 97 + row.segment_hex got_hex 99 98 100 99 let test_segment_encode row () = 101 100 (* Decode the reference to get the segment, then encode and compare *) 102 101 let ref_bytes = hex_to_string row.segment_hex in 103 102 match Ltp.decode_segment ref_bytes with 104 - | Error e -> 105 - Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 103 + | Error e -> Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 106 104 | Ok seg -> 107 105 let encoded = Ltp.encode_segment seg in 108 106 let got_hex = string_to_hex encoded in 109 - Alcotest.(check string) (row.name ^ ": encode exact bytes") row.segment_hex got_hex 107 + Alcotest.(check string) 108 + (row.name ^ ": encode exact bytes") 109 + row.segment_hex got_hex 110 110 111 111 let test_segment_fields row () = 112 112 let ref_bytes = hex_to_string row.segment_hex in 113 113 match Ltp.decode_segment ref_bytes with 114 - | Error e -> 115 - Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 114 + | Error e -> Alcotest.failf "%s: decode failed: %a" row.name Ltp.pp_error e 116 115 | Ok seg -> ( 117 116 (* Verify key fields based on test vector name *) 118 117 match row.name with 119 - | "green_data_simple" -> 120 - Alcotest.(check bool) 121 - "is green" true (Ltp.is_green_segment seg); 122 - Alcotest.(check int64) 123 - "originator" 10L seg.session_id.originator; 124 - Alcotest.(check int64) 125 - "session number" 1000L seg.session_id.number; 126 - (match seg.content with 118 + | "green_data_simple" -> ( 119 + Alcotest.(check bool) "is green" true (Ltp.is_green_segment seg); 120 + Alcotest.(check int64) "originator" 10L seg.session_id.originator; 121 + Alcotest.(check int64) "session number" 1000L seg.session_id.number; 122 + match seg.content with 127 123 | Ltp.Data ds -> 128 - Alcotest.(check int64) 129 - "client_service_id" 1L ds.client_service_id; 124 + Alcotest.(check int64) "client_service_id" 1L ds.client_service_id; 130 125 Alcotest.(check int64) "block_offset" 0L ds.block_offset; 131 - Alcotest.(check string) 132 - "data" "Hello, LTP!" ds.data 126 + Alcotest.(check string) "data" "Hello, LTP!" ds.data 133 127 | _ -> Alcotest.fail "expected Data content") 134 - | "green_eob" -> 128 + | "green_eob" -> ( 135 129 Alcotest.(check bool) "is eob" true (Ltp.is_eob seg); 136 - Alcotest.(check bool) 137 - "is green" true (Ltp.is_green_segment seg); 138 - (match seg.content with 130 + Alcotest.(check bool) "is green" true (Ltp.is_green_segment seg); 131 + match seg.content with 139 132 | Ltp.Data ds -> 140 133 Alcotest.(check int64) "block_offset" 512L ds.block_offset 141 134 | _ -> Alcotest.fail "expected Data content") 142 - | "red_checkpoint" -> 143 - Alcotest.(check bool) 144 - "is checkpoint" true (Ltp.is_checkpoint seg); 145 - Alcotest.(check bool) 146 - "is red" true (Ltp.is_red_segment seg); 147 - (match seg.content with 135 + | "red_checkpoint" -> ( 136 + Alcotest.(check bool) "is checkpoint" true (Ltp.is_checkpoint seg); 137 + Alcotest.(check bool) "is red" true (Ltp.is_red_segment seg); 138 + match seg.content with 148 139 | Ltp.Data ds -> 149 140 Alcotest.(check (option int64)) 150 141 "checkpoint_serial" (Some 5L) ds.checkpoint_serial; ··· 152 143 "report_serial" (Some 0L) ds.report_serial; 153 144 Alcotest.(check string) "data" "checkpoint data" ds.data 154 145 | _ -> Alcotest.fail "expected Data content") 155 - | "red_checkpoint_eorp_eob" -> 146 + | "red_checkpoint_eorp_eob" -> ( 156 147 Alcotest.(check bool) "is eorp" true (Ltp.is_eorp seg); 157 148 Alcotest.(check bool) "is eob" true (Ltp.is_eob seg); 158 - (match seg.content with 149 + match seg.content with 159 150 | Ltp.Data ds -> 160 151 Alcotest.(check int64) "block_offset" 256L ds.block_offset; 161 152 Alcotest.(check (option int64)) ··· 164 155 "report_serial" (Some 2L) ds.report_serial; 165 156 Alcotest.(check string) "data" "final red" ds.data 166 157 | _ -> Alcotest.fail "expected Data content") 167 - | "report_two_claims" -> 168 - (match seg.content with 158 + | "report_two_claims" -> ( 159 + match seg.content with 169 160 | Ltp.Report rs -> 170 161 Alcotest.(check int64) "report_serial" 7L rs.report_serial; 171 - Alcotest.(check int64) 172 - "checkpoint_serial" 5L rs.checkpoint_serial; 162 + Alcotest.(check int64) "checkpoint_serial" 5L rs.checkpoint_serial; 173 163 Alcotest.(check int64) "upper_bound" 1024L rs.upper_bound; 174 164 Alcotest.(check int64) "lower_bound" 0L rs.lower_bound; 175 165 Alcotest.(check int) "claims" 2 (List.length rs.claims); ··· 180 170 Alcotest.(check int64) "claim1.offset" 600L c1.offset; 181 171 Alcotest.(check int64) "claim1.length" 200L c1.length 182 172 | _ -> Alcotest.fail "expected Report content") 183 - | "report_large_offsets" -> 184 - (match seg.content with 173 + | "report_large_offsets" -> ( 174 + match seg.content with 185 175 | Ltp.Report rs -> 186 176 Alcotest.(check int64) "upper_bound" 100000L rs.upper_bound; 187 177 Alcotest.(check int64) "lower_bound" 50000L rs.lower_bound; ··· 190 180 Alcotest.(check int64) "claim0.offset" 50000L c0.offset; 191 181 Alcotest.(check int64) "claim0.length" 50000L c0.length 192 182 | _ -> Alcotest.fail "expected Report content") 193 - | "report_ack" -> 194 - (match seg.content with 183 + | "report_ack" -> ( 184 + match seg.content with 195 185 | Ltp.Report_ack ra -> 196 186 Alcotest.(check int64) "report_serial" 7L ra.report_serial 197 187 | _ -> Alcotest.fail "expected Report_ack content") 198 - | "cancel_sender_rlexc" -> 188 + | "cancel_sender_rlexc" -> ( 199 189 Alcotest.(check int) 200 190 "segment_type" 12 201 191 (Ltp.segment_type_to_int seg.segment_type); 202 - (match seg.content with 192 + match seg.content with 203 193 | Ltp.Cancel cs -> 204 194 Alcotest.(check int) 205 - "reason" 2 (Ltp.cancel_reason_to_int cs.reason) 195 + "reason" 2 196 + (Ltp.cancel_reason_to_int cs.reason) 206 197 | _ -> Alcotest.fail "expected Cancel content") 207 - | "cancel_receiver_user" -> 198 + | "cancel_receiver_user" -> ( 208 199 Alcotest.(check int) 209 200 "segment_type" 14 210 201 (Ltp.segment_type_to_int seg.segment_type); 211 - (match seg.content with 202 + match seg.content with 212 203 | Ltp.Cancel cs -> 213 204 Alcotest.(check int) 214 - "reason" 0 (Ltp.cancel_reason_to_int cs.reason) 205 + "reason" 0 206 + (Ltp.cancel_reason_to_int cs.reason) 215 207 | _ -> Alcotest.fail "expected Cancel content") 216 - | "cancel_ack_to_sender" -> 208 + | "cancel_ack_to_sender" -> ( 217 209 Alcotest.(check int) 218 210 "segment_type" 13 219 211 (Ltp.segment_type_to_int seg.segment_type); 220 - (match seg.content with 212 + match seg.content with 221 213 | Ltp.Cancel_ack () -> () 222 214 | _ -> Alcotest.fail "expected Cancel_ack content") 223 - | "cancel_ack_to_receiver" -> 215 + | "cancel_ack_to_receiver" -> ( 224 216 Alcotest.(check int) 225 217 "segment_type" 15 226 218 (Ltp.segment_type_to_int seg.segment_type); 227 - (match seg.content with 219 + match seg.content with 228 220 | Ltp.Cancel_ack () -> () 229 221 | _ -> Alcotest.fail "expected Cancel_ack content") 230 222 | name -> Alcotest.failf "unknown test vector: %s" name)