lib

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

error_contract.rs (8706B)


      1 use radroots_transport::Error;
      2 
      3 #[test]
      4 fn every_transport_error_has_stable_operator_facing_text() {
      5     let cases = [
      6         (
      7             Error::UnsupportedOperation,
      8             "transport operation is unsupported",
      9         ),
     10         (Error::EmptyTransportKind, "transport kind is empty"),
     11         (Error::InvalidTransportKind, "transport kind is invalid"),
     12         (Error::EmptyTargetUri, "transport target URI is empty"),
     13         (Error::InvalidTargetUri, "transport target URI is invalid"),
     14         (Error::EmptyTargetScope, "transport target scope is empty"),
     15         (
     16             Error::InvalidTargetScope,
     17             "transport target scope is invalid",
     18         ),
     19         (Error::EmptyTargetLabel, "transport target label is empty"),
     20         (
     21             Error::InvalidTargetLabel,
     22             "transport target label is invalid",
     23         ),
     24         (Error::EmptyTargetSet, "transport target set is empty"),
     25         (
     26             Error::TargetSetTooLarge,
     27             "transport target set exceeds its item limit",
     28         ),
     29         (
     30             Error::DuplicateTargetFingerprint,
     31             "transport target set contains duplicate fingerprints",
     32         ),
     33         (
     34             Error::InvalidTargetFingerprint,
     35             "transport target fingerprint is invalid",
     36         ),
     37         (
     38             Error::EmptyFetchRequestId,
     39             "transport fetch request id is empty",
     40         ),
     41         (
     42             Error::InvalidFetchRequestId,
     43             "transport fetch request id is invalid",
     44         ),
     45         (Error::InvalidFetchLimit, "transport fetch limit is invalid"),
     46         (
     47             Error::InvalidFetchDeadline,
     48             "transport fetch deadline is invalid",
     49         ),
     50         (
     51             Error::FetchSelectorTooLarge,
     52             "transport fetch selector exceeds its item limit",
     53         ),
     54         (
     55             Error::DuplicateFetchKind,
     56             "transport fetch selector contains a duplicate event kind",
     57         ),
     58         (
     59             Error::DuplicateFetchAuthor,
     60             "transport fetch selector contains a duplicate author",
     61         ),
     62         (
     63             Error::InvalidFetchTagKey,
     64             "transport fetch selector tag key is invalid",
     65         ),
     66         (
     67             Error::InvalidFetchTagValue,
     68             "transport fetch selector tag value is invalid",
     69         ),
     70         (
     71             Error::DuplicateFetchTagValue,
     72             "transport fetch selector contains a duplicate tag value",
     73         ),
     74         (
     75             Error::InvalidFetchTimeRange,
     76             "transport fetch selector time range is invalid",
     77         ),
     78         (Error::EmptyFetchCursor, "transport fetch cursor is empty"),
     79         (
     80             Error::InvalidFetchCursor,
     81             "transport fetch cursor is invalid",
     82         ),
     83         (
     84             Error::InvalidObservedAt,
     85             "transport event observation time is invalid",
     86         ),
     87         (
     88             Error::UnexpectedFetchEvent,
     89             "transport fetch page contains an event outside its selector",
     90         ),
     91         (
     92             Error::UnexpectedFetchProvenance,
     93             "transport fetch page contains unexpected event provenance",
     94         ),
     95         (
     96             Error::UnexpectedFetchTargetOutcome,
     97             "transport fetch page contains an unexpected target outcome",
     98         ),
     99         (
    100             Error::DuplicateFetchTargetOutcome,
    101             "transport fetch page contains a duplicate target outcome",
    102         ),
    103         (
    104             Error::FetchPageLimitExceeded,
    105             "transport fetch page exceeds its requested event limit",
    106         ),
    107         (
    108             Error::FetchPageRequestMismatch,
    109             "transport fetch page does not match its request",
    110         ),
    111         (
    112             Error::EmptySubscriptionRequestId,
    113             "transport subscription request id is empty",
    114         ),
    115         (
    116             Error::InvalidSubscriptionRequestId,
    117             "transport subscription request id is invalid",
    118         ),
    119         (
    120             Error::InvalidSubscriptionLimit,
    121             "transport subscription event limit is invalid",
    122         ),
    123         (
    124             Error::InvalidSubscriptionDeadline,
    125             "transport subscription deadline is invalid",
    126         ),
    127         (
    128             Error::SubscriptionCheckpointSetTooLarge,
    129             "transport subscription checkpoint set exceeds its target limit",
    130         ),
    131         (
    132             Error::UnexpectedSubscriptionCheckpoint,
    133             "transport subscription contains an unexpected checkpoint",
    134         ),
    135         (
    136             Error::DuplicateSubscriptionCheckpoint,
    137             "transport subscription contains a duplicate checkpoint",
    138         ),
    139         (
    140             Error::UnexpectedSubscriptionEvent,
    141             "transport subscription contains an unexpected event",
    142         ),
    143         (
    144             Error::SubscriptionEventCheckpointMismatch,
    145             "transport subscription event checkpoint does not match provenance",
    146         ),
    147         (
    148             Error::SubscriptionEndLimitExceeded,
    149             "transport subscription exceeded its requested event limit",
    150         ),
    151         (
    152             Error::InvalidSubscriptionEnd,
    153             "transport subscription terminal result is invalid",
    154         ),
    155         (
    156             Error::SubscriptionEndRequestMismatch,
    157             "transport subscription result does not match its request",
    158         ),
    159         (
    160             Error::SubscriptionUnavailable,
    161             "transport subscription is unavailable",
    162         ),
    163         (
    164             Error::InvalidSatisfactionPolicy,
    165             "transport satisfaction policy is invalid",
    166         ),
    167         (
    168             Error::EmptyRequiredTargetSet,
    169             "transport required target set is empty",
    170         ),
    171         (
    172             Error::DuplicateRequiredTargetFingerprint,
    173             "transport required target set contains duplicate fingerprints",
    174         ),
    175         (
    176             Error::RequiredTargetNotRequested,
    177             "transport required target was not requested",
    178         ),
    179         (
    180             Error::EmptyDeliveryRequestId,
    181             "transport delivery request id is empty",
    182         ),
    183         (
    184             Error::InvalidDeliveryRequestId,
    185             "transport delivery request id is invalid",
    186         ),
    187         (
    188             Error::InvalidDeliveryTimestamp,
    189             "transport delivery timestamp is invalid",
    190         ),
    191         (
    192             Error::InvalidDeliveryDeadline,
    193             "transport delivery deadline is invalid",
    194         ),
    195         (
    196             Error::InvalidDeliveryOutcome,
    197             "transport delivery outcome is invalid",
    198         ),
    199         (
    200             Error::UnexpectedDeliveryTargetReceipt,
    201             "transport delivery receipt contains an unexpected target",
    202         ),
    203         (
    204             Error::DuplicateDeliveryTargetReceipt,
    205             "transport delivery receipt contains a duplicate target",
    206         ),
    207         (
    208             Error::MissingDeliveryTargetReceipt,
    209             "transport delivery receipt is missing a requested target",
    210         ),
    211         (
    212             Error::DeliveryTargetReceiptStatusMismatch,
    213             "transport delivery target receipt status does not match its outcome",
    214         ),
    215         (
    216             Error::DeliveryTargetReceiptAttemptMismatch,
    217             "transport delivery target receipt attempt evidence is incoherent",
    218         ),
    219         (
    220             Error::TransportOutcomeStatusMismatch,
    221             "transport outcome status does not match its outcome kind",
    222         ),
    223         (
    224             Error::DeliveryReceiptRequestIdMismatch,
    225             "transport delivery receipt request id does not match its request",
    226         ),
    227         (
    228             Error::DeliveryReceiptTargetSetMismatch,
    229             "transport delivery receipt target set does not match its request",
    230         ),
    231         (Error::EmptyPayloadId, "transport payload id is empty"),
    232         (Error::InvalidPayloadId, "transport payload id is invalid"),
    233         (Error::EmptyPayloadLabel, "transport payload label is empty"),
    234         (
    235             Error::InvalidPayloadLabel,
    236             "transport payload label is invalid",
    237         ),
    238         (
    239             Error::EmptyPayloadBytes,
    240             "transport payload bytes are empty",
    241         ),
    242         (
    243             Error::InvalidPayloadBytes,
    244             "transport payload bytes are invalid",
    245         ),
    246         (
    247             Error::InvalidPayloadDigest,
    248             "transport payload digest is invalid",
    249         ),
    250         (
    251             Error::PayloadDigestMismatch,
    252             "transport payload digest does not match payload bytes",
    253         ),
    254     ];
    255 
    256     for (error, expected) in cases {
    257         assert_eq!(error.to_string(), expected);
    258     }
    259 }