mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-07 16:14:26 +01:00
pytest: add schema support for JSON responses.
This adds our first (basic) schema, and sews support into pyln-testing
so it will load schemas for any method for doc/schemas/{method}.schema.json.
All JSON responses in a test run are checked against the schema (if any).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
72
doc/schemas/listpays.schema.json
Normal file
72
doc/schemas/listpays.schema.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"pays": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"payment_hash": {
|
||||
"type": "hex",
|
||||
"description": "the hash of the *payment_preimage* which will prove payment",
|
||||
"maxLength": 64,
|
||||
"minLength": 64
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [ "pending", "failed", "complete" ],
|
||||
"description": "status of the payment"
|
||||
},
|
||||
"destination": {
|
||||
"type": "pubkey",
|
||||
"description": "the final destination of the payment if known"
|
||||
},
|
||||
"amount_msat": {
|
||||
"type": "msat",
|
||||
"description": "the amount the destination received, if known (**status** *complete* or *pending*)"
|
||||
},
|
||||
"amount_sent_msat": {
|
||||
"type": "msat",
|
||||
"description": "the amount we actually sent, including fees (**status** *complete* or *pending*)"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "u64",
|
||||
"description": "the UNIX timestamp showing when this payment was initiated"
|
||||
},
|
||||
"preimage": {
|
||||
"type": "hex",
|
||||
"description": "proof of payment, only if (and always if) **status** is *complete*",
|
||||
"FIXME": "we should enforce the status/payment_preimage relation in the schema!",
|
||||
"maxLength": 64,
|
||||
"minLength": 64
|
||||
},
|
||||
"label": {
|
||||
"type": "string",
|
||||
"description": "the label, if given to sendpay"
|
||||
},
|
||||
"bolt11": {
|
||||
"type": "string",
|
||||
"description": "the bolt11 string (if pay supplied one)"
|
||||
},
|
||||
"bolt12": {
|
||||
"type": "string",
|
||||
"description": "the bolt12 string (if supplied for pay: **experimental-offers** only)."
|
||||
},
|
||||
"erroronion": {
|
||||
"type": "hex",
|
||||
"description": "the error onion returned on failure, if any."
|
||||
},
|
||||
"number_of_parts": {
|
||||
"type": "u64",
|
||||
"description": "the number of parts for a successful payment (only if more than one, and **status** is *complete*)."
|
||||
}
|
||||
},
|
||||
"required": [ "payment_hash", "status", "created_at" ]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [ "pays" ]
|
||||
}
|
||||
Reference in New Issue
Block a user