mirror of
https://github.com/corda/corda.git
synced 2025-05-07 11:08:40 +00:00
ENT-11351 - Compiler warnings pass 2 (#7655)
* Addressed compiler warnings * Removed unchecked cast fixes - not for this PR * Sorted out detekt issues
This commit is contained in:
parent
a0ce265b35
commit
f15e6ec56a
@ -61,7 +61,7 @@ class SpecificationTest {
|
|||||||
|
|
||||||
override fun parseValid(configuration: Config, options: Configuration.Options): Valid<AtomicLong> {
|
override fun parseValid(configuration: Config, options: Configuration.Options): Valid<AtomicLong> {
|
||||||
val config = configuration.withOptions(options)
|
val config = configuration.withOptions(options)
|
||||||
return valid(AtomicLong(config[maxElement]!!))
|
return valid(AtomicLong(config[maxElement]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class SpecificationTest {
|
|||||||
if (elements.any { element -> element <= 1 }) {
|
if (elements.any { element -> element <= 1 }) {
|
||||||
return invalid(Configuration.Validation.Error.BadValue.of("elements cannot be less than or equal to 1"))
|
return invalid(Configuration.Validation.Error.BadValue.of("elements cannot be less than or equal to 1"))
|
||||||
}
|
}
|
||||||
return valid(elements.max()!!)
|
return valid(elements.max())
|
||||||
}
|
}
|
||||||
|
|
||||||
val spec = object : Configuration.Specification<AtomicLong>("AtomicLong") {
|
val spec = object : Configuration.Specification<AtomicLong>("AtomicLong") {
|
||||||
|
@ -56,8 +56,8 @@ class AmountTests {
|
|||||||
val splits = baseAmount.splitEvenly(partitionCount)
|
val splits = baseAmount.splitEvenly(partitionCount)
|
||||||
assertEquals(partitionCount, splits.size)
|
assertEquals(partitionCount, splits.size)
|
||||||
assertEquals(baseAmount, splits.sumOrZero(baseAmount.token))
|
assertEquals(baseAmount, splits.sumOrZero(baseAmount.token))
|
||||||
val min = splits.min()!!
|
val min = splits.min()
|
||||||
val max = splits.max()!!
|
val max = splits.max()
|
||||||
assertTrue(max.quantity - min.quantity <= 1L, "Amount quantities should differ by at most one token")
|
assertTrue(max.quantity - min.quantity <= 1L, "Amount quantities should differ by at most one token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ class CompatibleTransactionTests {
|
|||||||
ftxCompatibleNoInputs.verify()
|
ftxCompatibleNoInputs.verify()
|
||||||
assertFailsWith<ComponentVisibilityException> { ftxCompatibleNoInputs.checkAllComponentsVisible(INPUTS_GROUP) }
|
assertFailsWith<ComponentVisibilityException> { ftxCompatibleNoInputs.checkAllComponentsVisible(INPUTS_GROUP) }
|
||||||
assertEquals(wireTransactionCompatibleA.componentGroups.size - 1, ftxCompatibleNoInputs.filteredComponentGroups.size)
|
assertEquals(wireTransactionCompatibleA.componentGroups.size - 1, ftxCompatibleNoInputs.filteredComponentGroups.size)
|
||||||
assertEquals(wireTransactionCompatibleA.componentGroups.map { it.groupIndex }.max()!!, ftxCompatibleNoInputs.groupHashes.size - 1)
|
assertEquals(wireTransactionCompatibleA.componentGroups.map { it.groupIndex }.max(), ftxCompatibleNoInputs.groupHashes.size - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
|
@ -13,7 +13,8 @@ import net.corda.testing.core.SerializationEnvironmentRule
|
|||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
object EmptyWhitelist : ClassWhitelist {
|
object EmptyWhitelist : ClassWhitelist {
|
||||||
override fun hasListed(type: Class<*>): Boolean = false
|
override fun hasListed(type: Class<*>): Boolean = false
|
||||||
@ -23,9 +24,6 @@ class KotlinUtilsTest {
|
|||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
@JvmField
|
|
||||||
@Rule
|
|
||||||
val expectedEx: ExpectedException = ExpectedException.none()
|
|
||||||
|
|
||||||
private val KRYO_CHECKPOINT_NOWHITELIST_CONTEXT = CheckpointSerializationContextImpl(
|
private val KRYO_CHECKPOINT_NOWHITELIST_CONTEXT = CheckpointSerializationContextImpl(
|
||||||
javaClass.classLoader,
|
javaClass.classLoader,
|
||||||
@ -54,10 +52,11 @@ class KotlinUtilsTest {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `deserialise transient property with non-capturing lambda`() {
|
fun `deserialise transient property with non-capturing lambda`() {
|
||||||
expectedEx.expect(KryoException::class.java)
|
val anException = assertThrows<KryoException> {
|
||||||
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
|
val original = NonCapturingTransientProperty()
|
||||||
val original = NonCapturingTransientProperty()
|
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
||||||
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("is not annotated or on the whitelist, so cannot be used in serialization")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
@ -73,12 +72,11 @@ class KotlinUtilsTest {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `deserialise transient property with capturing lambda`() {
|
fun `deserialise transient property with capturing lambda`() {
|
||||||
expectedEx.expect(KryoException::class.java)
|
val anException = assertThrows<KryoException> {
|
||||||
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
|
val original = CapturingTransientProperty("Hello")
|
||||||
|
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
||||||
val original = CapturingTransientProperty("Hello")
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("is not annotated or on the whitelist, so cannot be used in serialization")) }
|
||||||
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NullTransientProperty {
|
private class NullTransientProperty {
|
||||||
|
@ -5,16 +5,12 @@ import net.corda.core.internal.lazyMapped
|
|||||||
import net.corda.core.internal.TransactionDeserialisationException
|
import net.corda.core.internal.TransactionDeserialisationException
|
||||||
import net.corda.core.internal.eagerDeserialise
|
import net.corda.core.internal.eagerDeserialise
|
||||||
import net.corda.core.serialization.MissingAttachmentsException
|
import net.corda.core.serialization.MissingAttachmentsException
|
||||||
import org.junit.Rule
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.jupiter.api.assertThrows
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class LazyMappedListTest {
|
class LazyMappedListTest {
|
||||||
|
|
||||||
@get:Rule
|
|
||||||
val exception: ExpectedException = ExpectedException.none()
|
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `LazyMappedList works`() {
|
fun `LazyMappedList works`() {
|
||||||
val originalList = (1 until 10).toList()
|
val originalList = (1 until 10).toList()
|
||||||
@ -44,14 +40,13 @@ class LazyMappedListTest {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun testMissingAttachments() {
|
fun testMissingAttachments() {
|
||||||
exception.expect(MissingAttachmentsException::class.java)
|
val anException = assertThrows<MissingAttachmentsException> {
|
||||||
exception.expectMessage("Uncatchable!")
|
val lazyList = (0 until 5).toList().lazyMapped<Int, Int> { _, _ ->
|
||||||
|
throw MissingAttachmentsException(emptyList(), "Uncatchable!")
|
||||||
val lazyList = (0 until 5).toList().lazyMapped<Int, Int> { _, _ ->
|
}
|
||||||
throw MissingAttachmentsException(emptyList(), "Uncatchable!")
|
lazyList.eagerDeserialise { _, _ -> -999 }
|
||||||
}
|
}
|
||||||
|
assertEquals("Uncatchable!", anException.message)
|
||||||
lazyList.eagerDeserialise { _, _ -> -999 }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
|
@ -40,7 +40,7 @@ import org.junit.After
|
|||||||
import org.junit.AfterClass
|
import org.junit.AfterClass
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.jupiter.api.assertThrows
|
||||||
import org.junit.rules.TemporaryFolder
|
import org.junit.rules.TemporaryFolder
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@ -54,16 +54,13 @@ import kotlin.io.path.readBytes
|
|||||||
import kotlin.io.path.useDirectoryEntries
|
import kotlin.io.path.useDirectoryEntries
|
||||||
import kotlin.io.path.writeBytes
|
import kotlin.io.path.writeBytes
|
||||||
import kotlin.io.path.writeText
|
import kotlin.io.path.writeText
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class NetworkBootstrapperTest {
|
class NetworkBootstrapperTest {
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val tempFolder = TemporaryFolder()
|
val tempFolder = TemporaryFolder()
|
||||||
|
|
||||||
@Rule
|
|
||||||
@JvmField
|
|
||||||
val expectedEx: ExpectedException = ExpectedException.none()
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
@ -304,9 +301,10 @@ class NetworkBootstrapperTest {
|
|||||||
assertContainsPackageOwner("alice", mapOf(Pair(greedyNamespace, alice.publicKey)))
|
assertContainsPackageOwner("alice", mapOf(Pair(greedyNamespace, alice.publicKey)))
|
||||||
// register overlapping package name
|
// register overlapping package name
|
||||||
createNodeConfFile("bob", bobConfig)
|
createNodeConfFile("bob", bobConfig)
|
||||||
expectedEx.expect(IllegalArgumentException::class.java)
|
val anException = assertThrows<IllegalArgumentException> {
|
||||||
expectedEx.expectMessage("Multiple packages added to the packageOwnership overlap.")
|
bootstrap(packageOwnership = mapOf(Pair(greedyNamespace, alice.publicKey), Pair(bobPackageName, bob.publicKey)))
|
||||||
bootstrap(packageOwnership = mapOf(Pair(greedyNamespace, alice.publicKey), Pair(bobPackageName, bob.publicKey)))
|
}
|
||||||
|
assertEquals("Multiple packages added to the packageOwnership overlap.", anException.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
|
@ -60,7 +60,7 @@ class NodeStatePersistenceTests {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
assertNotNull(stateAndRef)
|
assertNotNull(stateAndRef)
|
||||||
val retrievedMessage = stateAndRef!!.state.data.message
|
val retrievedMessage = stateAndRef.state.data.message
|
||||||
assertEquals(message, retrievedMessage)
|
assertEquals(message, retrievedMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class NodeStatePersistenceTests {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
assertNotNull(stateAndRef)
|
assertNotNull(stateAndRef)
|
||||||
val retrievedMessage = stateAndRef!!.state.data.message
|
val retrievedMessage = stateAndRef.state.data.message
|
||||||
assertEquals(message, retrievedMessage)
|
assertEquals(message, retrievedMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class NodeRegistrationTest {
|
|||||||
pollInterval = 1.seconds,
|
pollInterval = 1.seconds,
|
||||||
hostAndPort = portAllocation.nextHostAndPort(),
|
hostAndPort = portAllocation.nextHostAndPort(),
|
||||||
myHostNameValue = "localhost",
|
myHostNameValue = "localhost",
|
||||||
additionalServices = *arrayOf(registrationHandler))
|
additionalServices = arrayOf(registrationHandler))
|
||||||
serverHostAndPort = server.start()
|
serverHostAndPort = server.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,11 +306,11 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging,
|
|||||||
log.info("Error ${index + 1} of ${errors.size}:", error)
|
log.info("Error ${index + 1} of ${errors.size}:", error)
|
||||||
val diagnoses: Map<Diagnosis, List<Staff>> = staff.groupBy { it.consult(flowFiber, currentState, error, medicalHistory) }
|
val diagnoses: Map<Diagnosis, List<Staff>> = staff.groupBy { it.consult(flowFiber, currentState, error, medicalHistory) }
|
||||||
// We're only interested in the highest priority diagnosis for the error
|
// We're only interested in the highest priority diagnosis for the error
|
||||||
val (diagnosis, by) = diagnoses.entries.minBy { it.key }!!
|
val (diagnosis, by) = diagnoses.entries.minBy { it.key }
|
||||||
ConsultationReport(error, diagnosis, by)
|
ConsultationReport(error, diagnosis, by)
|
||||||
}
|
}
|
||||||
// And we're only interested in the error with the highest priority diagnosis
|
// And we're only interested in the error with the highest priority diagnosis
|
||||||
.minBy { it.diagnosis }!!
|
.minBy { it.diagnosis }
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class ConsultationReport(val error: Throwable, val diagnosis: Diagnosis, val by: List<Staff>)
|
private data class ConsultationReport(val error: Throwable, val diagnosis: Diagnosis, val by: List<Staff>)
|
||||||
|
@ -412,7 +412,7 @@ class FlowMetadataRecordingTest {
|
|||||||
metadata!!.let {
|
metadata!!.let {
|
||||||
assertNull(it.finishInstant)
|
assertNull(it.finishInstant)
|
||||||
assertNotNull(finishTime)
|
assertNotNull(finishTime)
|
||||||
assertTrue(finishTime!! >= it.startInstant)
|
assertTrue(finishTime >= it.startInstant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import net.corda.testing.core.*
|
|||||||
import net.corda.testing.internal.vault.DummyLinearStateSchemaV1
|
import net.corda.testing.internal.vault.DummyLinearStateSchemaV1
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.junit.*
|
import org.junit.*
|
||||||
import org.junit.rules.ExpectedException
|
|
||||||
|
|
||||||
class VaultQueryExceptionsTests : VaultQueryParties by rule {
|
class VaultQueryExceptionsTests : VaultQueryParties by rule {
|
||||||
|
|
||||||
@ -30,10 +29,6 @@ class VaultQueryExceptionsTests : VaultQueryParties by rule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule
|
|
||||||
@JvmField
|
|
||||||
val expectedEx: ExpectedException = ExpectedException.none()
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val rollbackRule = VaultQueryRollbackRule(this)
|
val rollbackRule = VaultQueryRollbackRule(this)
|
||||||
|
@ -45,7 +45,8 @@ import org.junit.ClassRule
|
|||||||
import org.junit.Ignore
|
import org.junit.Ignore
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
import org.junit.rules.ExternalResource
|
import org.junit.rules.ExternalResource
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
@ -148,7 +149,7 @@ open class VaultQueryTestRule(private val persistentServices: Boolean) : Externa
|
|||||||
cordappPackages,
|
cordappPackages,
|
||||||
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
||||||
megaCorp,
|
megaCorp,
|
||||||
moreKeys = *arrayOf(DUMMY_NOTARY_KEY)
|
moreKeys = arrayOf(DUMMY_NOTARY_KEY)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
database = databaseAndServices.first
|
database = databaseAndServices.first
|
||||||
@ -184,10 +185,6 @@ class VaultQueryRollbackRule(private val vaultQueryParties: VaultQueryParties) :
|
|||||||
|
|
||||||
abstract class VaultQueryTestsBase : VaultQueryParties {
|
abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||||
|
|
||||||
@Rule
|
|
||||||
@JvmField
|
|
||||||
val expectedEx: ExpectedException = ExpectedException.none()
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ClassRule @JvmField
|
@ClassRule @JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
@ -1006,10 +1003,11 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5)
|
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5)
|
||||||
|
|
||||||
// missing lockId
|
// missing lockId
|
||||||
expectedEx.expect(VaultQueryException::class.java)
|
val anException = assertThrows<VaultQueryException> {
|
||||||
expectedEx.expectMessage("Must specify one or more lockIds")
|
val criteriaMissingLockId = VaultQueryCriteria(softLockingCondition = SoftLockingCondition(SoftLockingType.UNLOCKED_AND_SPECIFIED))
|
||||||
val criteriaMissingLockId = VaultQueryCriteria(softLockingCondition = SoftLockingCondition(SoftLockingType.UNLOCKED_AND_SPECIFIED))
|
vaultService.queryBy<ContractState>(criteriaMissingLockId)
|
||||||
vaultService.queryBy<ContractState>(criteriaMissingLockId)
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("Must specify one or more lockIds")) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1707,44 +1705,43 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
|||||||
// pagination: invalid page number
|
// pagination: invalid page number
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `invalid page number`() {
|
fun `invalid page number`() {
|
||||||
expectedEx.expect(VaultQueryException::class.java)
|
val anException = assertThrows<VaultQueryException> {
|
||||||
expectedEx.expectMessage("Page specification: invalid page number")
|
database.transaction {
|
||||||
|
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
||||||
database.transaction {
|
val pagingSpec = PageSpecification(0, 10)
|
||||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||||
val pagingSpec = PageSpecification(0, 10)
|
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
||||||
|
}
|
||||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
|
||||||
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
|
||||||
}
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("Page specification: invalid page number")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// pagination: invalid page size
|
// pagination: invalid page size
|
||||||
@Suppress("INTEGER_OVERFLOW")
|
@Suppress("INTEGER_OVERFLOW")
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `invalid page size`() {
|
fun `invalid page size`() {
|
||||||
expectedEx.expect(VaultQueryException::class.java)
|
val anException = assertThrows<VaultQueryException> {
|
||||||
expectedEx.expectMessage("Page specification: invalid page size")
|
database.transaction {
|
||||||
|
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
||||||
database.transaction {
|
val pagingSpec = PageSpecification(DEFAULT_PAGE_NUM, Integer.MAX_VALUE + 1) // overflow = -2147483648
|
||||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||||
val pagingSpec = PageSpecification(DEFAULT_PAGE_NUM, Integer.MAX_VALUE + 1) // overflow = -2147483648
|
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
||||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
}
|
||||||
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
|
||||||
}
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("Page specification: invalid page size")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// pagination not specified but more than DEFAULT_PAGE_SIZE results available (fail-fast test)
|
// pagination not specified but more than DEFAULT_PAGE_SIZE results available (fail-fast test)
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `pagination not specified but more than default results available`() {
|
fun `pagination not specified but more than default results available`() {
|
||||||
expectedEx.expect(VaultQueryException::class.java)
|
val anException = assertThrows<VaultQueryException> {
|
||||||
expectedEx.expectMessage("provide a PageSpecification")
|
database.transaction {
|
||||||
|
vaultFiller.fillWithSomeTestCash(201.DOLLARS, notaryServices, 201, DUMMY_CASH_ISSUER)
|
||||||
database.transaction {
|
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||||
vaultFiller.fillWithSomeTestCash(201.DOLLARS, notaryServices, 201, DUMMY_CASH_ISSUER)
|
vaultService.queryBy<ContractState>(criteria)
|
||||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
}
|
||||||
vaultService.queryBy<ContractState>(criteria)
|
|
||||||
}
|
}
|
||||||
|
anException.message?.let { assertTrue(it.contains("provide a PageSpecification")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// example of querying states with paging using totalStatesAvailable
|
// example of querying states with paging using totalStatesAvailable
|
||||||
|
@ -83,7 +83,7 @@ class VaultWithCashTest {
|
|||||||
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
||||||
TestIdentity(MEGA_CORP.name, servicesKey),
|
TestIdentity(MEGA_CORP.name, servicesKey),
|
||||||
networkParameters,
|
networkParameters,
|
||||||
moreKeys = *arrayOf(dummyNotary.keyPair))
|
moreKeys = arrayOf(dummyNotary.keyPair))
|
||||||
database = databaseAndServices.first
|
database = databaseAndServices.first
|
||||||
services = databaseAndServices.second
|
services = databaseAndServices.second
|
||||||
vaultFiller = VaultFiller(services, dummyNotary)
|
vaultFiller = VaultFiller(services, dummyNotary)
|
||||||
|
@ -131,7 +131,7 @@ object SimmFlow {
|
|||||||
|
|
||||||
val valuer = serviceHub.identityService.wellKnownPartyFromAnonymous(state.valuer)
|
val valuer = serviceHub.identityService.wellKnownPartyFromAnonymous(state.valuer)
|
||||||
require(valuer != null) { "Valuer party must be known to this node" }
|
require(valuer != null) { "Valuer party must be known to this node" }
|
||||||
val valuation = agreeValuation(portfolio, valuationDate, valuer!!)
|
val valuation = agreeValuation(portfolio, valuationDate, valuer)
|
||||||
val update = PortfolioState.Update(valuation = valuation)
|
val update = PortfolioState.Update(valuation = valuation)
|
||||||
return subFlow(StateRevisionFlowRequester(otherPartySession, stateRef, update)).state.data
|
return subFlow(StateRevisionFlowRequester(otherPartySession, stateRef, update)).state.data
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ object SimmRevaluation {
|
|||||||
if (ourIdentity == curState.participants[0]) {
|
if (ourIdentity == curState.participants[0]) {
|
||||||
val otherParty = serviceHub.identityService.wellKnownPartyFromAnonymous(curState.participants[1])
|
val otherParty = serviceHub.identityService.wellKnownPartyFromAnonymous(curState.participants[1])
|
||||||
require(otherParty != null) { "Other party must be known by this node" }
|
require(otherParty != null) { "Other party must be known by this node" }
|
||||||
subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef))
|
subFlow(SimmFlow.Requester(otherParty, valuationDate, stateAndRef))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,8 @@ import net.corda.testing.internal.TestingNamedCacheFactory
|
|||||||
import net.corda.testing.internal.services.InternalMockAttachmentStorage
|
import net.corda.testing.internal.services.InternalMockAttachmentStorage
|
||||||
import net.corda.testing.services.MockAttachmentStorage
|
import net.corda.testing.services.MockAttachmentStorage
|
||||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||||
import org.junit.Rule
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.jupiter.api.assertThrows
|
||||||
import org.mockito.kotlin.any
|
import org.mockito.kotlin.any
|
||||||
import org.mockito.kotlin.doReturn
|
import org.mockito.kotlin.doReturn
|
||||||
import org.mockito.kotlin.verify
|
import org.mockito.kotlin.verify
|
||||||
@ -267,16 +266,15 @@ class CordaClassResolverTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Blacklist tests. Note: leave the variable public or else expected messages do not work correctly
|
// Blacklist tests. Note: leave the variable public or else expected messages do not work correctly
|
||||||
@get:Rule
|
|
||||||
val expectedEx = ExpectedException.none()!!
|
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklisted class`() {
|
fun `Check blacklisted class`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("Class java.util.HashSet is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// HashSet is blacklisted.
|
||||||
// HashSet is blacklisted.
|
resolver.getRegistration(HashSet::class.java)
|
||||||
resolver.getRegistration(HashSet::class.java)
|
}
|
||||||
|
assertEquals("Class java.util.HashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
@ -349,33 +347,37 @@ class CordaClassResolverTests {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklisted subclass`() {
|
fun `Check blacklisted subclass`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubHashSet is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// SubHashSet extends the blacklisted HashSet.
|
||||||
// SubHashSet extends the blacklisted HashSet.
|
resolver.getRegistration(SubHashSet::class.java)
|
||||||
resolver.getRegistration(SubHashSet::class.java)
|
}
|
||||||
|
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
class SubSubHashSet<E> : SubHashSet<E>()
|
class SubSubHashSet<E> : SubHashSet<E>()
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklisted subsubclass`() {
|
fun `Check blacklisted subsubclass`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubSubHashSet is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// SubSubHashSet extends SubHashSet, which extends the blacklisted HashSet.
|
||||||
// SubSubHashSet extends SubHashSet, which extends the blacklisted HashSet.
|
resolver.getRegistration(SubSubHashSet::class.java)
|
||||||
resolver.getRegistration(SubSubHashSet::class.java)
|
}
|
||||||
|
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubSubHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConnectionImpl(private val connection: Connection) : Connection by connection
|
class ConnectionImpl(private val connection: Connection) : Connection by connection
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklisted interface impl`() {
|
fun `Check blacklisted interface impl`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$ConnectionImpl is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// ConnectionImpl implements blacklisted Connection.
|
||||||
// ConnectionImpl implements blacklisted Connection.
|
resolver.getRegistration(ConnectionImpl::class.java)
|
||||||
resolver.getRegistration(ConnectionImpl::class.java)
|
}
|
||||||
|
assertEquals("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$ConnectionImpl is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SubConnection : Connection
|
interface SubConnection : Connection
|
||||||
@ -383,11 +385,13 @@ class CordaClassResolverTests {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklisted super-interface impl`() {
|
fun `Check blacklisted super-interface impl`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$SubConnectionImpl is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// SubConnectionImpl implements SubConnection, which extends the blacklisted Connection.
|
||||||
// SubConnectionImpl implements SubConnection, which extends the blacklisted Connection.
|
resolver.getRegistration(SubConnectionImpl::class.java)
|
||||||
resolver.getRegistration(SubConnectionImpl::class.java)
|
}
|
||||||
|
assertEquals("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$SubConnectionImpl is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
@ -402,10 +406,11 @@ class CordaClassResolverTests {
|
|||||||
|
|
||||||
@Test(timeout=300_000)
|
@Test(timeout=300_000)
|
||||||
fun `Check blacklist precedes CordaSerializable`() {
|
fun `Check blacklist precedes CordaSerializable`() {
|
||||||
expectedEx.expect(IllegalStateException::class.java)
|
val anException = assertThrows<IllegalStateException> {
|
||||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$CordaSerializableHashSet is blacklisted, so it cannot be used in serialization.")
|
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
// CordaSerializableHashSet is @CordaSerializable, but extends the blacklisted HashSet.
|
||||||
// CordaSerializableHashSet is @CordaSerializable, but extends the blacklisted HashSet.
|
resolver.getRegistration(CordaSerializableHashSet::class.java)
|
||||||
resolver.getRegistration(CordaSerializableHashSet::class.java)
|
}
|
||||||
|
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$CordaSerializableHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ private class SpectatorDefaultAnswer : DefaultAnswer() {
|
|||||||
?: method.returnType!!
|
?: method.returnType!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun newSpectator(invocation: InvocationOnMock) = spectator(type)!!.also { log.info("New spectator {} for: {}", it, invocation.arguments) }
|
private fun newSpectator(invocation: InvocationOnMock) = spectator(type).also { log.info("New spectator {} for: {}", it, invocation.arguments) }
|
||||||
private val spectators = try {
|
private val spectators = try {
|
||||||
val first = newSpectator(invocation)
|
val first = newSpectator(invocation)
|
||||||
ConcurrentHashMap<InvocationOnMock, Any>().apply { put(invocation, first) }
|
ConcurrentHashMap<InvocationOnMock, Any>().apply { put(invocation, first) }
|
||||||
|
@ -232,7 +232,7 @@ class NetworkMapServer(private val pollInterval: Duration,
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
requireNotNull(requestedParameters)
|
requireNotNull(requestedParameters)
|
||||||
return Response.ok(requestedParameters!!.serialize().bytes).build()
|
return Response.ok(requestedParameters.serialize().bytes).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@ -57,7 +57,7 @@ class TransactionViewer : CordaView("Transactions") {
|
|||||||
override val widgets = listOf(CordaWidget(title, TransactionWidget(), icon)).observable()
|
override val widgets = listOf(CordaWidget(title, TransactionWidget(), icon)).observable()
|
||||||
|
|
||||||
private var scrollPosition: Int = 0
|
private var scrollPosition: Int = 0
|
||||||
private lateinit var expander: ExpanderColumn<TransactionViewer.Transaction>
|
private var expander: ExpanderColumn<TransactionViewer.Transaction>
|
||||||
private var txIdToScroll: SecureHash? = null // Passed as param.
|
private var txIdToScroll: SecureHash? = null // Passed as param.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ class NodeConnection(val remoteNode: RemoteNode, private val jSchSession: Sessio
|
|||||||
val connection = rpcConnection
|
val connection = rpcConnection
|
||||||
require(connection != null) { "doWhileClientStopped called with no running client" }
|
require(connection != null) { "doWhileClientStopped called with no running client" }
|
||||||
log.info("Stopping RPC proxy to ${remoteNode.hostname}, tunnel at $localTunnelAddress")
|
log.info("Stopping RPC proxy to ${remoteNode.hostname}, tunnel at $localTunnelAddress")
|
||||||
connection!!.close()
|
connection.close()
|
||||||
try {
|
try {
|
||||||
return action()
|
return action()
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user