Added test to deserialise 4.11 network params

This commit is contained in:
tomstark99 2023-07-17 14:35:16 +01:00
parent 6b655c0f91
commit 639acc4c63
2 changed files with 39 additions and 0 deletions

View File

@ -637,6 +637,45 @@ class EvolvabilityTests {
assertEquals(DUMMY_NOTARY_PARTY, networkParams.notaries.firstOrNull()?.identity)
}
//
// This test uses a NetworkParameters signed set of bytes generated by a Corda 4.11 build and
// is here to ensure we can still read them. This test exists because Corda 4.11 Adds in new
// network parameters that should be backwards compatible with older corda versions
//
// The file itself was generated from a corda-os 4.11 build at commit
// 58ecce1 Ent-9875: New Network Parameters
//
// To regenerate the file un-ignore the test below this one (regenerate broken network parameters),
// to regenerate at a specific version add that test to a checkout at the desired sha then take
// the resulting file and add to the repo, changing the filename as appropriate
//
@Test(timeout=300_000)
fun `read corda 4-11 network parameters`() {
val sf = testDefaultFactory()
sf.register(net.corda.serialization.internal.amqp.custom.InstantSerializer(sf))
sf.register(net.corda.serialization.internal.amqp.custom.PublicKeySerializer)
sf.register(net.corda.serialization.internal.amqp.custom.DurationSerializer(sf))
//
// filename breakdown
// networkParams - because this is a serialised set of network parameters
// r3corda - generated by Corda Enterprise instead of Corda
// 6a6b6f256 - Commit sha of the build that generated the file we're testing against
//
val resource = "networkParams.4.11.58ecce1"
val url = EvolvabilityTests::class.java.getResource(resource)
val sc2 = url.readBytes()
val deserializedC = DeserializationInput(sf).deserialize(SerializedBytes<SignedData<NetworkParameters>>(sc2))
val networkParams = DeserializationInput(sf).deserialize(deserializedC.raw)
assertEquals(1000, networkParams.maxMessageSize)
assertEquals(1000, networkParams.maxTransactionSize)
assertEquals(3, networkParams.minimumPlatformVersion)
assertEquals(1, networkParams.notaries.size)
assertEquals(DUMMY_NOTARY_PARTY, networkParams.notaries.firstOrNull()?.identity)
}
//
// This test created a serialized and signed set of Network Parameters to test whether we
// can still deserialize them