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 / synapse / core / test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note protocol/synapse/core/test.om: comprehensive behavioral test suite for all 5 Synapse core modules |
| 3 | note (changeset, graph, lease, review, ledger) covering positive paths and every negative/refusal control. |
| 4 | note Composed OM-2 test unit (compose after si/directives/om2.om, om/tls/sha2.om, and core modules). |
| 5 | |
| 6 | global g_tst_cnt ulong 8 |
| 7 | |
| 8 | text tt_pass "PASS " |
| 9 | text tt_fail "FAIL " |
| 10 | text tt_nl "\n" |
| 11 | text tt_sum1 "SYNAPSE-CORE-TEST PASS checks=" |
| 12 | text tt_sum2 "SYNAPSE-CORE-TEST FAIL checks=" |
| 13 | text tt_sumf " failures=" |
| 14 | |
| 15 | note test fixtures |
| 16 | text tf_alice "alice" |
| 17 | text tf_bob "bob" |
| 18 | text tf_carol "carol" |
| 19 | text tf_main "main" |
| 20 | text tf_feat1 "feat-1" |
| 21 | text tf_feat2 "feat-2" |
| 22 | text tf_featd "feat-div" |
| 23 | text tf_featr "feat-rej" |
| 24 | text tf_pa "src/a.om" |
| 25 | text tf_pb "src/b.om" |
| 26 | text tf_palpha "src/alpha.om" |
| 27 | text tf_pbeta "src/beta.om" |
| 28 | text tf_pshared "src/shared.om" |
| 29 | text tf_pdir "pkg/mod" |
| 30 | text tf_psub "pkg/mod/sub.om" |
| 31 | text tf_psib "pkg/mod2/sub.om" |
| 32 | text tf_pcore "src/core" |
| 33 | text tf_pcoref "src/core/graph.om" |
| 34 | text tf_pcoref2 "src/core/graph.om" |
| 35 | text tf_bad1 "/abs/file.om" |
| 36 | text tf_bad2 "dir/trail/" |
| 37 | text tf_bad3 "a//b.om" |
| 38 | text tf_bad4 "a/../b.om" |
| 39 | text tf_bad5 "a/./b.om" |
| 40 | text tf_bad6 ".git/config" |
| 41 | text tf_sum "core change" |
| 42 | text tf_lb1 "branch:feat-x" |
| 43 | text tf_lp1 "path:src/core" |
| 44 | text tf_lp2 "path:src/core/graph.om" |
| 45 | text tf_lp3 "path:src" |
| 46 | text tf_lp4 "path:src/core/*" |
| 47 | text tf_lp5 "path:src/core2/x.om" |
| 48 | text tf_lbad "invalid:target" |
| 49 | text tf_fmerged "MERGED" |
| 50 | |
| 51 | text tn_cs_ser "changeset.canonical_bytes_match_direct_sha256" |
| 52 | text tn_cs_det "changeset.canonical_sha256_deterministic_across_path_order" |
| 53 | text tn_cs_uniq "changeset.distinct_content_distinct_digest" |
| 54 | text tn_cs_pval "changeset.invalid_and_duplicate_paths_refused" |
| 55 | text tn_cs_ov "changeset.exact_prefix_and_sibling_path_overlap" |
| 56 | text tn_cs_st "changeset.state_machine_forward_and_refusals" |
| 57 | |
| 58 | text tn_gr_anc "graph.parent_child_and_ancestry_reachability" |
| 59 | text tn_gr_lca "graph.lowest_common_ancestor_merge_base" |
| 60 | text tn_gr_cyc "graph.cycle_and_self_parent_refused" |
| 61 | text tn_gr_conf "graph.concurrent_branch_disjoint_exact_prefix_conflicts" |
| 62 | |
| 63 | text tn_ls_ov "lease.overlapping_branch_and_path_refused_status_2" |
| 64 | text tn_ls_ren "lease.renewal_holder_only_and_extends_ttl" |
| 65 | text tn_ls_exp "lease.expired_lease_reclaimable_and_renew_refused" |
| 66 | text tn_ls_rel "lease.explicit_release_final_status_and_reclaim" |
| 67 | |
| 68 | text tn_rv_self "review.self_review_refused" |
| 69 | text tn_rv_blk "review.unreviewed_and_changes_requested_and_reject_block_land" |
| 70 | text tn_rv_inv "review.new_head_invalidates_prior_verdicts_and_stale_head_refused" |
| 71 | text tn_rv_land "review.exact_head_merge_and_fast_forward_land_advances_main" |
| 72 | text tn_rv_nff "review.non_fast_forward_land_refused_never_automerges" |
| 73 | |
| 74 | text tn_lg_ok "ledger.hash_chain_records_all_transitions_and_verifies" |
| 75 | text tn_lg_t1 "ledger.tampered_subject_caught" |
| 76 | text tn_lg_t2 "ledger.tampered_prev_hash_caught" |
| 77 | text tn_lg_t3 "ledger.tampered_entry_hash_caught" |
| 78 | text tn_lg_t4 "ledger.tampered_seq_caught" |
| 79 | |
| 80 | fn tst_check cond bool label view uchar * to void |
| 81 | put g_tst_cnt 0 add get g_tst_cnt 0 1 |
| 82 | if cond |
| 83 | syn_write_text 1 tt_pass |
| 84 | syn_write_text 1 label |
| 85 | syn_write_text 1 tt_nl |
| 86 | else |
| 87 | put g_tst_cnt 1 add get g_tst_cnt 1 1 |
| 88 | syn_write_text 1 tt_fail |
| 89 | syn_write_text 1 label |
| 90 | syn_write_text 1 tt_nl |
| 91 | end |
| 92 | end |
| 93 | |
| 94 | fn tst_set_par pidx ulong to void |
| 95 | put g_tst_cnt 2 pidx |
| 96 | end |
| 97 | |
| 98 | fn tst_next_ts to ulong |
| 99 | t = add get g_tst_cnt 3 1 |
| 100 | put g_tst_cnt 3 t |
| 101 | ret t |
| 102 | end |
| 103 | |
| 104 | fn tst_cs_add auth view uchar * br view uchar * pth view uchar * to ulong |
| 105 | pid = new uchar 32 0 |
| 106 | rc = cs_stage_begin auth br tst_next_ts |
| 107 | if ne rc SYN_OK |
| 108 | ret SYN_NONE |
| 109 | end |
| 110 | pidx = get g_tst_cnt 2 |
| 111 | if ne pidx SYN_NONE |
| 112 | cs_get_id pidx pid |
| 113 | rc = cs_stage_set_parent pid |
| 114 | if ne rc SYN_OK |
| 115 | ret SYN_NONE |
| 116 | end |
| 117 | end |
| 118 | rc = cs_stage_add_path pth |
| 119 | if ne rc SYN_OK |
| 120 | ret SYN_NONE |
| 121 | end |
| 122 | rc = cs_stage_commit |
| 123 | if ne rc SYN_OK |
| 124 | ret SYN_NONE |
| 125 | end |
| 126 | ret cs_last_idx |
| 127 | end |
| 128 | |
| 129 | note ======== Suite 1: changeset.om ======== |
| 130 | |
| 131 | fn tst_cs_digest_checks to void |
| 132 | id1 = new uchar 32 0 |
| 133 | id2 = new uchar 32 0 |
| 134 | ser = new uchar 1024 0 |
| 135 | dig = new uchar 32 0 |
| 136 | syn_reset_all |
| 137 | ok = eq cs_stage_begin tf_alice tf_feat1 1000 SYN_OK |
| 138 | ok = and ok eq cs_stage_set_summary tf_sum SYN_OK |
| 139 | ok = and ok eq cs_stage_add_path tf_pb SYN_OK |
| 140 | ok = and ok eq cs_stage_add_path tf_pa SYN_OK |
| 141 | ok = and ok eq cs_stage_commit SYN_OK |
| 142 | i1 = cs_last_idx |
| 143 | cs_get_id i1 id1 |
| 144 | slen = cs_canonical_serialize i1 ser |
| 145 | dl = sha2_digest 256 part ser 0 slen dig |
| 146 | ok = and ok and eq dl 32 syn_digest_eq id1 dig |
| 147 | tst_check ok tn_cs_ser |
| 148 | |
| 149 | syn_reset_all |
| 150 | ok = eq cs_stage_begin tf_alice tf_feat1 1000 SYN_OK |
| 151 | ok = and ok eq cs_stage_set_summary tf_sum SYN_OK |
| 152 | ok = and ok eq cs_stage_add_path tf_pa SYN_OK |
| 153 | ok = and ok eq cs_stage_add_path tf_pb SYN_OK |
| 154 | ok = and ok eq cs_stage_commit SYN_OK |
| 155 | cs_get_id cs_last_idx id2 |
| 156 | ok = and ok syn_digest_eq id1 id2 |
| 157 | tst_check ok tn_cs_det |
| 158 | |
| 159 | ok = eq cs_stage_begin tf_bob tf_feat1 1000 SYN_OK |
| 160 | ok = and ok eq cs_stage_set_summary tf_sum SYN_OK |
| 161 | ok = and ok eq cs_stage_add_path tf_pa SYN_OK |
| 162 | ok = and ok eq cs_stage_add_path tf_pb SYN_OK |
| 163 | ok = and ok eq cs_stage_commit SYN_OK |
| 164 | cs_get_id cs_last_idx dig |
| 165 | ok = and ok eq syn_digest_eq id2 dig false |
| 166 | tst_check ok tn_cs_uniq |
| 167 | end |
| 168 | |
| 169 | fn tst_cs_path_and_state_checks to void |
| 170 | syn_reset_all |
| 171 | ok = eq cs_path_valid tf_bad1 false |
| 172 | ok = and ok eq cs_path_valid tf_bad2 false |
| 173 | ok = and ok eq cs_path_valid tf_bad3 false |
| 174 | ok = and ok eq cs_path_valid tf_bad4 false |
| 175 | ok = and ok eq cs_path_valid tf_bad5 false |
| 176 | ok = and ok eq cs_path_valid tf_bad6 false |
| 177 | ok = and ok eq cs_stage_begin tf_alice tf_feat2 1001 SYN_OK |
| 178 | ok = and ok eq cs_stage_add_path tf_pa SYN_OK |
| 179 | ok = and ok eq cs_stage_add_path tf_pa SYN_ERR_DUPLICATE |
| 180 | tst_check ok tn_cs_pval |
| 181 | |
| 182 | ok = eq cs_paths_overlap_view tf_pcoref tf_pcoref2 1 |
| 183 | ok = and ok eq cs_paths_overlap_view tf_pcore tf_pcoref 2 |
| 184 | ok = and ok eq cs_paths_overlap_view tf_pcoref tf_pcore 2 |
| 185 | ok = and ok eq cs_paths_overlap_view tf_pdir tf_psub 2 |
| 186 | ok = and ok eq cs_paths_overlap_view tf_pdir tf_psib 0 |
| 187 | tst_check ok tn_cs_ov |
| 188 | |
| 189 | tst_set_par SYN_NONE |
| 190 | i1 = tst_cs_add tf_alice tf_feat1 tf_pa |
| 191 | i2 = tst_cs_add tf_bob tf_feat2 tf_pb |
| 192 | ok = eq cs_get_state i1 CS_STATE_DRAFT |
| 193 | ok = and ok eq cs_transition i1 CS_STATE_LANDED 1010 SYN_ERR_STATE_INVALID |
| 194 | ok = and ok eq cs_transition i1 CS_STATE_PROPOSED 1011 SYN_OK |
| 195 | ok = and ok eq cs_transition i1 CS_STATE_DRAFT 1012 SYN_ERR_STATE_INVALID |
| 196 | ok = and ok eq cs_transition i1 CS_STATE_REVIEWED 1013 SYN_OK |
| 197 | ok = and ok eq cs_transition i1 CS_STATE_LANDED 1014 SYN_OK |
| 198 | ok = and ok eq cs_transition i1 CS_STATE_ABANDONED 1015 SYN_ERR_STATE_INVALID |
| 199 | ok = and ok eq cs_transition i2 CS_STATE_ABANDONED 1016 SYN_OK |
| 200 | ok = and ok eq cs_transition i2 CS_STATE_PROPOSED 1017 SYN_ERR_STATE_INVALID |
| 201 | tst_check ok tn_cs_st |
| 202 | end |
| 203 | |
| 204 | note ======== Suite 2: graph.om ======== |
| 205 | |
| 206 | fn tst_graph_suite to void |
| 207 | syn_reset_all |
| 208 | put g_tst_cnt 3 2000 |
| 209 | tst_set_par SYN_NONE |
| 210 | root = tst_cs_add tf_alice tf_main tf_pa |
| 211 | tst_set_par root |
| 212 | a1 = tst_cs_add tf_alice tf_feat1 tf_palpha |
| 213 | tst_set_par a1 |
| 214 | a2 = tst_cs_add tf_alice tf_feat1 tf_pcore |
| 215 | tst_set_par root |
| 216 | b1 = tst_cs_add tf_bob tf_feat2 tf_pbeta |
| 217 | tst_set_par b1 |
| 218 | b2 = tst_cs_add tf_bob tf_feat2 tf_psib |
| 219 | tst_set_par a1 |
| 220 | c1 = tst_cs_add tf_carol tf_featd tf_pcoref |
| 221 | |
| 222 | ok = and eq gr_child_count root 2 eq gr_child_count a1 2 |
| 223 | ok = and ok and eq gr_parent_count a2 1 eq gr_parent_at a2 0 a1 |
| 224 | ok = and ok gr_is_ancestor root a2 |
| 225 | ok = and ok gr_is_ancestor a1 c1 |
| 226 | ok = and ok gr_is_ancestor a2 a2 |
| 227 | ok = and ok eq gr_is_ancestor a2 root false |
| 228 | ok = and ok eq gr_is_ancestor a2 b2 false |
| 229 | tst_check ok tn_gr_anc |
| 230 | |
| 231 | ok = eq gr_lca a2 b2 root |
| 232 | ok = and ok eq gr_lca a2 c1 a1 |
| 233 | ok = and ok eq gr_lca a1 a2 a1 |
| 234 | ok = and ok eq gr_lca b1 c1 root |
| 235 | tst_check ok tn_gr_lca |
| 236 | |
| 237 | ok = eq gr_link_parent root a2 SYN_ERR_CYCLE |
| 238 | ok = and ok eq gr_link_parent a1 a1 SYN_ERR_CYCLE |
| 239 | ok = and ok eq gr_link_parent a1 c1 SYN_ERR_CYCLE |
| 240 | ok = and ok eq gr_parent_count root 0 |
| 241 | tst_check ok tn_gr_cyc |
| 242 | |
| 243 | ok = eq gr_branches_conflict a2 b2 0 |
| 244 | ok = and ok eq gr_branches_conflict a1 a2 0 |
| 245 | ok = and ok eq gr_branches_conflict a2 c1 2 |
| 246 | tst_set_par root |
| 247 | x1 = tst_cs_add tf_alice tf_feat1 tf_pshared |
| 248 | tst_set_par root |
| 249 | x2 = tst_cs_add tf_bob tf_feat2 tf_pshared |
| 250 | ok = and ok eq gr_branches_conflict x1 x2 1 |
| 251 | ok = and ok and eq gr_conflict_cs_a x1 eq gr_conflict_cs_b x2 |
| 252 | tst_set_par root |
| 253 | x1 = tst_cs_add tf_alice tf_feat1 tf_pdir |
| 254 | tst_set_par root |
| 255 | x2 = tst_cs_add tf_bob tf_feat2 tf_psub |
| 256 | ok = and ok eq gr_branches_conflict x1 x2 2 |
| 257 | tst_check ok tn_gr_conf |
| 258 | end |
| 259 | |
| 260 | note ======== Suite 3: lease.om ======== |
| 261 | |
| 262 | fn tst_lease_suite to void |
| 263 | syn_reset_all |
| 264 | ok = eq ls_claim tf_alice tf_lb1 100 50 SYN_OK |
| 265 | lid_br = ls_last_id |
| 266 | ok = and ok eq ls_claim tf_alice tf_lp1 100 50 SYN_OK |
| 267 | lid_pa = ls_last_id |
| 268 | ok = and ok eq ls_claim tf_bob tf_lb1 110 50 SYN_ERR_LEASE_CONFLICT |
| 269 | cidx = ls_conflict_idx |
| 270 | if ne cidx SYN_NONE |
| 271 | ok = and ok syn_arena_eq_view ls_holder_off cidx ls_holder_len cidx tf_alice |
| 272 | else |
| 273 | ok = false |
| 274 | end |
| 275 | ok = and ok eq ls_claim tf_bob tf_lp2 110 50 SYN_ERR_LEASE_CONFLICT |
| 276 | ok = and ok eq ls_claim tf_bob tf_lp3 110 50 SYN_ERR_LEASE_CONFLICT |
| 277 | ok = and ok eq ls_claim tf_bob tf_lp4 110 50 SYN_ERR_LEASE_CONFLICT |
| 278 | ok = and ok eq ls_claim tf_bob tf_lp5 110 50 SYN_OK |
| 279 | ok = and ok eq ls_claim tf_bob tf_lbad 110 50 SYN_ERR_MALFORMED |
| 280 | tst_check ok tn_ls_ov |
| 281 | |
| 282 | ok = eq ls_renew lid_br tf_bob 120 60 SYN_ERR_NOT_HOLDER |
| 283 | ok = and ok eq ls_renew lid_br tf_alice 140 60 SYN_OK |
| 284 | ok = and ok eq ls_claim tf_bob tf_lb1 160 30 SYN_ERR_LEASE_CONFLICT |
| 285 | tst_check ok tn_ls_ren |
| 286 | |
| 287 | ok = eq ls_is_active lid_pa 160 false |
| 288 | ok = and ok eq ls_renew lid_pa tf_alice 160 50 SYN_ERR_LEASE_CLOSED |
| 289 | ok = and ok eq ls_claim tf_bob tf_lp1 160 50 SYN_OK |
| 290 | tst_check ok tn_ls_exp |
| 291 | |
| 292 | ok = eq ls_release lid_br tf_bob tf_fmerged 170 SYN_ERR_NOT_HOLDER |
| 293 | ok = and ok eq ls_release lid_br tf_alice tf_fmerged 170 SYN_OK |
| 294 | ok = and ok eq ls_release lid_br tf_alice tf_fmerged 171 SYN_ERR_LEASE_CLOSED |
| 295 | ok = and ok eq ls_claim tf_bob tf_lb1 171 40 SYN_OK |
| 296 | cidx = ls_find_by_id lid_br |
| 297 | if ne cidx SYN_NONE |
| 298 | ok = and ok syn_arena_eq_view ls_final_off cidx ls_final_len cidx tf_fmerged |
| 299 | else |
| 300 | ok = false |
| 301 | end |
| 302 | tst_check ok tn_ls_rel |
| 303 | end |
| 304 | |
| 305 | note ======== Suite 4: review.om ======== |
| 306 | |
| 307 | fn tst_review_suite to void |
| 308 | id1 = new uchar 32 0 |
| 309 | id2 = new uchar 32 0 |
| 310 | syn_reset_all |
| 311 | put g_tst_cnt 3 3000 |
| 312 | |
| 313 | tst_set_par SYN_NONE |
| 314 | root = tst_cs_add tf_alice tf_main tf_pa |
| 315 | ok = eq gr_branch_set tf_main root SYN_OK |
| 316 | tst_set_par root |
| 317 | cs1 = tst_cs_add tf_alice tf_feat1 tf_palpha |
| 318 | ok = and ok eq cs_transition cs1 CS_STATE_PROPOSED 3005 SYN_OK |
| 319 | cs_get_id cs1 id1 |
| 320 | |
| 321 | note 4a: self-review refused |
| 322 | ok = and ok eq rv_record id1 tf_alice RV_MERGE 3006 SYN_ERR_SELF_REVIEW |
| 323 | tst_check ok tn_rv_self |
| 324 | |
| 325 | note 4b: unreviewed blocked, CHANGES_REQUESTED blocks even with MERGE, REJECT blocks |
| 326 | ok = eq rv_land cs1 id1 3007 SYN_ERR_REVIEW_BLOCKED |
| 327 | ok = and ok eq rv_record id1 tf_carol RV_CHANGES_REQUESTED 3008 SYN_OK |
| 328 | ok = and ok eq rv_record id1 tf_bob RV_MERGE 3009 SYN_OK |
| 329 | ok = and ok eq rv_land cs1 id1 3010 SYN_ERR_REVIEW_BLOCKED |
| 330 | tst_set_par root |
| 331 | cs2 = tst_cs_add tf_alice tf_featr tf_pb |
| 332 | ok = and ok eq cs_transition cs2 CS_STATE_PROPOSED 3011 SYN_OK |
| 333 | cs_get_id cs2 id2 |
| 334 | ok = and ok eq rv_record id2 tf_bob RV_MERGE 3012 SYN_OK |
| 335 | ok = and ok eq rv_record id2 tf_carol RV_REJECT 3013 SYN_OK |
| 336 | ok = and ok eq rv_land cs2 id2 3014 SYN_ERR_REVIEW_BLOCKED |
| 337 | tst_check ok tn_rv_blk |
| 338 | |
| 339 | note 4c: new head on feat-1 invalidates cs1 verdicts; stale-head verdict refused |
| 340 | tst_set_par cs1 |
| 341 | cs2 = tst_cs_add tf_alice tf_feat1 tf_pcore |
| 342 | ok = eq cs_transition cs2 CS_STATE_PROPOSED 3020 SYN_OK |
| 343 | cs_get_id cs2 id2 |
| 344 | ok = and ok eq rv_valid_merge_count cs1 0 |
| 345 | ok = and ok eq rv_record id1 tf_bob RV_MERGE 3021 SYN_ERR_STALE_HEAD |
| 346 | rv_set_time 3022 |
| 347 | ok = and ok eq rv_record_bound cs2 id1 tf_bob RV_MERGE SYN_ERR_STALE_HEAD |
| 348 | ok = and ok eq rv_land cs2 id1 3023 SYN_ERR_STALE_HEAD |
| 349 | ok = and ok eq rv_land cs2 id2 3024 SYN_ERR_REVIEW_BLOCKED |
| 350 | tst_check ok tn_rv_inv |
| 351 | |
| 352 | note 4d: fresh exact-head MERGE + fast-forward from main -> LAND succeeds & advances main |
| 353 | ok = eq rv_record id2 tf_bob RV_MERGE 3030 SYN_OK |
| 354 | ok = and ok eq rv_land cs2 id2 3031 SYN_OK |
| 355 | ok = and ok eq cs_get_state cs2 CS_STATE_LANDED |
| 356 | ok = and ok eq gr_main_head cs2 |
| 357 | tst_check ok tn_rv_land |
| 358 | |
| 359 | note 4e: non-fast-forward land refused (never automerges!) |
| 360 | tst_set_par root |
| 361 | cs1 = tst_cs_add tf_bob tf_featd tf_pbeta |
| 362 | ok = eq cs_transition cs1 CS_STATE_PROPOSED 3040 SYN_OK |
| 363 | cs_get_id cs1 id1 |
| 364 | ok = and ok eq rv_record id1 tf_carol RV_MERGE 3041 SYN_OK |
| 365 | ok = and ok eq rv_land cs1 id1 3042 SYN_ERR_NON_FF |
| 366 | ok = and ok eq gr_main_head cs2 |
| 367 | tst_check ok tn_rv_nff |
| 368 | end |
| 369 | |
| 370 | note ======== Suite 5: ledger.om ======== |
| 371 | |
| 372 | fn tst_ledger_suite to void |
| 373 | id1 = new uchar 32 0 |
| 374 | syn_reset_all |
| 375 | put g_tst_cnt 3 4000 |
| 376 | |
| 377 | tst_set_par SYN_NONE |
| 378 | root = tst_cs_add tf_alice tf_main tf_pa |
| 379 | ok = eq gr_branch_set tf_main root SYN_OK |
| 380 | tst_set_par root |
| 381 | cs1 = tst_cs_add tf_alice tf_feat1 tf_pb |
| 382 | ok = and ok eq cs_transition cs1 CS_STATE_PROPOSED 4005 SYN_OK |
| 383 | cs_get_id cs1 id1 |
| 384 | ok = and ok eq ls_claim tf_alice tf_lb1 4006 100 SYN_OK |
| 385 | lid = ls_last_id |
| 386 | ok = and ok eq ls_renew lid tf_alice 4010 100 SYN_OK |
| 387 | ok = and ok eq rv_record id1 tf_bob RV_MERGE 4011 SYN_OK |
| 388 | ok = and ok eq rv_land cs1 id1 4012 SYN_OK |
| 389 | ok = and ok eq ls_release lid tf_alice tf_fmerged 4013 SYN_OK |
| 390 | ok = and ok eq lg_verify SYN_OK |
| 391 | ok = and ok ge lg_count 9 |
| 392 | tst_check ok tn_lg_ok |
| 393 | |
| 394 | lg_tamper_xor_subj 2 0 1 |
| 395 | ok = eq lg_verify SYN_ERR_LEDGER_TAMPER |
| 396 | ok = and ok eq lg_bad_seq 3 |
| 397 | lg_tamper_xor_subj 2 0 1 |
| 398 | ok = and ok eq lg_verify SYN_OK |
| 399 | tst_check ok tn_lg_t1 |
| 400 | |
| 401 | lg_tamper_xor_prev 3 5 1 |
| 402 | ok = eq lg_verify SYN_ERR_LEDGER_TAMPER |
| 403 | ok = and ok eq lg_bad_seq 4 |
| 404 | lg_tamper_xor_prev 3 5 1 |
| 405 | ok = and ok eq lg_verify SYN_OK |
| 406 | tst_check ok tn_lg_t2 |
| 407 | |
| 408 | lg_tamper_xor_hash 1 31 1 |
| 409 | ok = eq lg_verify SYN_ERR_LEDGER_TAMPER |
| 410 | ok = and ok eq lg_bad_seq 2 |
| 411 | lg_tamper_xor_hash 1 31 1 |
| 412 | ok = and ok eq lg_verify SYN_OK |
| 413 | tst_check ok tn_lg_t3 |
| 414 | |
| 415 | lg_tamper_set_seq 0 99 |
| 416 | ok = eq lg_verify SYN_ERR_LEDGER_TAMPER |
| 417 | ok = and ok eq lg_bad_seq 1 |
| 418 | lg_tamper_set_seq 0 1 |
| 419 | ok = and ok eq lg_verify SYN_OK |
| 420 | tst_check ok tn_lg_t4 |
| 421 | end |
| 422 | |
| 423 | fn main to int |
| 424 | put g_tst_cnt 0 0 |
| 425 | put g_tst_cnt 1 0 |
| 426 | put g_tst_cnt 2 SYN_NONE |
| 427 | put g_tst_cnt 3 1000 |
| 428 | tst_cs_digest_checks |
| 429 | tst_cs_path_and_state_checks |
| 430 | tst_graph_suite |
| 431 | tst_lease_suite |
| 432 | tst_review_suite |
| 433 | tst_ledger_suite |
| 434 | tot = get g_tst_cnt 0 |
| 435 | fails = get g_tst_cnt 1 |
| 436 | if eq fails 0 |
| 437 | syn_write_text 1 tt_sum1 |
| 438 | syn_write_u64 1 tot |
| 439 | syn_write_text 1 tt_sumf |
| 440 | syn_write_u64 1 fails |
| 441 | syn_write_text 1 tt_nl |
| 442 | ret 0 |
| 443 | end |
| 444 | syn_write_text 1 tt_sum2 |
| 445 | syn_write_u64 1 tot |
| 446 | syn_write_text 1 tt_sumf |
| 447 | syn_write_u64 1 fails |
| 448 | syn_write_text 1 tt_nl |
| 449 | ret 1 |
| 450 | end |