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:
kasiastreich 2017-03-24 15:14:02 +00:00 committed by GitHub
parent 81b0393766
commit 11cedee211
3 changed files with 20 additions and 5 deletions

View File

@ -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(

View File

@ -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] */

View File

@ -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())
}
}