mirror of
https://github.com/corda/corda.git
synced 2025-04-08 20:04:51 +00:00
Size of notary key in vault schema fix. (#414)
Fix in vault schema so notary_key can have more key entries in CompositeKey, as it's kept as Base58 string. Change default varchar field with size 255 to varchar with size 65535. Add test to VaultSchemaTest.
This commit is contained in:
parent
81b0393766
commit
11cedee211
@ -82,6 +82,7 @@ public class VaultStatesEntity implements VaultSchema.VaultStates, Persistable {
|
||||
.setLazy(false)
|
||||
.setNullable(true)
|
||||
.setUnique(false)
|
||||
.setLength(65535)
|
||||
.build());
|
||||
|
||||
public static final AttributeDelegate<VaultStatesEntity, String> CONTRACT_STATE_CLASS_NAME = new AttributeDelegate(
|
||||
|
@ -40,7 +40,7 @@ object VaultSchema {
|
||||
@get:Column(name = "notary_name")
|
||||
var notaryName: String
|
||||
|
||||
@get:Column(name = "notary_key")
|
||||
@get:Column(name = "notary_key", length = 65535) // TODO What is the upper limit on size of CompositeKey?
|
||||
var notaryKey: String
|
||||
|
||||
/** references a concrete ContractState that is [QueryableState] and has a [MappedSchema] */
|
||||
|
@ -8,10 +8,7 @@ import io.requery.rx.KotlinRxEntityStore
|
||||
import io.requery.sql.*
|
||||
import io.requery.sql.platform.Generic
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.core.crypto.CompositeKey
|
||||
import net.corda.core.crypto.Party
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.crypto.composite
|
||||
import net.corda.core.crypto.*
|
||||
import net.corda.core.node.services.Vault
|
||||
import net.corda.core.schemas.requery.converters.InstantConverter
|
||||
import net.corda.core.schemas.requery.converters.VaultStateStatusConverter
|
||||
@ -527,4 +524,21 @@ class VaultSchemaTest {
|
||||
assertEquals(3, count)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertWithBigCompositeKey() {
|
||||
val keys = (1..314).map { generateKeyPair().public.composite }
|
||||
val bigNotaryKey = CompositeKey.Builder().addKeys(keys).build()
|
||||
val vaultStEntity = VaultStatesEntity().apply {
|
||||
txId = SecureHash.randomSHA256().toString()
|
||||
index = 314
|
||||
stateStatus = Vault.StateStatus.UNCONSUMED
|
||||
contractStateClassName = VaultNoopContract.VaultNoopState::class.java.name
|
||||
notaryName = "Huge distributed notary"
|
||||
notaryKey = bigNotaryKey.toBase58String()
|
||||
recordedTime = Instant.now()
|
||||
}
|
||||
data.insert(vaultStEntity)
|
||||
assertEquals(1, data.select(VaultSchema.VaultStates::class).get().count())
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user