wallet-kit / test / vectors / ledger.json
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
{
  "_doc": "The balance fold, as arithmetic anyone can check. `me` is the payer; every amount below is in the fixture currency. settled folds receipts only (credit when po.to === me, debit when po.from === me), held sums OUTGOING pending orders, available = settled - held. The expected numbers are written out by hand, not read back from a run.",
  "me": "A6EHv_POEL4dcN0Y50vAmWfk1jCbpQ1fHdyGZBJVMbg",
  "cur": "0EqyMnQrtKs6E2i9RhXk5tAiSrcaAWuvhSCjMsl3hzc.LEI",
  "steps": [
    {
      "op": "start",
      "expect": null,
      "nextSeq": 1,
      "why": "a fresh ledger has no currencies and no history"
    },
    {
      "op": "addOrder",
      "order": "out_a",
      "amt": 100,
      "seq": 1,
      "expect": {
        "settled": 0,
        "held": 100,
        "available": -100
      },
      "nextSeq": 2,
      "why": "signing an order commits nothing and settles nothing"
    },
    {
      "op": "addOrder",
      "order": "out_b",
      "amt": 250,
      "seq": 2,
      "expect": {
        "settled": 0,
        "held": 350,
        "available": -350
      },
      "nextSeq": 3,
      "why": "100 + 250 held"
    },
    {
      "op": "addOrder",
      "order": "out_a",
      "amt": 100,
      "seq": 1,
      "expect": {
        "settled": 0,
        "held": 350,
        "available": -350
      },
      "nextSeq": 3,
      "expectResult": false,
      "why": "the same order twice is one order"
    },
    {
      "op": "applyReceipt",
      "order": "out_a",
      "expect": {
        "settled": -100,
        "held": 250,
        "available": -350
      },
      "nextSeq": 3,
      "why": "the debit lands and the hold is released: 0-100 settled, 350-100 held"
    },
    {
      "op": "applyReceipt",
      "order": "out_a",
      "expect": {
        "settled": -100,
        "held": 250,
        "available": -350
      },
      "nextSeq": 3,
      "expectResult": false,
      "why": "idempotent — folding a receipt twice would double a debit"
    },
    {
      "op": "applyDecline",
      "order": "out_b",
      "expect": {
        "settled": -100,
        "held": 0,
        "available": -100
      },
      "nextSeq": 3,
      "why": "a decline releases the hold and moves nothing"
    },
    {
      "op": "applyReceipt",
      "order": "in_c",
      "amt": 500,
      "seq": 1,
      "expect": {
        "settled": 400,
        "held": 0,
        "available": 400
      },
      "nextSeq": 3,
      "why": "an incoming receipt credits: -100 + 500 = 400. Its seq is the PAYEE's, so nextSeq is untouched"
    },
    {
      "op": "reload",
      "expect": {
        "settled": 400,
        "held": 0,
        "available": 400
      },
      "nextSeq": 3,
      "why": "a fresh LedgerStore on the same key folds to the same numbers"
    }
  ],
  "issuance_steps": {
    "_doc": "The issuance fold, as arithmetic anyone can check. `me` is the payer again; a wri credits `to` and NEVER debits anyone in this ledger — a burn has no wri at all. The mints are named rows the test signs with the fixed bank seed; each carries its own `h`, and the re-issue row reuses mint_a's `h` with a fresh ts, which is the same fact said twice.",
    "mints": {
      "mint_a": {
        "seq": 1,
        "amt": 500,
        "h": "mint-entry-a",
        "to": "me"
      },
      "mint_b": {
        "seq": 2,
        "amt": 250,
        "h": "mint-entry-b",
        "to": "me"
      },
      "mint_other": {
        "seq": 3,
        "amt": 999,
        "h": "mint-entry-c",
        "to": "payee"
      }
    },
    "steps": [
      {
        "op": "applyIssuance",
        "mint": "mint_a",
        "expect": {
          "settled": 500,
          "held": 0,
          "available": 500
        },
        "nextSeq": 1,
        "expectResult": true,
        "why": "a mint credits with no order and no debit anywhere"
      },
      {
        "op": "applyIssuance",
        "mint": "mint_a",
        "reissueTsDelta": 5000,
        "expect": {
          "settled": 500,
          "held": 0,
          "available": 500
        },
        "nextSeq": 1,
        "expectResult": false,
        "why": "a re-issued receipt with a fresh ts is the same mint — issuanceKey is blind to ts"
      },
      {
        "op": "applyIssuance",
        "mint": "mint_other",
        "expect": {
          "settled": 500,
          "held": 0,
          "available": 500
        },
        "nextSeq": 1,
        "expectResult": false,
        "why": "a mint to someone else is rejected outright: a wri has exactly one beneficiary"
      },
      {
        "op": "addOrder",
        "order": "out_a",
        "amt": 100,
        "seq": 1,
        "expect": {
          "settled": 500,
          "held": 100,
          "available": 400
        },
        "nextSeq": 2,
        "expectResult": true,
        "why": "minted money can then be committed by an ordinary order"
      },
      {
        "op": "applyReceipt",
        "order": "out_a",
        "expect": {
          "settled": 400,
          "held": 0,
          "available": 400
        },
        "nextSeq": 2,
        "expectResult": true,
        "why": "and settled: 500 - 100"
      },
      {
        "op": "applyIssuance",
        "mint": "mint_b",
        "expect": {
          "settled": 650,
          "held": 0,
          "available": 650
        },
        "nextSeq": 2,
        "expectResult": true,
        "why": "a second mint on a different entry hash folds: 400 + 250. The bank's issuance seq never touches the payer's order seq"
      },
      {
        "op": "reload",
        "expect": {
          "settled": 650,
          "held": 0,
          "available": 650
        },
        "nextSeq": 2,
        "why": "a fresh LedgerStore on the same key folds to the same numbers"
      }
    ]
  }
}

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/wallet-kit.git