{
 "format": "zoobc-conformance-vectors/1",
 "edition": "0.6.1",
 "chapter": "13",
 "license": "CC BY 4.0, ZooBC Foundation",
 "cases": [
  {
   "id": "13-1-record",
   "chapter": "13",
   "section": "1",
   "title": "A version-2 CreateApp with a survival of 0.1 ZBC opens a longevity record",
   "kind": "13-survival-record",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "type": "24",
    "version": "2",
    "survival": "10000000",
    "body": "12000000000000000000ca9a3b0000000001030001000100",
    "message": "",
    "height": "11877",
    "interval": "172800",
    "price": "5000000"
   },
   "expected": {
    "deposit": "10000000",
    "payload_bytes": "24",
    "cost_per_mib_locked": "5000000",
    "free_until_height": "357477",
    "paid_through_height": "357477"
   }
  },
  {
   "id": "13-1-below-minimum",
   "chapter": "13",
   "section": "1",
   "title": "A survival of 9,999,999 is below the minimum deposit",
   "kind": "13-survival-record",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "24",
    "version": "2",
    "survival": "9999999",
    "body": "12000000000000000000ca9a3b0000000001030001000100",
    "message": "",
    "height": "11877",
    "interval": "172800",
    "price": "5000000"
   },
   "expected": {
    "error": "Survival below the minimum deposit of 10000000 units (0 means none)"
   }
  },
  {
   "id": "13-1-version-1",
   "chapter": "13",
   "section": "1",
   "title": "A version-1 transaction cannot carry a survival",
   "kind": "13-survival-record",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "24",
    "version": "1",
    "survival": "10000000",
    "body": "12000000000000000000ca9a3b0000000001030001000100",
    "message": "",
    "height": "11877",
    "interval": "172800",
    "price": "5000000"
   },
   "expected": {
    "error": "A version-1 transaction carries no survival; use transaction version 2"
   }
  },
  {
   "id": "13-1-negative",
   "chapter": "13",
   "section": "1",
   "title": "A negative survival is refused",
   "kind": "13-tx-check",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "24",
    "version": "2",
    "survival": "-1",
    "body": "12000000000000000000ca9a3b0000000001030001000100"
   },
   "expected": {
    "error": "Survival must not be negative"
   }
  },
  {
   "id": "13-1-bad-version",
   "chapter": "13",
   "section": "1",
   "title": "Version 4 is not a transaction version",
   "kind": "13-tx-check",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "24",
    "version": "4",
    "survival": "0",
    "body": "12000000000000000000ca9a3b0000000001030001000100"
   },
   "expected": {
    "error": "Invalid transaction version"
   }
  },
  {
   "id": "13-1-view-empty",
   "chapter": "13",
   "section": "1",
   "title": "The longevity view of a chain with no live record, at height 12,467",
   "kind": "reference",
   "validity": "valid",
   "source": "computed",
   "inputs": {},
   "expected": {
    "value": "{\"chain_height\":12467,\"billing_period_blocks\":172800,\"count\":0,\"longevity\":[]}"
   }
  },
  {
   "id": "13-2-fifo",
   "chapter": "13",
   "section": "2",
   "title": "Four payments, ten units left: who still has money on the record",
   "kind": "13-deposit-shares",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 10\nB 5\nC 5\ncreator 5",
    "left": "10"
   },
   "expected": {
    "consumed": "15",
    "payers": "creator 15 5\nB 5 0\nC 5 5"
   }
  },
  {
   "id": "13-2-quote",
   "chapter": "13",
   "section": "2",
   "title": "The quote for funding a 24-byte CreateApp mined at 11,877 with 0.1 ZBC",
   "kind": "13-longevity-quote",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "target_height": "11877",
    "payload_bytes": "24",
    "price": "5000000",
    "interval": "172800",
    "amount": "10000000"
   },
   "expected": {
    "first_funding_last_height": "184676",
    "free_until_height": "357477",
    "rent_per_period": "115",
    "periods_remaining": "86957"
   }
  },
  {
   "id": "13-2-quote-no-target",
   "chapter": "13",
   "section": "2",
   "title": "A quote without a target is refused with HTTP 400",
   "kind": "reference",
   "validity": "invalid",
   "source": "computed",
   "inputs": {},
   "expected": {
    "value": "{\"success\":false,\"error\":\"target is required: a transaction id or its 64-hex hash\",\"code\":400}"
   }
  },
  {
   "id": "13-3-first",
   "chapter": "13",
   "section": "3",
   "title": "A first FundLongevity of 0.1 ZBC for the CreateApp of 11,877",
   "kind": "13-fund-longevity",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "body": "e2400e49c2a0fe498096980000000000652e00001800000000000000",
    "height": "12500",
    "interval": "172800",
    "price": "5000000",
    "row_height": "11877",
    "row_bytes": "24"
   },
   "expected": {
    "target": "5331875765163016418",
    "amount": "10000000",
    "target_height": "11877",
    "target_bytes": "24",
    "free_until_height": "357477",
    "cost_per_mib_locked": "5000000",
    "rent_per_period": "115"
   }
  },
  {
   "id": "13-3-wrong-size",
   "chapter": "13",
   "section": "3",
   "title": "A stated size of 23 bytes does not match the 24-byte target",
   "kind": "13-fund-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "body": "e2400e49c2a0fe498096980000000000652e00001700000000000000",
    "height": "12500",
    "interval": "172800",
    "price": "5000000",
    "row_height": "11877",
    "row_bytes": "24"
   },
   "expected": {
    "error": "FundLongevity: stated target size 23 bytes but the target is 24"
   }
  },
  {
   "id": "13-3-too-late",
   "chapter": "13",
   "section": "3",
   "title": "A first funding one snapshot interval after the target is too late",
   "kind": "13-fund-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "body": "e2400e49c2a0fe498096980000000000652e00001800000000000000",
    "height": "184677",
    "interval": "172800",
    "price": "5000000",
    "row_height": "11877",
    "row_bytes": "24"
   },
   "expected": {
    "error": "FundLongevity: the target is not younger than one snapshot interval (172800 blocks); a first funding must come before height 184677"
   }
  },
  {
   "id": "13-3-below-minimum",
   "chapter": "13",
   "section": "3",
   "title": "An amount of 9,999,999 is below the minimum deposit",
   "kind": "13-fund-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "body": "e2400e49c2a0fe497f96980000000000652e00001800000000000000",
    "height": "12500",
    "interval": "172800",
    "price": "5000000",
    "row_height": "11877",
    "row_bytes": "24"
   },
   "expected": {
    "error": "FundLongevity deposit is below the minimum"
   }
  },
  {
   "id": "13-3-short-body",
   "chapter": "13",
   "section": "3",
   "title": "A 16-byte FundLongevity body is refused",
   "kind": "13-fund-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "body": "e2400e49c2a0fe498096980000000000",
    "height": "12500",
    "interval": "172800",
    "price": "5000000",
    "row_height": "11877",
    "row_bytes": "24"
   },
   "expected": {
    "error": "FundLongevity body must be exactly 28 bytes (target id, amount, target height, target bytes)"
   }
  },
  {
   "id": "13-4-retired",
   "chapter": "13",
   "section": "4",
   "title": "CancelLongevity is retired",
   "kind": "13-tx-check",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "53",
    "version": "1",
    "body": "e2400e49c2a0fe49"
   },
   "expected": {
    "error": "Transaction type 53 is retired from height 0"
   }
  },
  {
   "id": "13-5-b-no-money",
   "chapter": "13",
   "section": "5",
   "title": "B's money is used up, so B has no vote",
   "kind": "13-close-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 100000000\nB 50000000\nC 50000000\ncreator 50000000",
    "deposit": "100000000",
    "voted": "",
    "sender": "B"
   },
   "expected": {
    "error": "CloseLongevity: only an account whose money on the record is not used up yet votes to close it"
   }
  },
  {
   "id": "13-5-creator-votes",
   "chapter": "13",
   "section": "5",
   "title": "The creator votes; C has not voted, so the record lives",
   "kind": "13-close-longevity",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 100000000\nB 50000000\nC 50000000\ncreator 50000000",
    "deposit": "100000000",
    "voted": "",
    "sender": "creator"
   },
   "expected": {
    "votes": "creator",
    "closes": "false",
    "deposit_after": "100000000"
   }
  },
  {
   "id": "13-5-creator-again",
   "chapter": "13",
   "section": "5",
   "title": "The creator's second vote is already counted",
   "kind": "13-close-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 100000000\nB 50000000\nC 50000000\ncreator 50000000",
    "deposit": "100000000",
    "voted": "creator",
    "sender": "creator"
   },
   "expected": {
    "error": "CloseLongevity: your vote to close this record is already counted"
   }
  },
  {
   "id": "13-5-c-closes",
   "chapter": "13",
   "section": "5",
   "title": "C's vote is the last one: the record closes and the pool receives the rest",
   "kind": "13-close-longevity",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 100000000\nB 50000000\nC 50000000\ncreator 50000000",
    "deposit": "100000000",
    "voted": "creator",
    "sender": "C"
   },
   "expected": {
    "votes": "C",
    "closes": "true",
    "deposit_after": "0",
    "pool_close": "100000000"
   }
  },
  {
   "id": "13-5-nothing-funded",
   "chapter": "13",
   "section": "5",
   "title": "A CloseLongevity for a record with no deposit",
   "kind": "13-close-longevity",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "deposits": "creator 100000000\nB 50000000\nC 50000000\ncreator 50000000",
    "deposit": "0",
    "voted": "",
    "sender": "creator"
   },
   "expected": {
    "error": "CloseLongevity: nothing is funded for that transaction"
   }
  },
  {
   "id": "13-5-body-9",
   "chapter": "13",
   "section": "5",
   "title": "A 9-byte CloseLongevity body is refused",
   "kind": "13-tx-check",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "type": "309",
    "version": "1",
    "body": "e2400e49c2a0fe4900"
   },
   "expected": {
    "error": "CloseLongevity body must be exactly 8 bytes"
   }
  },
  {
   "id": "13-6-devnet-185",
   "chapter": "13",
   "section": "6",
   "title": "A 43-byte record on DevNet after 185 billings",
   "kind": "13-longevity-rent",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "payload_bytes": "43",
    "price": "100000000",
    "deposit": "100000000",
    "free_until_height": "912",
    "paid_through_height": "912",
    "period": "240",
    "billings": "185"
   },
   "expected": {
    "rent": "4101",
    "heights": "1152\n1392\n1632",
    "deposit_after": "99241315"
   }
  },
  {
   "id": "13-6-close-at-billing",
   "chapter": "13",
   "section": "6",
   "title": "The billing uses up A's money; B has voted, so the record closes",
   "kind": "13-close-longevity",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "deposits": "A 4101\nB 4101",
    "deposit": "8202",
    "sender": "",
    "rent": "4101",
    "voted": "B"
   },
   "expected": {
    "closes": "true",
    "deposit_after": "0",
    "pool_rent": "4101",
    "pool_close": "4101"
   }
  },
  {
   "id": "13-6-live-at-billing",
   "chapter": "13",
   "section": "6",
   "title": "The billing uses up A's money; A voted but B has not, so the record lives",
   "kind": "13-close-longevity",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "deposits": "A 4101\nB 4101",
    "deposit": "8202",
    "sender": "",
    "rent": "4101",
    "voted": "A"
   },
   "expected": {
    "closes": "false",
    "deposit_after": "4101",
    "pool_rent": "4101",
    "pool_close": "0"
   }
  },
  {
   "id": "13-6-quote",
   "chapter": "13",
   "section": "6",
   "title": "The TestNet quote's rent and periods",
   "kind": "13-longevity-quote",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "target_height": "11877",
    "payload_bytes": "24",
    "price": "5000000",
    "interval": "172800",
    "amount": "10000000"
   },
   "expected": {
    "rent_per_period": "115",
    "periods_remaining": "86957"
   }
  },
  {
   "id": "13-7-slice",
   "chapter": "13",
   "section": "7",
   "title": "A pool of 1,000,000 at block 12,467 pays a slice of 6",
   "kind": "13-pool-slice",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "balance": "1000000",
    "height": "12467",
    "period": "172800"
   },
   "expected": {
    "slice": "6"
   }
  },
  {
   "id": "13-7-too-small",
   "chapter": "13",
   "section": "7",
   "title": "A pool of 100,000 at block 12,467 pays nothing",
   "kind": "13-pool-slice",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "balance": "100000",
    "height": "12467",
    "period": "172800"
   },
   "expected": {
    "slice": "0"
   }
  },
  {
   "id": "13-7-pool-empty",
   "chapter": "13",
   "section": "7",
   "title": "A pool that has received nothing since block 0 shows balance 0 and no movements",
   "kind": "reference",
   "validity": "valid",
   "source": "computed",
   "inputs": {},
   "expected": {
    "address": "000000005A42434C4F4E4756000000000000000000000000000000000000000000000000",
    "balance": "0",
    "movements": "[]"
   }
  },
  {
   "id": "13-8-testnet",
   "chapter": "13",
   "section": "8",
   "title": "TestNet at height 360,000 with manifests at 172,040 and 344,840",
   "kind": "13-prune-bounds",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "h": "360000",
    "interval": "172800",
    "depth": "760",
    "rollback": "720",
    "lifecycle": "518400",
    "min_block_interval": "15",
    "manifests": "172040\n344840"
   },
   "expected": {
    "horizon": "172040",
    "bound": "172040",
    "replay": "6924",
    "ref": "344840",
    "window_from": "171280",
    "tx_bound": "171280",
    "receipt": "0"
   }
  },
  {
   "id": "13-8-devnet",
   "chapter": "13",
   "section": "8",
   "title": "DevNet at height 2,000 with manifests at 1,600 and 1,840",
   "kind": "13-prune-bounds",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "h": "2000",
    "interval": "240",
    "depth": "80",
    "rollback": "60",
    "lifecycle": "1440",
    "min_block_interval": "15",
    "manifests": "1600\n1840"
   },
   "expected": {
    "horizon": "1600",
    "ref": "1840",
    "bound": "400",
    "tx_bound": "0",
    "receipt": "560",
    "floor": "560",
    "release_keep": "172860",
    "release": "0",
    "survival_from": "1821",
    "survival_pending": "none",
    "flags_kept_from": "1821"
   }
  },
  {
   "id": "13-8-survival",
   "chapter": "13",
   "section": "8",
   "title": "DevNet in survival mode from 600 to 1,900: an event last attested at 500 is 199 blocks idle and stays",
   "kind": "13-prune-bounds",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "h": "2000",
    "interval": "240",
    "depth": "80",
    "rollback": "60",
    "lifecycle": "1440",
    "min_block_interval": "15",
    "manifests": "1600\n1840",
    "survival": "600 1900",
    "events": "E generic 500\nV release 500"
   },
   "expected": {
    "receipt": "560",
    "survival_from": "1821",
    "survival_pending": "500",
    "flags_kept_from": "500",
    "events": "E 199 kept\nV 199 kept"
   },
   "note": "The 1,301 survival heights do not count in an age; the release vote cast at 500 still counts."
  },
  {
   "id": "13-8-survival-none",
   "chapter": "13",
   "section": "8",
   "title": "Without the survival heights the same event is 1,500 blocks idle and its rows go",
   "kind": "13-prune-bounds",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "h": "2000",
    "interval": "240",
    "depth": "80",
    "rollback": "60",
    "lifecycle": "1440",
    "min_block_interval": "15",
    "manifests": "1600\n1840",
    "events": "E generic 500"
   },
   "expected": {
    "receipt": "560",
    "survival_from": "1821",
    "survival_pending": "none",
    "flags_kept_from": "1821",
    "events": "E 1500 deleted"
   }
  },
  {
   "id": "13-9-pays",
   "chapter": "13",
   "section": "9",
   "title": "Prepaid storage pays first, the balance the rest",
   "kind": "13-account-rent",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "1000000",
    "period": "172800",
    "height": "172800",
    "due": "172800",
    "balance": "600000",
    "prepaid": "500000"
   },
   "expected": {
    "outcome": "paid",
    "balance": "100000",
    "prepaid": "0",
    "rent_due_height": "345600",
    "rows": "83 +500000\n24 -1000000",
    "pool": "19 +1000000"
   }
  },
  {
   "id": "13-9-pruned",
   "chapter": "13",
   "section": "9",
   "title": "An account that cannot pay is tombstoned and its dust goes to the pool",
   "kind": "13-account-rent",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "1000000",
    "period": "172800",
    "height": "345600",
    "due": "345600",
    "balance": "100000",
    "prepaid": "0"
   },
   "expected": {
    "outcome": "pruned",
    "balance": "0",
    "prepaid": "0",
    "rent_due_height": "0",
    "rows": "25 -100000",
    "pool": "50 +100000"
   }
  },
  {
   "id": "13-9-pruned-prepaid",
   "chapter": "13",
   "section": "9",
   "title": "A pruned account's prepaid storage goes to the pool too",
   "kind": "13-account-rent",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "1000000",
    "period": "172800",
    "height": "345600",
    "due": "345600",
    "balance": "100000",
    "prepaid": "300000"
   },
   "expected": {
    "outcome": "pruned",
    "rows": "83 +300000\n25 -400000",
    "pool": "50 +400000"
   }
  },
  {
   "id": "13-9-treasury",
   "chapter": "13",
   "section": "9",
   "title": "The TestNet treasury pays its first rent at block 172,800",
   "kind": "13-account-rent",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "1000000",
    "period": "172800",
    "height": "172800",
    "due": "172800",
    "balance": "100000000000000",
    "prepaid": "0"
   },
   "expected": {
    "outcome": "paid",
    "rent_due_height": "345600",
    "rows": "24 -1000000",
    "pool": "19 +1000000"
   }
  },
  {
   "id": "13-9-genesis-armed",
   "chapter": "13",
   "section": "9",
   "title": "The genesis arms every funded account's rent clock one period out",
   "kind": "reference",
   "validity": "valid",
   "source": "computed",
   "inputs": {},
   "expected": {
    "treasury_rent_due_height": "172800",
    "treasury_block_height": "0",
    "pool_rent_due_height": "0",
    "unfunded_genesis_rent_due_height": "0"
   }
  },
  {
   "id": "13-10-one-period",
   "chapter": "13",
   "section": "10",
   "title": "0.1 ZBC buys one period",
   "kind": "13-token-blocks",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "payment": "10000000"
   },
   "expected": {
    "blocks": "172800"
   }
  },
  {
   "id": "13-10-two-and-half",
   "chapter": "13",
   "section": "10",
   "title": "0.25 ZBC buys two and a half periods",
   "kind": "13-token-blocks",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "payment": "25000000"
   },
   "expected": {
    "blocks": "432000"
   }
  },
  {
   "id": "13-10-one-unit",
   "chapter": "13",
   "section": "10",
   "title": "One unit buys nothing",
   "kind": "13-token-blocks",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "payment": "1"
   },
   "expected": {
    "blocks": "0"
   }
  },
  {
   "id": "13-10-zero",
   "chapter": "13",
   "section": "10",
   "title": "Nothing buys nothing",
   "kind": "13-token-blocks",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "payment": "0"
   },
   "expected": {
    "blocks": "0"
   }
  },
  {
   "id": "13-10-devnet",
   "chapter": "13",
   "section": "10",
   "title": "On DevNet 1 ZBC buys one 240-block period",
   "kind": "13-token-blocks",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "payment": "100000000",
    "cost": "100000000",
    "period": "240"
   },
   "expected": {
    "blocks": "240"
   }
  },
  {
   "id": "13-10-issue",
   "chapter": "13",
   "section": "10",
   "title": "A token issued at height 12,500 with no survival payment lives for the free period",
   "kind": "13-token-persist",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "op": "issue",
    "token": "20",
    "height": "12500",
    "payment": "0",
    "free": "172800"
   },
   "expected": {
    "persist_height": "185300"
   }
  },
  {
   "id": "13-10-finance-genesis",
   "chapter": "13",
   "section": "10",
   "title": "FinanceToken on ZUSD, which never expires, is refused",
   "kind": "13-token-persist",
   "validity": "invalid",
   "source": "computed",
   "inputs": {
    "cost": "10000000",
    "period": "172800",
    "op": "finance",
    "token": "1",
    "height": "12500",
    "persist_height": "0",
    "payment": "10000000",
    "free": "172800"
   },
   "expected": {
    "error": "Token 1 never expires: FinanceToken has nothing to fund"
   }
  },
  {
   "id": "13-10-expiry-refused",
   "chapter": "13",
   "section": "10",
   "title": "An expired token's backing of 1,000 held 600 : 400, where the first holder's credit would overflow",
   "kind": "13-token-expiry",
   "validity": "valid",
   "source": "computed",
   "inputs": {
    "backing": "1000",
    "holders": "H1 600 9223372036854775500\nH2 400"
   },
   "expected": {
    "credits": "H2 +400",
    "pool": "600",
    "issuer": "0",
    "backing_after": "0"
   },
   "note": "The refused share goes to the longevity pool (event 50, transaction_id = the token id): nothing is destroyed."
  },
  {
   "id": "13-10-genesis-tokens",
   "chapter": "13",
   "section": "10",
   "title": "The token set at block 0 is the 14 genesis coins, none of which expires",
   "kind": "reference",
   "validity": "valid",
   "source": "computed",
   "inputs": {},
   "expected": {
    "tokens": "1-14 (ZUSD ... ZUSDT)",
    "persist_height": "0",
    "backing_amount": "0"
   }
  }
 ]
}
