lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

comment_authority.rs (18480B)


      1 use super::CommentOperationExpectation;
      2 
      3 pub(super) const COMMENT_CONFORMANCE_VECTOR_RELATIVE: &str =
      4     "contracts/conformance/vectors/comment/verified_profile.v1.json";
      5 
      6 pub(super) const REQUIRED_COMMENT_PUBLIC_TYPES: [&str; 26] = [
      7     "Nip01EventWireParts",
      8     "EventEnvelope",
      9     "RadrootsSignatureVerifiedEvent",
     10     "NostrRelayHint",
     11     "Nip22CommentError",
     12     "Nip22CommentRootKind",
     13     "Nip22EventRootReference",
     14     "Nip22AddressRootReference",
     15     "Nip22CommentParentReference",
     16     "Nip22CommentRoot",
     17     "Nip22CommentPosition",
     18     "AuthoredNip22Comment",
     19     "RadrootsNip22CommentDiagnostic",
     20     "RadrootsInboundNip22Participant",
     21     "RadrootsInboundNip22EventRoot",
     22     "RadrootsInboundNip22AddressRoot",
     23     "RadrootsInboundNip22CommentRoot",
     24     "RadrootsInboundNip22CommentParent",
     25     "RadrootsInboundNip22CurrentRevision",
     26     "RadrootsInboundNip22TopLevelEventReference",
     27     "RadrootsInboundNip22TopLevelAddressReference",
     28     "RadrootsInboundNip22CommentPosition",
     29     "RadrootsInboundNip22CommentProjection",
     30     "RadrootsNip22CommentProjectionError",
     31     "RadrootsAdmittedNip22CommentEvent",
     32     "RadrootsNip22CommentAdmissionError",
     33 ];
     34 
     35 pub(super) const COMMENT_OPERATION_EXPECTATIONS: [CommentOperationExpectation; 3] = [
     36     CommentOperationExpectation {
     37         key: "social_comment_build_authored_draft",
     38         id: "social.comment.build_authored_draft",
     39         inputs: &["AuthoredNip22Comment"],
     40         outputs: &["Nip01EventWireParts"],
     41         error_class: "encode_error",
     42         signing: "none",
     43         rust_modules: &[
     44             "crates/event/src/comment.rs",
     45             "crates/event/src/relay_hint.rs",
     46             "crates/event_codec/src/comment/authored.rs",
     47         ],
     48         rust_types: &[
     49             "radroots_event::post::comment::AuthoredNip22Comment",
     50             "radroots_event::post::comment::Nip22AddressRootReference",
     51             "radroots_event::post::comment::Nip22CommentError",
     52             "radroots_event::post::comment::Nip22CommentParentReference",
     53             "radroots_event::post::comment::Nip22CommentPosition",
     54             "radroots_event::post::comment::Nip22CommentRoot",
     55             "radroots_event::post::comment::Nip22CommentRootKind",
     56             "radroots_event::post::comment::Nip22EventRootReference",
     57             "radroots_event::tag::relay_hint::NostrRelayHint",
     58             "radroots_event::wire::Nip01EventWireParts",
     59         ],
     60         case_kinds: &[
     61             "social.comment.build_authored_draft.valid",
     62             "social.comment.build_authored_draft.invalid",
     63         ],
     64     },
     65     CommentOperationExpectation {
     66         key: "social_comment_project_verified_event",
     67         id: "social.comment.project_verified_event",
     68         inputs: &["RadrootsSignatureVerifiedEvent"],
     69         outputs: &["RadrootsInboundNip22CommentProjection"],
     70         error_class: "parse_error",
     71         signing: "none",
     72         rust_modules: &[
     73             "crates/event_codec/src/comment/inbound.rs",
     74             "crates/event_codec/src/verification.rs",
     75         ],
     76         rust_types: &[
     77             "radroots_event_codec::decode::comment::RadrootsInboundNip22AddressRoot",
     78             "radroots_event_codec::decode::comment::RadrootsInboundNip22CommentParent",
     79             "radroots_event_codec::decode::comment::RadrootsInboundNip22CommentPosition",
     80             "radroots_event_codec::decode::comment::RadrootsInboundNip22CommentProjection",
     81             "radroots_event_codec::decode::comment::RadrootsInboundNip22CommentRoot",
     82             "radroots_event_codec::decode::comment::RadrootsInboundNip22CurrentRevision",
     83             "radroots_event_codec::decode::comment::RadrootsInboundNip22EventRoot",
     84             "radroots_event_codec::decode::comment::RadrootsInboundNip22Participant",
     85             "radroots_event_codec::decode::comment::RadrootsInboundNip22TopLevelAddressReference",
     86             "radroots_event_codec::decode::comment::RadrootsInboundNip22TopLevelEventReference",
     87             "radroots_event_codec::decode::comment::RadrootsNip22CommentDiagnostic",
     88             "radroots_event_codec::decode::comment::RadrootsNip22CommentProjectionError",
     89             "radroots_event_codec::verify::RadrootsSignatureVerifiedEvent",
     90         ],
     91         case_kinds: &[
     92             "social.comment.project_verified_event.valid",
     93             "social.comment.project_verified_event.invalid",
     94         ],
     95     },
     96     CommentOperationExpectation {
     97         key: "social_comment_verify_and_admit_event",
     98         id: "social.comment.verify_and_admit_event",
     99         inputs: &["EventEnvelope"],
    100         outputs: &["RadrootsAdmittedNip22CommentEvent"],
    101         error_class: "admission_error",
    102         signing: "nip01",
    103         rust_modules: &[
    104             "crates/event_codec/src/comment/admission.rs",
    105             "crates/event_codec/src/comment/inbound.rs",
    106             "crates/event_codec/src/verification.rs",
    107         ],
    108         rust_types: &[
    109             "radroots_event::envelope::EventEnvelope",
    110             "radroots_event_codec::admission::comment::RadrootsAdmittedNip22CommentEvent",
    111             "radroots_event_codec::admission::comment::RadrootsNip22CommentAdmissionError",
    112             "radroots_event_codec::decode::comment::RadrootsInboundNip22CommentProjection",
    113             "radroots_event_codec::decode::comment::RadrootsNip22CommentProjectionError",
    114             "radroots_event_codec::verify::RadrootsSignatureVerifiedEvent",
    115         ],
    116         case_kinds: &[
    117             "social.comment.verify_and_admit_event.valid",
    118             "social.comment.verify_and_admit_event.invalid",
    119         ],
    120     },
    121 ];
    122 
    123 pub(super) const COMMENT_CASE_KINDS: [&str; 6] = [
    124     "social.comment.build_authored_draft.valid",
    125     "social.comment.build_authored_draft.invalid",
    126     "social.comment.project_verified_event.valid",
    127     "social.comment.project_verified_event.invalid",
    128     "social.comment.verify_and_admit_event.valid",
    129     "social.comment.verify_and_admit_event.invalid",
    130 ];
    131 
    132 pub(super) const COMMENT_VECTOR_EXPECTATIONS: [(&str, &str); 114] = [
    133     (
    134         "authored_top_event_listing",
    135         "social.comment.build_authored_draft.valid",
    136     ),
    137     (
    138         "authored_top_event_date",
    139         "social.comment.build_authored_draft.valid",
    140     ),
    141     (
    142         "authored_top_event_time",
    143         "social.comment.build_authored_draft.valid",
    144     ),
    145     (
    146         "authored_top_address_listing",
    147         "social.comment.build_authored_draft.valid",
    148     ),
    149     (
    150         "authored_top_address_date",
    151         "social.comment.build_authored_draft.valid",
    152     ),
    153     (
    154         "authored_top_address_time",
    155         "social.comment.build_authored_draft.valid",
    156     ),
    157     (
    158         "authored_nested_event_listing",
    159         "social.comment.build_authored_draft.valid",
    160     ),
    161     (
    162         "authored_nested_event_date",
    163         "social.comment.build_authored_draft.valid",
    164     ),
    165     (
    166         "authored_nested_event_time",
    167         "social.comment.build_authored_draft.valid",
    168     ),
    169     (
    170         "authored_nested_address_listing",
    171         "social.comment.build_authored_draft.valid",
    172     ),
    173     (
    174         "authored_nested_address_date",
    175         "social.comment.build_authored_draft.valid",
    176     ),
    177     (
    178         "authored_nested_address_time",
    179         "social.comment.build_authored_draft.valid",
    180     ),
    181     (
    182         "authored_blank_content",
    183         "social.comment.build_authored_draft.invalid",
    184     ),
    185     (
    186         "authored_kind_one_root",
    187         "social.comment.build_authored_draft.invalid",
    188     ),
    189     (
    190         "authored_kind_comment_root",
    191         "social.comment.build_authored_draft.invalid",
    192     ),
    193     (
    194         "authored_invalid_event_id",
    195         "social.comment.build_authored_draft.invalid",
    196     ),
    197     (
    198         "authored_invalid_author",
    199         "social.comment.build_authored_draft.invalid",
    200     ),
    201     (
    202         "authored_invalid_coordinate",
    203         "social.comment.build_authored_draft.invalid",
    204     ),
    205     (
    206         "authored_invalid_current_revision",
    207         "social.comment.build_authored_draft.invalid",
    208     ),
    209     (
    210         "authored_parent_matches_root",
    211         "social.comment.build_authored_draft.invalid",
    212     ),
    213     (
    214         "authored_relay_uppercase_scheme",
    215         "social.comment.build_authored_draft.invalid",
    216     ),
    217     (
    218         "authored_relay_zero_port",
    219         "social.comment.build_authored_draft.invalid",
    220     ),
    221     (
    222         "authored_relay_lower_percent",
    223         "social.comment.build_authored_draft.invalid",
    224     ),
    225     (
    226         "authored_escaped_wire_overflow",
    227         "social.comment.build_authored_draft.invalid",
    228     ),
    229     (
    230         "project_signed_top_event",
    231         "social.comment.project_verified_event.valid",
    232     ),
    233     (
    234         "project_signed_top_address",
    235         "social.comment.project_verified_event.valid",
    236     ),
    237     (
    238         "project_signed_nested_event",
    239         "social.comment.project_verified_event.valid",
    240     ),
    241     (
    242         "project_signed_nested_address",
    243         "social.comment.project_verified_event.valid",
    244     ),
    245     (
    246         "project_unordered_top_event",
    247         "social.comment.project_verified_event.valid",
    248     ),
    249     (
    250         "project_unordered_top_address",
    251         "social.comment.project_verified_event.valid",
    252     ),
    253     (
    254         "project_supplemental_unknown_tag",
    255         "social.comment.project_verified_event.valid",
    256     ),
    257     (
    258         "project_supplemental_q_tag",
    259         "social.comment.project_verified_event.valid",
    260     ),
    261     (
    262         "project_additional_participant",
    263         "social.comment.project_verified_event.valid",
    264     ),
    265     (
    266         "project_duplicate_participant",
    267         "social.comment.project_verified_event.valid",
    268     ),
    269     (
    270         "project_malformed_participant",
    271         "social.comment.project_verified_event.valid",
    272     ),
    273     (
    274         "project_invalid_root_relay",
    275         "social.comment.project_verified_event.valid",
    276     ),
    277     (
    278         "project_invalid_root_participant_relay",
    279         "social.comment.project_verified_event.valid",
    280     ),
    281     (
    282         "project_invalid_parent_relay",
    283         "social.comment.project_verified_event.valid",
    284     ),
    285     (
    286         "project_malformed_root_author_hint",
    287         "social.comment.project_verified_event.valid",
    288     ),
    289     (
    290         "project_malformed_parent_author_hint",
    291         "social.comment.project_verified_event.valid",
    292     ),
    293     (
    294         "project_missing_nested_author_hint",
    295         "social.comment.project_verified_event.valid",
    296     ),
    297     (
    298         "project_distinct_relay_hints",
    299         "social.comment.project_verified_event.valid",
    300     ),
    301     (
    302         "project_invalid_address_root_relay",
    303         "social.comment.project_verified_event.valid",
    304     ),
    305     (
    306         "project_invalid_address_reference_relay",
    307         "social.comment.project_verified_event.valid",
    308     ),
    309     (
    310         "project_invalid_revision_relay",
    311         "social.comment.project_verified_event.valid",
    312     ),
    313     (
    314         "project_invalid_participant_relay",
    315         "social.comment.project_verified_event.valid",
    316     ),
    317     (
    318         "project_malformed_participant_shape",
    319         "social.comment.project_verified_event.valid",
    320     ),
    321     (
    322         "project_tag_count_exact",
    323         "social.comment.project_verified_event.valid",
    324     ),
    325     (
    326         "project_tag_element_count_exact",
    327         "social.comment.project_verified_event.valid",
    328     ),
    329     (
    330         "project_wrong_kind",
    331         "social.comment.project_verified_event.invalid",
    332     ),
    333     (
    334         "project_blank_content",
    335         "social.comment.project_verified_event.invalid",
    336     ),
    337     (
    338         "project_mixed_root",
    339         "social.comment.project_verified_event.invalid",
    340     ),
    341     (
    342         "project_duplicate_root",
    343         "social.comment.project_verified_event.invalid",
    344     ),
    345     (
    346         "project_duplicate_K",
    347         "social.comment.project_verified_event.invalid",
    348     ),
    349     (
    350         "project_missing_P",
    351         "social.comment.project_verified_event.invalid",
    352     ),
    353     (
    354         "project_unsupported_K",
    355         "social.comment.project_verified_event.invalid",
    356     ),
    357     (
    358         "project_padded_K",
    359         "social.comment.project_verified_event.invalid",
    360     ),
    361     (
    362         "project_plus_K",
    363         "social.comment.project_verified_event.invalid",
    364     ),
    365     (
    366         "project_address_K_mismatch",
    367         "social.comment.project_verified_event.invalid",
    368     ),
    369     (
    370         "project_invalid_P",
    371         "social.comment.project_verified_event.invalid",
    372     ),
    373     (
    374         "project_address_P_mismatch",
    375         "social.comment.project_verified_event.invalid",
    376     ),
    377     (
    378         "project_top_reference_mismatch",
    379         "social.comment.project_verified_event.invalid",
    380     ),
    381     (
    382         "project_top_hint_mismatch",
    383         "social.comment.project_verified_event.invalid",
    384     ),
    385     (
    386         "project_nested_parent_matches_root",
    387         "social.comment.project_verified_event.invalid",
    388     ),
    389     (
    390         "project_nested_missing_p",
    391         "social.comment.project_verified_event.invalid",
    392     ),
    393     (
    394         "project_nested_ambiguous_p",
    395         "social.comment.project_verified_event.invalid",
    396     ),
    397     (
    398         "project_address_missing_a",
    399         "social.comment.project_verified_event.invalid",
    400     ),
    401     (
    402         "project_revision_author_extra",
    403         "social.comment.project_verified_event.invalid",
    404     ),
    405     (
    406         "project_event_reference_extra",
    407         "social.comment.project_verified_event.invalid",
    408     ),
    409     (
    410         "project_tag_count_overflow",
    411         "social.comment.project_verified_event.invalid",
    412     ),
    413     (
    414         "project_tag_element_count_overflow",
    415         "social.comment.project_verified_event.invalid",
    416     ),
    417     (
    418         "project_external_root_form",
    419         "social.comment.project_verified_event.invalid",
    420     ),
    421     (
    422         "project_external_parent_form",
    423         "social.comment.project_verified_event.invalid",
    424     ),
    425     (
    426         "admit_signed_top_event",
    427         "social.comment.verify_and_admit_event.valid",
    428     ),
    429     (
    430         "admit_signed_top_address",
    431         "social.comment.verify_and_admit_event.valid",
    432     ),
    433     (
    434         "admit_signed_nested_event",
    435         "social.comment.verify_and_admit_event.valid",
    436     ),
    437     (
    438         "admit_signed_nested_address",
    439         "social.comment.verify_and_admit_event.valid",
    440     ),
    441     (
    442         "admit_invalid_signature",
    443         "social.comment.verify_and_admit_event.invalid",
    444     ),
    445     (
    446         "admit_id_mismatch",
    447         "social.comment.verify_and_admit_event.invalid",
    448     ),
    449     (
    450         "admit_invalid_shape",
    451         "social.comment.verify_and_admit_event.invalid",
    452     ),
    453     (
    454         "admit_wrong_kind",
    455         "social.comment.verify_and_admit_event.invalid",
    456     ),
    457     (
    458         "nip22_comment_u001c_is_content",
    459         "social.comment.build_authored_draft.valid",
    460     ),
    461     (
    462         "comment_nbsp_blank_content",
    463         "social.comment.build_authored_draft.invalid",
    464     ),
    465     (
    466         "inbound_nip22_u001c_is_content",
    467         "social.comment.project_verified_event.valid",
    468     ),
    469     (
    470         "inbound_comment_nbsp_blank_content",
    471         "social.comment.project_verified_event.invalid",
    472     ),
    473     (
    474         "authored_content_bytes_exact",
    475         "social.comment.build_authored_draft.valid",
    476     ),
    477     (
    478         "authored_content_bytes_overflow",
    479         "social.comment.build_authored_draft.invalid",
    480     ),
    481     (
    482         "project_content_bytes_exact",
    483         "social.comment.project_verified_event.valid",
    484     ),
    485     (
    486         "project_content_bytes_overflow",
    487         "social.comment.project_verified_event.invalid",
    488     ),
    489     (
    490         "project_tag_element_bytes_exact",
    491         "social.comment.project_verified_event.valid",
    492     ),
    493     (
    494         "project_tag_element_bytes_overflow",
    495         "social.comment.project_verified_event.invalid",
    496     ),
    497     (
    498         "project_tag_bytes_exact",
    499         "social.comment.project_verified_event.valid",
    500     ),
    501     (
    502         "project_tag_bytes_overflow",
    503         "social.comment.project_verified_event.invalid",
    504     ),
    505     (
    506         "project_event_wire_bytes_exact",
    507         "social.comment.project_verified_event.valid",
    508     ),
    509     (
    510         "project_event_wire_bytes_overflow",
    511         "social.comment.project_verified_event.invalid",
    512     ),
    513     (
    514         "project_root_event_id_invalid",
    515         "social.comment.project_verified_event.invalid",
    516     ),
    517     (
    518         "project_root_coordinate_invalid",
    519         "social.comment.project_verified_event.invalid",
    520     ),
    521     (
    522         "project_parent_kind_missing",
    523         "social.comment.project_verified_event.invalid",
    524     ),
    525     (
    526         "project_parent_kind_noncanonical",
    527         "social.comment.project_verified_event.invalid",
    528     ),
    529     (
    530         "project_parent_reference_shape",
    531         "social.comment.project_verified_event.invalid",
    532     ),
    533     (
    534         "project_parent_event_id_invalid",
    535         "social.comment.project_verified_event.invalid",
    536     ),
    537     (
    538         "project_parent_coordinate_invalid",
    539         "social.comment.project_verified_event.invalid",
    540     ),
    541     (
    542         "project_revision_missing",
    543         "social.comment.project_verified_event.invalid",
    544     ),
    545     (
    546         "project_revision_event_id_invalid",
    547         "social.comment.project_verified_event.invalid",
    548     ),
    549     (
    550         "project_parent_author_mismatch",
    551         "social.comment.project_verified_event.invalid",
    552     ),
    553     (
    554         "project_content_budget_precedes_missing_authority",
    555         "social.comment.project_verified_event.invalid",
    556     ),
    557     (
    558         "project_tag_count_budget_precedes_missing_authority",
    559         "social.comment.project_verified_event.invalid",
    560     ),
    561     (
    562         "project_tag_element_count_budget_precedes_missing_authority",
    563         "social.comment.project_verified_event.invalid",
    564     ),
    565     (
    566         "project_tag_element_budget_precedes_missing_authority",
    567         "social.comment.project_verified_event.invalid",
    568     ),
    569     (
    570         "project_tag_bytes_budget_precedes_missing_authority",
    571         "social.comment.project_verified_event.invalid",
    572     ),
    573     (
    574         "project_event_wire_budget_precedes_missing_authority",
    575         "social.comment.project_verified_event.invalid",
    576     ),
    577     (
    578         "authored_invalid_parent_event_id",
    579         "social.comment.build_authored_draft.invalid",
    580     ),
    581     (
    582         "authored_invalid_parent_author",
    583         "social.comment.build_authored_draft.invalid",
    584     ),
    585     (
    586         "authored_relay_element_bytes_overflow",
    587         "social.comment.build_authored_draft.invalid",
    588     ),
    589 ];