lib

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

parse_event.v1.json (6771B)


      1 {
      2   "suite": "operational_listing",
      3   "contract_version": "1.0.0",
      4   "vectors": [
      5     {
      6       "id": "operational_listing_tags_override_json_content_001",
      7       "kind": "operational_listing.parse_event.valid",
      8       "input": {
      9         "event_kind": 30402,
     10         "content": "{\"product\":{\"title\":\"Content override\",\"category\":\"Content category\"},\"inventory_available\":\"99\"}",
     11         "tags": [
     12           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
     13           ["p", "farm_pubkey"],
     14           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
     15           ["key", "sku"],
     16           ["title", "Widget"],
     17           ["category", "Tools"],
     18           ["radroots:primary_bin", "bin-1"],
     19           ["radroots:bin", "bin-1", "1", "each"],
     20           ["radroots:price", "bin-1", "10", "USD", "1", "each"],
     21           ["price", "10", "USD"]
     22         ]
     23       },
     24       "expected": {
     25         "listing": {
     26           "d_tag": "AAAAAAAAAAAAAAAAAAAAAg",
     27           "title": "Widget",
     28           "category": "Tools",
     29           "primary_bin_id": "bin-1",
     30           "quantity_amount": "1",
     31           "quantity_unit": "each",
     32           "price_amount": "10",
     33           "price_currency": "USD",
     34           "inventory_available": null
     35         }
     36       }
     37     },
     38     {
     39       "id": "operational_listing_missing_d_001",
     40       "kind": "operational_listing.parse_event.invalid",
     41       "input": {
     42         "event_kind": 30402,
     43         "content": "# Widget",
     44         "tags": [
     45           ["p", "farm_pubkey"],
     46           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
     47           ["key", "sku"],
     48           ["title", "Widget"],
     49           ["category", "Tools"],
     50           ["radroots:primary_bin", "bin-1"],
     51           ["radroots:bin", "bin-1", "1", "each"],
     52           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
     53         ]
     54       },
     55       "expected": {
     56         "error": {"MissingTag": "d"}
     57       }
     58     },
     59     {
     60       "id": "operational_listing_invalid_d_001",
     61       "kind": "operational_listing.parse_event.invalid",
     62       "input": {
     63         "event_kind": 30402,
     64         "content": "# Widget",
     65         "tags": [
     66           ["d", "bad d"],
     67           ["p", "farm_pubkey"],
     68           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
     69           ["key", "sku"],
     70           ["title", "Widget"],
     71           ["category", "Tools"],
     72           ["radroots:primary_bin", "bin-1"],
     73           ["radroots:bin", "bin-1", "1", "each"],
     74           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
     75         ]
     76       },
     77       "expected": {
     78         "error": {"InvalidTag": "d"}
     79       }
     80     },
     81     {
     82       "id": "operational_listing_invalid_number_001",
     83       "kind": "operational_listing.parse_event.invalid",
     84       "input": {
     85         "event_kind": 30402,
     86         "content": "# Widget",
     87         "tags": [
     88           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
     89           ["p", "farm_pubkey"],
     90           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
     91           ["key", "sku"],
     92           ["title", "Widget"],
     93           ["category", "Tools"],
     94           ["radroots:primary_bin", "bin-1"],
     95           ["radroots:bin", "bin-1", "bad", "each"],
     96           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
     97         ]
     98       },
     99       "expected": {
    100         "error": {"InvalidNumber": "radroots:bin"}
    101       }
    102     },
    103     {
    104       "id": "operational_listing_invalid_unit_001",
    105       "kind": "operational_listing.parse_event.invalid",
    106       "input": {
    107         "event_kind": 30402,
    108         "content": "# Widget",
    109         "tags": [
    110           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
    111           ["p", "farm_pubkey"],
    112           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
    113           ["key", "sku"],
    114           ["title", "Widget"],
    115           ["category", "Tools"],
    116           ["radroots:primary_bin", "bin-1"],
    117           ["radroots:bin", "bin-1", "1", "bad"],
    118           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
    119         ]
    120       },
    121       "expected": {
    122         "error": "InvalidUnit"
    123       }
    124     },
    125     {
    126       "id": "operational_listing_invalid_currency_001",
    127       "kind": "operational_listing.parse_event.invalid",
    128       "input": {
    129         "event_kind": 30402,
    130         "content": "# Widget",
    131         "tags": [
    132           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
    133           ["p", "farm_pubkey"],
    134           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
    135           ["key", "sku"],
    136           ["title", "Widget"],
    137           ["category", "Tools"],
    138           ["radroots:primary_bin", "bin-1"],
    139           ["radroots:bin", "bin-1", "1", "each"],
    140           ["radroots:price", "bin-1", "10", "US", "1", "each"]
    141         ]
    142       },
    143       "expected": {
    144         "error": "InvalidCurrency"
    145       }
    146     },
    147     {
    148       "id": "operational_listing_invalid_discount_001",
    149       "kind": "operational_listing.parse_event.invalid",
    150       "input": {
    151         "event_kind": 30402,
    152         "content": "# Widget",
    153         "tags": [
    154           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
    155           ["p", "farm_pubkey"],
    156           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
    157           ["key", "sku"],
    158           ["title", "Widget"],
    159           ["category", "Tools"],
    160           ["radroots:primary_bin", "bin-1"],
    161           ["radroots:bin", "bin-1", "1", "each"],
    162           ["radroots:price", "bin-1", "10", "USD", "1", "each"],
    163           ["radroots:discount", "{"]
    164         ]
    165       },
    166       "expected": {
    167         "error": {"InvalidDiscount": "radroots:discount"}
    168       }
    169     },
    170     {
    171       "id": "operational_listing_private_json_location_001",
    172       "kind": "operational_listing.parse_event.invalid",
    173       "input": {
    174         "event_kind": 30402,
    175         "content": "{\"location\":{\"coordinates\":[1,2]}}",
    176         "tags": [
    177           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
    178           ["p", "farm_pubkey"],
    179           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
    180           ["key", "sku"],
    181           ["title", "Widget"],
    182           ["category", "Tools"],
    183           ["radroots:primary_bin", "bin-1"],
    184           ["radroots:bin", "bin-1", "1", "each"],
    185           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
    186         ]
    187       },
    188       "expected": {
    189         "error": {"InvalidJson": "location"}
    190       }
    191     },
    192     {
    193       "id": "operational_listing_invalid_kind_001",
    194       "kind": "operational_listing.parse_event.invalid",
    195       "input": {
    196         "event_kind": 0,
    197         "content": "# Widget",
    198         "tags": [
    199           ["d", "AAAAAAAAAAAAAAAAAAAAAg"],
    200           ["p", "farm_pubkey"],
    201           ["a", "30340:farm_pubkey:AAAAAAAAAAAAAAAAAAAAAA"],
    202           ["key", "sku"],
    203           ["title", "Widget"],
    204           ["category", "Tools"],
    205           ["radroots:primary_bin", "bin-1"],
    206           ["radroots:bin", "bin-1", "1", "each"],
    207           ["radroots:price", "bin-1", "10", "USD", "1", "each"]
    208         ]
    209       },
    210       "expected": {
    211         "error": {"InvalidKind": 0}
    212       }
    213     }
    214   ]
    215 }