-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CORE-15396 Add support for an expiry timeout on a token claim, this i…
…s to support automatic cleanup of orphaned claims.
- Loading branch information
1 parent
e5b00ed
commit d1e75cb
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...tlin/net/corda/data/ledger/utxo/token/selection/data/TokenClaimSchemaCompatibilityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package net.corda.data.ledger.utxo.token.selection.data | ||
|
||
import org.apache.avro.Schema | ||
import org.apache.avro.SchemaCompatibility | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class TokenClaimSchemaCompatibilityTest { | ||
|
||
@Test | ||
fun `Token Claim schema changes between Corda 5_0 and 5_1 are compatible`() { | ||
val oldSchemaJson = """ | ||
{ | ||
"type": "record", | ||
"name": "TokenClaim", | ||
"namespace": "net.corda.data.ledger.utxo.token.selection.data", | ||
"doc": "The set of tokens claimed by a query", | ||
"fields": [ | ||
{ | ||
"name": "claimId", | ||
"type": "string", | ||
"doc": "Unique identifier for the claim" | ||
}, | ||
{ | ||
"name": "claimedTokenStateRefs", | ||
"type": { | ||
"type": "array", | ||
"items": "string" | ||
}, | ||
"default": [], | ||
"doc": "Deprecated. The List of state refs for the claimed tokens" | ||
}, | ||
{ | ||
"name": "claimedTokens", | ||
"type": { | ||
"type": "array", | ||
"items": "net.corda.data.ledger.utxo.token.selection.data.Token" | ||
}, | ||
"default": [], | ||
"doc": "List of claimed tokens" | ||
} | ||
] | ||
} | ||
""".trimIndent() | ||
|
||
val oldSchema = Schema.Parser() | ||
.addTypes( | ||
mapOf( | ||
Token::class.java.name to Token.`SCHEMA$`, | ||
) | ||
) | ||
.parse(oldSchemaJson) | ||
|
||
val newSchema = TokenClaim.`SCHEMA$` | ||
|
||
val compatibility = SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema) | ||
|
||
Assertions.assertEquals( | ||
compatibility.type, | ||
SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE, | ||
"Failed due to incompatible change. ${compatibility.description}" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters