lotus/corpus/schema.json

201 lines
5.4 KiB
JSON

{
"$id": "https://filecoin.io/oni/schemas/test-vector.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "a filecoin VM test vector",
"type": "object",
"definitions": {
"hex": {
"title": "hex value",
"description": "a hex value prefixed with 0x, and accepting only lowercase characters; 0x represents an empty byte array",
"type": "string",
"pattern": "0x[0-9a-f]*",
"examples": [
"0xa1b2c3",
"0x"
]
},
"meta": {
"title": "metadata",
"description": "metadata about this test vector, such as its id, version, data about its generation, etc.",
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"title": "a unique identifier that identifies this test vector",
"type": "string"
},
"version": {
"title": "the version of this test vector",
"type": "string"
},
"description": {
"title": "an optional description of the test vector",
"type": "string"
},
"comment": {
"title": "optional comments about this test vector, e.g. applicability, hints, rationale, etc.",
"type": "string"
},
"gen": {
"title": "generation metadata",
"description": "metadata about how this test vector was generated",
"type": "object",
"additionalProperties": false,
"properties": {
"source": {
"type": "string",
"examples": [
"lotus",
"dsl"
]
},
"version": {
"type": "string",
"examples": [
"0.4.1+git.27d74337+api0.8.1"
]
}
}
}
}
},
"state_tree": {
"additionalProperties": false,
"required": [
"root_cid"
],
"properties": {
"root_cid": {
"additionalProperties": false,
"required": [
"/"
],
"properties": {
"/": {
"type": "string"
}
}
}
}
},
"receipt": {
"type": "object",
"required": [
"exit_code",
"return",
"gas_used"
],
"additionalProperties": false,
"properties": {
"exit_code": {
"type": "number"
},
"return": {
"$ref": "#/definitions/hex"
},
"gas_used": {
"type": "number"
}
}
},
"preconditions": {
"title": "execution preconditions",
"description": "preconditions that need to be applied and satisfied before this test vector can be executed",
"additionalProperties": false,
"properties": {
"epoch": {
"type": "integer"
},
"state_tree": {
"title": "state tree to seed",
"description": "state tree to seed before applying this test vector; mapping of actor addresses => serialized state",
"$ref": "#/definitions/state_tree"
}
}
},
"postconditions": {
"title": "execution preconditions",
"description": "postconditions that need to be satisfied after execution for this test vector to pass",
"additionalProperties": false,
"properties": {
"state_tree": {
"title": "state tree postconditions",
"description": "state tree postconditions that must be true for this test vector to pass",
"$ref": "#/definitions/state_tree"
},
"receipts": {
"title": "receipts to match",
"description": "receipts to match, required when using messages-class test vectors; length of this array MUST be equal to length of apply_messages",
"type": "array",
"items": {
"$ref": "#/definitions/receipt"
}
}
}
},
"apply_messages": {
"title": "messages to apply, along with the receipt to expect for each",
"type": "array",
"items": {
"$ref": "#/definitions/hex"
}
}
},
"required": [
"class"
],
"properties": {
"class": {
"title": "test vector class",
"description": "test vector class; depending on the value, the apply_* property to provide (and its schema) will vary; the relevant apply property is apply_[class]",
"type": "string",
"enum": [
"messages",
"block",
"tipset",
"chain"
]
},
"selector": {
"title": "selector the driver can use to determine if this test vector applies",
"description": "format TBD",
"type": "string"
},
"_meta": {
"$ref": "#/definitions/meta"
},
"car_bytes": {
"title": "car containing state trees",
"description": "the gzipped, hex-encoded CAR containing the pre- and post-condition state trees for this test vector",
"$ref": "#/definitions/hex"
},
"preconditions": {
"$ref": "#/definitions/preconditions"
},
"postconditions": {
"$ref": "#/definitions/postconditions"
}
},
"allOf": [
{
"if": {
"properties": {
"class": {
"const": "messages"
}
}
},
"then": {
"required": [
"apply_messages"
],
"properties": {
"apply_messages": {
"$ref": "#/definitions/apply_messages"
}
}
}
}
]
}