Files
kvitt/contracts/test-vectors/validate_settlement.json
T
jacobh2 c6df2ab8f5 M1: contracts and vectors (SPEC v0.1, schema 1)
contracts/openapi.yaml (OpenAPI 3.1, E-1..E-33, error shape and the
exhaustive error code enum, device bearer scheme), contracts/schema/
server-v1.sql (SPEC §14.1 verbatim), seven test-vector files per §14.5.5,
80 examples (every JSON body of §14.3.4, every error code, sync pull/push,
every FCM push type), and tools/contracts-check.py (stdlib-only reference
of §9.1, §9.3, §9.4 and §14.5.4 plus shape checks; the M1 gate).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 20:57:59 +02:00

1085 lines
23 KiB
JSON

{
"format": 1,
"function": "validate_settlement",
"cases": [
{
"name": "valid: one allocation",
"input": {
"amount_ore": 50000,
"from_user_id": "b",
"to_user_id": "a",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 50000
}
]
},
"expected": {
"ok": null
}
},
{
"name": "valid: three allocations summing to the amount",
"input": {
"amount_ore": 60000,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 30000
},
{
"account_id": "y",
"amount_ore": 20000
},
{
"account_id": "z",
"amount_ore": 10000
}
]
},
"expected": {
"ok": null
}
},
{
"name": "valid: 50 allocations (the maximum)",
"input": {
"amount_ore": 5000,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "acc01",
"amount_ore": 100
},
{
"account_id": "acc02",
"amount_ore": 100
},
{
"account_id": "acc03",
"amount_ore": 100
},
{
"account_id": "acc04",
"amount_ore": 100
},
{
"account_id": "acc05",
"amount_ore": 100
},
{
"account_id": "acc06",
"amount_ore": 100
},
{
"account_id": "acc07",
"amount_ore": 100
},
{
"account_id": "acc08",
"amount_ore": 100
},
{
"account_id": "acc09",
"amount_ore": 100
},
{
"account_id": "acc10",
"amount_ore": 100
},
{
"account_id": "acc11",
"amount_ore": 100
},
{
"account_id": "acc12",
"amount_ore": 100
},
{
"account_id": "acc13",
"amount_ore": 100
},
{
"account_id": "acc14",
"amount_ore": 100
},
{
"account_id": "acc15",
"amount_ore": 100
},
{
"account_id": "acc16",
"amount_ore": 100
},
{
"account_id": "acc17",
"amount_ore": 100
},
{
"account_id": "acc18",
"amount_ore": 100
},
{
"account_id": "acc19",
"amount_ore": 100
},
{
"account_id": "acc20",
"amount_ore": 100
},
{
"account_id": "acc21",
"amount_ore": 100
},
{
"account_id": "acc22",
"amount_ore": 100
},
{
"account_id": "acc23",
"amount_ore": 100
},
{
"account_id": "acc24",
"amount_ore": 100
},
{
"account_id": "acc25",
"amount_ore": 100
},
{
"account_id": "acc26",
"amount_ore": 100
},
{
"account_id": "acc27",
"amount_ore": 100
},
{
"account_id": "acc28",
"amount_ore": 100
},
{
"account_id": "acc29",
"amount_ore": 100
},
{
"account_id": "acc30",
"amount_ore": 100
},
{
"account_id": "acc31",
"amount_ore": 100
},
{
"account_id": "acc32",
"amount_ore": 100
},
{
"account_id": "acc33",
"amount_ore": 100
},
{
"account_id": "acc34",
"amount_ore": 100
},
{
"account_id": "acc35",
"amount_ore": 100
},
{
"account_id": "acc36",
"amount_ore": 100
},
{
"account_id": "acc37",
"amount_ore": 100
},
{
"account_id": "acc38",
"amount_ore": 100
},
{
"account_id": "acc39",
"amount_ore": 100
},
{
"account_id": "acc40",
"amount_ore": 100
},
{
"account_id": "acc41",
"amount_ore": 100
},
{
"account_id": "acc42",
"amount_ore": 100
},
{
"account_id": "acc43",
"amount_ore": 100
},
{
"account_id": "acc44",
"amount_ore": 100
},
{
"account_id": "acc45",
"amount_ore": 100
},
{
"account_id": "acc46",
"amount_ore": 100
},
{
"account_id": "acc47",
"amount_ore": 100
},
{
"account_id": "acc48",
"amount_ore": 100
},
{
"account_id": "acc49",
"amount_ore": 100
},
{
"account_id": "acc50",
"amount_ore": 100
}
]
},
"expected": {
"ok": null
}
},
{
"name": "valid: amount 1 000 000 000 (the maximum)",
"input": {
"amount_ore": 1000000000,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 1000000000
}
]
},
"expected": {
"ok": null
}
},
{
"name": "amount 0",
"input": {
"amount_ore": 0,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 0
}
]
},
"expected": {
"error": "amount_out_of_range"
}
},
{
"name": "amount 1 000 000 001",
"input": {
"amount_ore": 1000000001,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 1000000001
}
]
},
"expected": {
"error": "amount_out_of_range"
}
},
{
"name": "from equals to",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "a",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
}
]
},
"expected": {
"error": "same_user"
}
},
{
"name": "from user unknown",
"input": {
"amount_ore": 500,
"from_user_id": "x",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
}
]
},
"expected": {
"error": "user_unknown"
}
},
{
"name": "to user unknown",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "x",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
}
]
},
"expected": {
"error": "user_unknown"
}
},
{
"name": "no allocations",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": []
},
"expected": {
"error": "no_allocations"
}
},
{
"name": "51 allocations",
"input": {
"amount_ore": 5100,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "acc01",
"amount_ore": 100
},
{
"account_id": "acc02",
"amount_ore": 100
},
{
"account_id": "acc03",
"amount_ore": 100
},
{
"account_id": "acc04",
"amount_ore": 100
},
{
"account_id": "acc05",
"amount_ore": 100
},
{
"account_id": "acc06",
"amount_ore": 100
},
{
"account_id": "acc07",
"amount_ore": 100
},
{
"account_id": "acc08",
"amount_ore": 100
},
{
"account_id": "acc09",
"amount_ore": 100
},
{
"account_id": "acc10",
"amount_ore": 100
},
{
"account_id": "acc11",
"amount_ore": 100
},
{
"account_id": "acc12",
"amount_ore": 100
},
{
"account_id": "acc13",
"amount_ore": 100
},
{
"account_id": "acc14",
"amount_ore": 100
},
{
"account_id": "acc15",
"amount_ore": 100
},
{
"account_id": "acc16",
"amount_ore": 100
},
{
"account_id": "acc17",
"amount_ore": 100
},
{
"account_id": "acc18",
"amount_ore": 100
},
{
"account_id": "acc19",
"amount_ore": 100
},
{
"account_id": "acc20",
"amount_ore": 100
},
{
"account_id": "acc21",
"amount_ore": 100
},
{
"account_id": "acc22",
"amount_ore": 100
},
{
"account_id": "acc23",
"amount_ore": 100
},
{
"account_id": "acc24",
"amount_ore": 100
},
{
"account_id": "acc25",
"amount_ore": 100
},
{
"account_id": "acc26",
"amount_ore": 100
},
{
"account_id": "acc27",
"amount_ore": 100
},
{
"account_id": "acc28",
"amount_ore": 100
},
{
"account_id": "acc29",
"amount_ore": 100
},
{
"account_id": "acc30",
"amount_ore": 100
},
{
"account_id": "acc31",
"amount_ore": 100
},
{
"account_id": "acc32",
"amount_ore": 100
},
{
"account_id": "acc33",
"amount_ore": 100
},
{
"account_id": "acc34",
"amount_ore": 100
},
{
"account_id": "acc35",
"amount_ore": 100
},
{
"account_id": "acc36",
"amount_ore": 100
},
{
"account_id": "acc37",
"amount_ore": 100
},
{
"account_id": "acc38",
"amount_ore": 100
},
{
"account_id": "acc39",
"amount_ore": 100
},
{
"account_id": "acc40",
"amount_ore": 100
},
{
"account_id": "acc41",
"amount_ore": 100
},
{
"account_id": "acc42",
"amount_ore": 100
},
{
"account_id": "acc43",
"amount_ore": 100
},
{
"account_id": "acc44",
"amount_ore": 100
},
{
"account_id": "acc45",
"amount_ore": 100
},
{
"account_id": "acc46",
"amount_ore": 100
},
{
"account_id": "acc47",
"amount_ore": 100
},
{
"account_id": "acc48",
"amount_ore": 100
},
{
"account_id": "acc49",
"amount_ore": 100
},
{
"account_id": "acc50",
"amount_ore": 100
},
{
"account_id": "acc51",
"amount_ore": 100
}
]
},
"expected": {
"error": "too_many_allocations"
}
},
{
"name": "an allocation of 0",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
},
{
"account_id": "y",
"amount_ore": 0
}
]
},
"expected": {
"error": "allocation_not_positive"
}
},
{
"name": "a negative allocation",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 600
},
{
"account_id": "y",
"amount_ore": -100
}
]
},
"expected": {
"error": "allocation_not_positive"
}
},
{
"name": "the same account twice",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 200
},
{
"account_id": "x",
"amount_ore": 300
}
]
},
"expected": {
"error": "duplicate_account"
}
},
{
"name": "allocations sum below the amount",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 200
},
{
"account_id": "y",
"amount_ore": 299
}
]
},
"expected": {
"error": "allocation_sum_mismatch"
}
},
{
"name": "allocations sum above the amount",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 200
},
{
"account_id": "y",
"amount_ore": 301
}
]
},
"expected": {
"error": "allocation_sum_mismatch"
}
},
{
"name": "error order: amount before same user",
"input": {
"amount_ore": 0,
"from_user_id": "a",
"to_user_id": "a",
"user_ids": [
"a",
"b"
],
"allocations": []
},
"expected": {
"error": "amount_out_of_range"
}
},
{
"name": "error order: same user before user unknown",
"input": {
"amount_ore": 500,
"from_user_id": "x",
"to_user_id": "x",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
}
]
},
"expected": {
"error": "same_user"
}
},
{
"name": "error order: user unknown before no allocations",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "x",
"user_ids": [
"a",
"b"
],
"allocations": []
},
"expected": {
"error": "user_unknown"
}
},
{
"name": "error order: too many allocations before allocation not positive",
"input": {
"amount_ore": 5100,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "acc01",
"amount_ore": 0
},
{
"account_id": "acc02",
"amount_ore": 102
},
{
"account_id": "acc03",
"amount_ore": 102
},
{
"account_id": "acc04",
"amount_ore": 102
},
{
"account_id": "acc05",
"amount_ore": 102
},
{
"account_id": "acc06",
"amount_ore": 102
},
{
"account_id": "acc07",
"amount_ore": 102
},
{
"account_id": "acc08",
"amount_ore": 102
},
{
"account_id": "acc09",
"amount_ore": 102
},
{
"account_id": "acc10",
"amount_ore": 102
},
{
"account_id": "acc11",
"amount_ore": 102
},
{
"account_id": "acc12",
"amount_ore": 102
},
{
"account_id": "acc13",
"amount_ore": 102
},
{
"account_id": "acc14",
"amount_ore": 102
},
{
"account_id": "acc15",
"amount_ore": 102
},
{
"account_id": "acc16",
"amount_ore": 102
},
{
"account_id": "acc17",
"amount_ore": 102
},
{
"account_id": "acc18",
"amount_ore": 102
},
{
"account_id": "acc19",
"amount_ore": 102
},
{
"account_id": "acc20",
"amount_ore": 102
},
{
"account_id": "acc21",
"amount_ore": 102
},
{
"account_id": "acc22",
"amount_ore": 102
},
{
"account_id": "acc23",
"amount_ore": 102
},
{
"account_id": "acc24",
"amount_ore": 102
},
{
"account_id": "acc25",
"amount_ore": 102
},
{
"account_id": "acc26",
"amount_ore": 102
},
{
"account_id": "acc27",
"amount_ore": 102
},
{
"account_id": "acc28",
"amount_ore": 102
},
{
"account_id": "acc29",
"amount_ore": 102
},
{
"account_id": "acc30",
"amount_ore": 102
},
{
"account_id": "acc31",
"amount_ore": 102
},
{
"account_id": "acc32",
"amount_ore": 102
},
{
"account_id": "acc33",
"amount_ore": 102
},
{
"account_id": "acc34",
"amount_ore": 102
},
{
"account_id": "acc35",
"amount_ore": 102
},
{
"account_id": "acc36",
"amount_ore": 102
},
{
"account_id": "acc37",
"amount_ore": 102
},
{
"account_id": "acc38",
"amount_ore": 102
},
{
"account_id": "acc39",
"amount_ore": 102
},
{
"account_id": "acc40",
"amount_ore": 102
},
{
"account_id": "acc41",
"amount_ore": 102
},
{
"account_id": "acc42",
"amount_ore": 102
},
{
"account_id": "acc43",
"amount_ore": 102
},
{
"account_id": "acc44",
"amount_ore": 102
},
{
"account_id": "acc45",
"amount_ore": 102
},
{
"account_id": "acc46",
"amount_ore": 102
},
{
"account_id": "acc47",
"amount_ore": 102
},
{
"account_id": "acc48",
"amount_ore": 102
},
{
"account_id": "acc49",
"amount_ore": 102
},
{
"account_id": "acc50",
"amount_ore": 102
},
{
"account_id": "acc51",
"amount_ore": 102
}
]
},
"expected": {
"error": "too_many_allocations"
}
},
{
"name": "error order: allocation not positive before duplicate account",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 500
},
{
"account_id": "x",
"amount_ore": 0
}
]
},
"expected": {
"error": "allocation_not_positive"
}
},
{
"name": "error order: duplicate account before sum mismatch",
"input": {
"amount_ore": 500,
"from_user_id": "a",
"to_user_id": "b",
"user_ids": [
"a",
"b"
],
"allocations": [
{
"account_id": "x",
"amount_ore": 100
},
{
"account_id": "x",
"amount_ore": 100
}
]
},
"expected": {
"error": "duplicate_account"
}
}
]
}