Skip to content

Commit

Permalink
CORE-17495: Add runtime check for sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
malachyb committed Oct 31, 2023
1 parent e6d293a commit 119e878
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
{
"name": "attributes",
"type" : { "type": "map", "values" : "string", "default": {}}
},
{
"name": "cordappName",
"type": ["null", "string"],
"default": null
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package net.corda.data.packaging

import net.corda.data.KeyValuePairList
import org.apache.avro.Schema
import org.apache.avro.SchemaCompatibility
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test

class CorDappManifestSchemaCompatibilityTest {

@Test
fun `CorDappManifest schema changes between Corda 5_0 and 5_1 are compatible`() {
val oldSchemaJson = """
{
"type": "record",
"namespace": "net.corda.data.packaging",
"name": "CorDappManifest",
"fields": [
{
"name": "bundleSymbolicName",
"type" : "string"
},
{
"name": "bundleVersion",
"type" : "string"
},
{
"name": "minPlatformVersion",
"type" : "int"
},
{
"name": "targetPlatformVersion",
"type" : "int"
},
{
"name": "type",
"type" : "net.corda.data.packaging.CorDappType"
},
{
"name": "shortName",
"type": ["null", "string"]
},
{
"name": "vendor",
"type": ["null", "string"]
},
{
"name": "versionId",
"type": ["null", "int"]
},
{
"name": "license",
"type": ["null", "string"]
},
{
"name": "attributes",
"type" : { "type": "map", "values" : "string", "default": {}}
}
]
}
""".trimIndent()

val oldSchema = Schema.Parser()
.addTypes(
mapOf(
CorDappType::class.java.name to CorDappType.`SCHEMA$`
)
)
.parse(oldSchemaJson)

val newSchema = CorDappManifest.`SCHEMA$`

val compatibility = SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema)

Assertions.assertEquals(
compatibility.type,
SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE,
"Failed due to incompatible change. ${compatibility.description}"
)
}
}

0 comments on commit 119e878

Please sign in to comment.