omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / protocol / aien-protocols / ext / test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note protocol/aien-protocols/ext/test.om: positive, negative & mutant control test suite |
| 3 | note for aien-protocols-mv extended crates (microjob, probe, evaluation-protocol, discovery-capsule). |
| 4 | note Compose with: |
| 5 | note si/directives/om2.om om/tls/sha2.om protocol/aien-protocols/core/types.om |
| 6 | note protocol/aien-protocols/ext/microjob.om protocol/aien-protocols/ext/probe.om |
| 7 | note protocol/aien-protocols/ext/evaluation.om protocol/aien-protocols/ext/discovery_capsule.om |
| 8 | note protocol/aien-protocols/ext/test.om |
| 9 | |
| 10 | text tx_pass "PASS " |
| 11 | text tx_fail "FAIL " |
| 12 | text tx_nl "\n" |
| 13 | |
| 14 | text tx_c1 "microjob_lifecycle_envelope_payout_and_receipt" |
| 15 | text tx_c2 "microjob_mutant_controls_flip_and_perturbation" |
| 16 | text tx_c3 "probe_request_attestation_and_sla_verdicts" |
| 17 | text tx_c4 "probe_mutant_controls_nonce_target_and_rtt" |
| 18 | text tx_c5 "evaluation_binding_scores_adaptive_and_replay" |
| 19 | text tx_c6 "evaluation_mutant_controls_seed_and_digest" |
| 20 | text tx_c7 "discovery_capsule_lifecycle_recipient_routing_and_digest" |
| 21 | text tx_c8 "discovery_capsule_mutant_controls_recip_and_ttl" |
| 22 | text tx_done "PASS aien-protocols-ext all 8 test suites passed (pos+neg+mutant)\n" |
| 23 | |
| 24 | text tx_target_ok "spark-node-01.aien.internal:8443" |
| 25 | text tx_target_sp "spark node 01" |
| 26 | text tx_target_mut "spark-node-02.aien.internal:8443" |
| 27 | |
| 28 | text tx_recip_did "did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH" |
| 29 | text tx_recip_rad "rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5" |
| 30 | text tx_recip_node "node:spark-gb10-primary" |
| 31 | text tx_recip_bad "http://evil.example/cap" |
| 32 | text tx_recip_short "did:1" |
| 33 | text tx_recip_sp "did:key:bad space" |
| 34 | text tx_recip_mut "did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktI" |
| 35 | |
| 36 | fn tx_report name view uchar * ok bool to int |
| 37 | if ok |
| 38 | w1 = pt_write_all int 1 tx_pass |
| 39 | w2 = pt_write_all int 1 name |
| 40 | w3 = pt_write_all int 1 tx_nl |
| 41 | if and w1 and w2 w3 |
| 42 | ret int 0 |
| 43 | end |
| 44 | ret int 1 |
| 45 | end |
| 46 | w4 = pt_write_all int 1 tx_fail |
| 47 | w5 = pt_write_all int 1 name |
| 48 | w6 = pt_write_all int 1 tx_nl |
| 49 | if and w4 and w5 w6 |
| 50 | ret int 1 |
| 51 | end |
| 52 | ret int 1 |
| 53 | end |
| 54 | |
| 55 | fn tx_fill_id dst edit uchar 16 v uchar to void |
| 56 | for i ulong 16 |
| 57 | put dst i v |
| 58 | end |
| 59 | end |
| 60 | |
| 61 | fn tx_fill_dig dst edit uchar 32 v uchar to void |
| 62 | for i ulong 32 |
| 63 | put dst i v |
| 64 | end |
| 65 | end |
| 66 | |
| 67 | fn test_microjob to bool |
| 68 | note Positive transitions |
| 69 | if ne mj_transition_check MJ_STAT_OPEN MJ_STAT_CLAIMED MJ_OK |
| 70 | ret false |
| 71 | end |
| 72 | if ne mj_transition_check MJ_STAT_CLAIMED MJ_STAT_SUBMITTED MJ_OK |
| 73 | ret false |
| 74 | end |
| 75 | if ne mj_transition_check MJ_STAT_SUBMITTED MJ_STAT_VERIFIED MJ_OK |
| 76 | ret false |
| 77 | end |
| 78 | if ne mj_transition_check MJ_STAT_VERIFIED MJ_STAT_SETTLED MJ_OK |
| 79 | ret false |
| 80 | end |
| 81 | note Negative transitions (skip state, backward, from terminal) |
| 82 | if ne mj_transition_check MJ_STAT_OPEN MJ_STAT_SETTLED MJ_ERR_BAD_STATE |
| 83 | ret false |
| 84 | end |
| 85 | if ne mj_transition_check MJ_STAT_SETTLED MJ_STAT_OPEN MJ_ERR_BAD_STATE |
| 86 | ret false |
| 87 | end |
| 88 | if ne mj_transition_check MJ_STAT_EXPIRED MJ_STAT_CLAIMED MJ_ERR_BAD_STATE |
| 89 | ret false |
| 90 | end |
| 91 | if ne mj_transition_check ulong 99 MJ_STAT_OPEN MJ_ERR_BAD_STATE |
| 92 | ret false |
| 93 | end |
| 94 | note Envelope + deadline + payout positive/negative |
| 95 | jid = new uchar 16 0 |
| 96 | nil_id = new uchar 16 0 |
| 97 | indig = new uchar 32 0 |
| 98 | outdig = new uchar 32 0 |
| 99 | zdig = new uchar 32 0 |
| 100 | tx_fill_id jid uchar 0x11 |
| 101 | tx_fill_dig indig uchar 0x22 |
| 102 | tx_fill_dig outdig uchar 0x33 |
| 103 | if ne mj_validate_envelope jid indig ulong 5000 ulong 60000 MJ_OK |
| 104 | ret false |
| 105 | end |
| 106 | if ne mj_validate_envelope nil_id indig ulong 5000 ulong 60000 MJ_ERR_BAD_ID |
| 107 | ret false |
| 108 | end |
| 109 | if ne mj_validate_envelope jid zdig ulong 5000 ulong 60000 MJ_ERR_DIGEST |
| 110 | ret false |
| 111 | end |
| 112 | if ne mj_validate_envelope jid indig ulong 0 ulong 60000 MJ_ERR_BUDGET |
| 113 | ret false |
| 114 | end |
| 115 | if ne mj_validate_envelope jid indig ulong 5000 ulong 0 MJ_ERR_TIMEOUT |
| 116 | ret false |
| 117 | end |
| 118 | if ne mj_check_deadline ulong 1000 ulong 5000 ulong 5000 MJ_OK |
| 119 | ret false |
| 120 | end |
| 121 | if ne mj_check_deadline ulong 1000 ulong 5000 ulong 5001 MJ_ERR_DEADLINE |
| 122 | ret false |
| 123 | end |
| 124 | if ne mj_check_deadline ulong 5000 ulong 5000 ulong 5000 MJ_ERR_DEADLINE |
| 125 | ret false |
| 126 | end |
| 127 | if ne mj_check_payout ulong 1000 ulong 850 ulong 50 ulong 100 MJ_OK |
| 128 | ret false |
| 129 | end |
| 130 | if ne mj_check_payout ulong 1000 ulong 850 ulong 50 ulong 101 MJ_ERR_PAYOUT |
| 131 | ret false |
| 132 | end |
| 133 | if ne mj_check_payout ulong 1000 ulong 1001 ulong 0 ulong 0 MJ_ERR_PAYOUT |
| 134 | ret false |
| 135 | end |
| 136 | note Deterministic job and receipt digests |
| 137 | d1 = new uchar 32 0 |
| 138 | d2 = new uchar 32 0 |
| 139 | mj_compute_digest jid indig ulong 5000 ulong 9000 d1 |
| 140 | mj_compute_digest jid indig ulong 5000 ulong 9000 d2 |
| 141 | if not digest_eq d1 d2 |
| 142 | ret false |
| 143 | end |
| 144 | rcpt = new uchar 32 0 |
| 145 | mj_compute_receipt_digest jid indig outdig rcpt |
| 146 | if ne mj_verify_receipt jid indig outdig rcpt MJ_OK |
| 147 | ret false |
| 148 | end |
| 149 | if ne mj_verify_receipt jid indig zdig rcpt MJ_ERR_DIGEST |
| 150 | ret false |
| 151 | end |
| 152 | ret true |
| 153 | end |
| 154 | |
| 155 | fn test_microjob_mutants to bool |
| 156 | jid = new uchar 16 0 |
| 157 | indig = new uchar 32 0 |
| 158 | outdig = new uchar 32 0 |
| 159 | rcpt = new uchar 32 0 |
| 160 | tx_fill_id jid uchar 0x11 |
| 161 | tx_fill_dig indig uchar 0x22 |
| 162 | tx_fill_dig outdig uchar 0x33 |
| 163 | mj_compute_receipt_digest jid indig outdig rcpt |
| 164 | note Mutant 1: flip 1 bit in receipt digest -> MUST fail |
| 165 | put rcpt 31 xor get rcpt 31 uchar 1 |
| 166 | if ne mj_verify_receipt jid indig outdig rcpt MJ_ERR_DIGEST |
| 167 | ret false |
| 168 | end |
| 169 | put rcpt 31 xor get rcpt 31 uchar 1 |
| 170 | note Mutant 2: flip 1 bit in output digest -> MUST fail |
| 171 | put outdig 0 xor get outdig 0 uchar 1 |
| 172 | if ne mj_verify_receipt jid indig outdig rcpt MJ_ERR_DIGEST |
| 173 | ret false |
| 174 | end |
| 175 | note Mutant 3: perturb payout conservation by +1 -> MUST fail |
| 176 | if ne mj_check_payout ulong 10000 ulong 9000 ulong 501 ulong 500 MJ_ERR_PAYOUT |
| 177 | ret false |
| 178 | end |
| 179 | note Mutant 4: perturb job digest reward by +1 -> MUST change digest |
| 180 | d1 = new uchar 32 0 |
| 181 | d2 = new uchar 32 0 |
| 182 | mj_compute_digest jid indig ulong 5000 ulong 9000 d1 |
| 183 | mj_compute_digest jid indig ulong 5001 ulong 9000 d2 |
| 184 | if digest_eq d1 d2 |
| 185 | ret false |
| 186 | end |
| 187 | ret true |
| 188 | end |
| 189 | |
| 190 | fn test_probe to bool |
| 191 | nonce = new uchar 16 0 |
| 192 | nil_n = new uchar 16 0 |
| 193 | tx_fill_id nonce uchar 0x44 |
| 194 | if ne prb_validate_request PRB_KIND_LATENCY tx_target_ok nonce ulong 5000 PRB_OK |
| 195 | ret false |
| 196 | end |
| 197 | if ne prb_validate_request ulong 0 tx_target_ok nonce ulong 5000 PRB_ERR_KIND |
| 198 | ret false |
| 199 | end |
| 200 | if ne prb_validate_request PRB_KIND_LATENCY tx_target_sp nonce ulong 5000 PRB_ERR_TARGET |
| 201 | ret false |
| 202 | end |
| 203 | if ne prb_validate_request PRB_KIND_LATENCY tx_target_ok nil_n ulong 5000 PRB_ERR_NONCE |
| 204 | ret false |
| 205 | end |
| 206 | if ne prb_validate_request PRB_KIND_LATENCY tx_target_ok nonce ulong 300001 PRB_ERR_TIMEOUT |
| 207 | ret false |
| 208 | end |
| 209 | note Attestation compute & verify |
| 210 | ctx1 = new ulong 40 0 |
| 211 | ctx2 = new ulong 40 0 |
| 212 | att = new uchar 32 0 |
| 213 | prb_attest_head ctx1 PRB_KIND_INTEGRITY tx_target_ok nonce |
| 214 | prb_attest_finish ctx1 ulong 0 ulong 1200 att |
| 215 | prb_attest_head ctx2 PRB_KIND_INTEGRITY tx_target_ok nonce |
| 216 | if ne prb_verify_attestation ctx2 ulong 0 ulong 1200 att PRB_OK |
| 217 | ret false |
| 218 | end |
| 219 | note SLA verdicts |
| 220 | if ne prb_classify_verdict ulong 0 ulong 1000 ulong 5000 ulong 10000 PRB_VERDICT_PASS |
| 221 | ret false |
| 222 | end |
| 223 | if ne prb_classify_verdict ulong 0 ulong 6000 ulong 5000 ulong 10000 PRB_VERDICT_DEGRADED |
| 224 | ret false |
| 225 | end |
| 226 | if ne prb_classify_verdict ulong 0 ulong 10001 ulong 5000 ulong 10000 PRB_VERDICT_TIMEOUT |
| 227 | ret false |
| 228 | end |
| 229 | if ne prb_classify_verdict ulong 500 ulong 1000 ulong 5000 ulong 10000 PRB_VERDICT_FAIL |
| 230 | ret false |
| 231 | end |
| 232 | if ne prb_classify_verdict ulong 0 ulong 1000 ulong 12000 ulong 10000 PRB_VERDICT_FAIL |
| 233 | ret false |
| 234 | end |
| 235 | ret true |
| 236 | end |
| 237 | |
| 238 | fn test_probe_mutants to bool |
| 239 | nonce = new uchar 16 0 |
| 240 | tx_fill_id nonce uchar 0x55 |
| 241 | ctx1 = new ulong 40 0 |
| 242 | att = new uchar 32 0 |
| 243 | prb_attest_head ctx1 PRB_KIND_INTEGRITY tx_target_ok nonce |
| 244 | prb_attest_finish ctx1 ulong 0 ulong 1200 att |
| 245 | note Mutant 1: mutated RTT (+1us) -> MUST reject attestation |
| 246 | ctx2 = new ulong 40 0 |
| 247 | prb_attest_head ctx2 PRB_KIND_INTEGRITY tx_target_ok nonce |
| 248 | if ne prb_verify_attestation ctx2 ulong 0 ulong 1201 att PRB_ERR_ATTEST |
| 249 | ret false |
| 250 | end |
| 251 | note Mutant 2: mutated target string -> MUST reject attestation |
| 252 | ctx3 = new ulong 40 0 |
| 253 | prb_attest_head ctx3 PRB_KIND_INTEGRITY tx_target_mut nonce |
| 254 | if ne prb_verify_attestation ctx3 ulong 0 ulong 1200 att PRB_ERR_ATTEST |
| 255 | ret false |
| 256 | end |
| 257 | note Mutant 3: flipped 1 bit in nonce -> MUST reject attestation |
| 258 | put nonce 0 xor get nonce 0 uchar 1 |
| 259 | ctx4 = new ulong 40 0 |
| 260 | prb_attest_head ctx4 PRB_KIND_INTEGRITY tx_target_ok nonce |
| 261 | if ne prb_verify_attestation ctx4 ulong 0 ulong 1200 att PRB_ERR_ATTEST |
| 262 | ret false |
| 263 | end |
| 264 | ret true |
| 265 | end |
| 266 | |
| 267 | fn test_evaluation to bool |
| 268 | eid = new uchar 16 0 |
| 269 | nil_id = new uchar 16 0 |
| 270 | mdig = new uchar 32 0 |
| 271 | ddig = new uchar 32 0 |
| 272 | zdig = new uchar 32 0 |
| 273 | bdig = new uchar 32 0 |
| 274 | tx_fill_id eid uchar 0x66 |
| 275 | tx_fill_dig mdig uchar 0x77 |
| 276 | tx_fill_dig ddig uchar 0x88 |
| 277 | ev_compute_binding eid mdig ddig ulong 42 bdig |
| 278 | if ne ev_verify_binding eid mdig ddig ulong 42 bdig EV_OK |
| 279 | ret false |
| 280 | end |
| 281 | if ne ev_verify_binding nil_id mdig ddig ulong 42 bdig EV_ERR_BINDING |
| 282 | ret false |
| 283 | end |
| 284 | if ne ev_verify_binding eid zdig ddig ulong 42 bdig EV_ERR_DIGEST |
| 285 | ret false |
| 286 | end |
| 287 | note Score validation |
| 288 | if ne ev_score_validate ulong 85 ulong 100 ulong 8500 EV_OK |
| 289 | ret false |
| 290 | end |
| 291 | if ne ev_score_validate ulong 85 ulong 100 ulong 8501 EV_ERR_SCORE_RANGE |
| 292 | ret false |
| 293 | end |
| 294 | if ne ev_score_validate ulong 101 ulong 100 ulong 10000 EV_ERR_SCORE_RANGE |
| 295 | ret false |
| 296 | end |
| 297 | if ne ev_score_validate ulong 0 ulong 0 ulong 0 EV_ERR_SAMPLE_COUNT |
| 298 | ret false |
| 299 | end |
| 300 | note Adaptive decisions: min=20 max=100 accept=9000 reject=5000 |
| 301 | if ne ev_adaptive_decide ulong 10 ulong 10 ulong 20 ulong 100 ulong 9000 ulong 5000 EV_DEC_CONTINUE |
| 302 | ret false |
| 303 | end |
| 304 | if ne ev_adaptive_decide ulong 19 ulong 20 ulong 20 ulong 100 ulong 9000 ulong 5000 EV_DEC_ACCEPT |
| 305 | ret false |
| 306 | end |
| 307 | if ne ev_adaptive_decide ulong 10 ulong 20 ulong 20 ulong 100 ulong 9000 ulong 5000 EV_DEC_REJECT |
| 308 | ret false |
| 309 | end |
| 310 | if ne ev_adaptive_decide ulong 75 ulong 100 ulong 20 ulong 100 ulong 9000 ulong 5000 EV_DEC_REJECT |
| 311 | ret false |
| 312 | end |
| 313 | if ne ev_adaptive_decide ulong 40 ulong 50 ulong 20 ulong 100 ulong 9000 ulong 5000 EV_DEC_CONTINUE |
| 314 | ret false |
| 315 | end |
| 316 | note Negative adaptive params: reject >= accept |
| 317 | if ne ev_adaptive_decide ulong 10 ulong 20 ulong 20 ulong 100 ulong 5000 ulong 5000 EV_DEC_INVALID |
| 318 | ret false |
| 319 | end |
| 320 | note Monotonic round replay guard |
| 321 | if ne ev_check_monotonic_round ulong 7 ulong 8 EV_OK |
| 322 | ret false |
| 323 | end |
| 324 | if ne ev_check_monotonic_round ulong 7 ulong 7 EV_ERR_REPLAY |
| 325 | ret false |
| 326 | end |
| 327 | if ne ev_check_monotonic_round ulong 7 ulong 9 EV_ERR_REPLAY |
| 328 | ret false |
| 329 | end |
| 330 | ret true |
| 331 | end |
| 332 | |
| 333 | fn test_evaluation_mutants to bool |
| 334 | eid = new uchar 16 0 |
| 335 | mdig = new uchar 32 0 |
| 336 | ddig = new uchar 32 0 |
| 337 | bdig = new uchar 32 0 |
| 338 | tx_fill_id eid uchar 0x66 |
| 339 | tx_fill_dig mdig uchar 0x77 |
| 340 | tx_fill_dig ddig uchar 0x88 |
| 341 | ev_compute_binding eid mdig ddig ulong 42 bdig |
| 342 | note Mutant 1: seed mutated 42 -> 43 -> MUST reject |
| 343 | if ne ev_verify_binding eid mdig ddig ulong 43 bdig EV_ERR_BINDING |
| 344 | ret false |
| 345 | end |
| 346 | note Mutant 2: model digest bit-flipped -> MUST reject |
| 347 | put mdig 15 xor get mdig 15 uchar 0x80 |
| 348 | if ne ev_verify_binding eid mdig ddig ulong 42 bdig EV_ERR_BINDING |
| 349 | ret false |
| 350 | end |
| 351 | put mdig 15 xor get mdig 15 uchar 0x80 |
| 352 | note Mutant 3: claimed binding bit-flipped -> MUST reject |
| 353 | put bdig 0 xor get bdig 0 uchar 1 |
| 354 | if ne ev_verify_binding eid mdig ddig ulong 42 bdig EV_ERR_BINDING |
| 355 | ret false |
| 356 | end |
| 357 | ret true |
| 358 | end |
| 359 | |
| 360 | fn test_discovery_capsule to bool |
| 361 | note Lifecycle state machine |
| 362 | if ne dc_transition_check DC_STATE_DRAFT DC_STATE_SEALED DC_OK |
| 363 | ret false |
| 364 | end |
| 365 | if ne dc_transition_check DC_STATE_SEALED DC_STATE_ROUTED DC_OK |
| 366 | ret false |
| 367 | end |
| 368 | if ne dc_transition_check DC_STATE_ROUTED DC_STATE_ROUTED DC_OK |
| 369 | ret false |
| 370 | end |
| 371 | if ne dc_transition_check DC_STATE_ROUTED DC_STATE_DELIVERED DC_OK |
| 372 | ret false |
| 373 | end |
| 374 | if ne dc_transition_check DC_STATE_DRAFT DC_STATE_DELIVERED DC_ERR_STATE |
| 375 | ret false |
| 376 | end |
| 377 | if ne dc_transition_check DC_STATE_DELIVERED DC_STATE_ROUTED DC_ERR_STATE |
| 378 | ret false |
| 379 | end |
| 380 | if ne dc_transition_check DC_STATE_REVOKED DC_STATE_SEALED DC_ERR_STATE |
| 381 | ret false |
| 382 | end |
| 383 | note Recipient validation |
| 384 | if ne dc_validate_recipient tx_recip_did DC_OK |
| 385 | ret false |
| 386 | end |
| 387 | if ne dc_validate_recipient tx_recip_rad DC_OK |
| 388 | ret false |
| 389 | end |
| 390 | if ne dc_validate_recipient tx_recip_node DC_OK |
| 391 | ret false |
| 392 | end |
| 393 | if ne dc_validate_recipient tx_recip_bad DC_ERR_RECIPIENT |
| 394 | ret false |
| 395 | end |
| 396 | if ne dc_validate_recipient tx_recip_short DC_ERR_RECIPIENT |
| 397 | ret false |
| 398 | end |
| 399 | if ne dc_validate_recipient tx_recip_sp DC_ERR_RECIPIENT |
| 400 | ret false |
| 401 | end |
| 402 | note Routing hops & TTL |
| 403 | if ne dc_check_routing ulong 3 ulong 8 ulong 1000 ulong 600 ulong 1500 DC_OK |
| 404 | ret false |
| 405 | end |
| 406 | if ne dc_check_routing ulong 9 ulong 8 ulong 1000 ulong 600 ulong 1500 DC_ERR_HOPS |
| 407 | ret false |
| 408 | end |
| 409 | if ne dc_check_routing ulong 1 ulong 17 ulong 1000 ulong 600 ulong 1500 DC_ERR_HOPS |
| 410 | ret false |
| 411 | end |
| 412 | if ne dc_check_routing ulong 1 ulong 8 ulong 1000 ulong 600 ulong 1601 DC_ERR_TTL |
| 413 | ret false |
| 414 | end |
| 415 | if ne dc_check_routing ulong 1 ulong 8 ulong 1000 ulong 600 ulong 999 DC_ERR_TTL |
| 416 | ret false |
| 417 | end |
| 418 | note Capsule validation & digest |
| 419 | cid = new uchar 16 0 |
| 420 | pdig = new uchar 32 0 |
| 421 | cdig = new uchar 32 0 |
| 422 | tx_fill_id cid uchar 0x99 |
| 423 | tx_fill_dig pdig uchar 0xaa |
| 424 | if ne dc_verify_capsule cid tx_recip_did pdig ulong 600 ulong 8 DC_OK |
| 425 | ret false |
| 426 | end |
| 427 | ctx1 = new ulong 40 0 |
| 428 | ctx2 = new ulong 40 0 |
| 429 | dc_hash_head ctx1 cid tx_recip_did pdig |
| 430 | dc_hash_finish ctx1 ulong 600 ulong 8 cdig |
| 431 | dc_hash_head ctx2 cid tx_recip_did pdig |
| 432 | if ne dc_verify_digest ctx2 ulong 600 ulong 8 cdig DC_OK |
| 433 | ret false |
| 434 | end |
| 435 | ret true |
| 436 | end |
| 437 | |
| 438 | fn test_discovery_capsule_mutants to bool |
| 439 | cid = new uchar 16 0 |
| 440 | pdig = new uchar 32 0 |
| 441 | cdig = new uchar 32 0 |
| 442 | tx_fill_id cid uchar 0x99 |
| 443 | tx_fill_dig pdig uchar 0xaa |
| 444 | ctx1 = new ulong 40 0 |
| 445 | dc_hash_head ctx1 cid tx_recip_did pdig |
| 446 | dc_hash_finish ctx1 ulong 600 ulong 8 cdig |
| 447 | note Mutant 1: recipient last char mutated H -> I -> MUST reject |
| 448 | ctx2 = new ulong 40 0 |
| 449 | dc_hash_head ctx2 cid tx_recip_mut pdig |
| 450 | if ne dc_verify_digest ctx2 ulong 600 ulong 8 cdig DC_ERR_DIGEST |
| 451 | ret false |
| 452 | end |
| 453 | note Mutant 2: TTL mutated 600 -> 601 -> MUST reject |
| 454 | ctx3 = new ulong 40 0 |
| 455 | dc_hash_head ctx3 cid tx_recip_did pdig |
| 456 | if ne dc_verify_digest ctx3 ulong 601 ulong 8 cdig DC_ERR_DIGEST |
| 457 | ret false |
| 458 | end |
| 459 | note Mutant 3: max_hops mutated 8 -> 9 -> MUST reject |
| 460 | ctx4 = new ulong 40 0 |
| 461 | dc_hash_head ctx4 cid tx_recip_did pdig |
| 462 | if ne dc_verify_digest ctx4 ulong 600 ulong 9 cdig DC_ERR_DIGEST |
| 463 | ret false |
| 464 | end |
| 465 | ret true |
| 466 | end |
| 467 | |
| 468 | fn main to int |
| 469 | fails = int 0 |
| 470 | fails = add fails tx_report tx_c1 test_microjob |
| 471 | fails = add fails tx_report tx_c2 test_microjob_mutants |
| 472 | fails = add fails tx_report tx_c3 test_probe |
| 473 | fails = add fails tx_report tx_c4 test_probe_mutants |
| 474 | fails = add fails tx_report tx_c5 test_evaluation |
| 475 | fails = add fails tx_report tx_c6 test_evaluation_mutants |
| 476 | fails = add fails tx_report tx_c7 test_discovery_capsule |
| 477 | fails = add fails tx_report tx_c8 test_discovery_capsule_mutants |
| 478 | if ne fails int 0 |
| 479 | ret int 1 |
| 480 | end |
| 481 | if not pt_write_all int 1 tx_done |
| 482 | ret int 1 |
| 483 | end |
| 484 | ret int 0 |
| 485 | end |