mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
[NOTICK] Add a detekt rule to catch tests with no timeout (#5959)
* [NOTICK] Add a custom detekt rule for tests with no timeout, and fix remaining missing timeouts * [NOTICK] Add a test for custom detekt rules and tidying * add timeout annotation to new test Co-authored-by: Stefano Franz <roastario@gmail.com>
This commit is contained in:
parent
014a03575e
commit
3547b629c3
@ -125,6 +125,7 @@ buildscript {
|
||||
ext.commons_lang_version = '3.9'
|
||||
ext.commons_io_version = '2.6'
|
||||
ext.controlsfx_version = '8.40.15'
|
||||
ext.detekt_version = constants.getProperty('detektVersion')
|
||||
if (JavaVersion.current() == JavaVersion.VERSION_11) {
|
||||
// has been compiled by a more recent version of the Java Runtime (class file version 55.0)
|
||||
ext.fontawesomefx_commons_version = '11.0'
|
||||
@ -464,13 +465,14 @@ task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
|
||||
}
|
||||
}
|
||||
|
||||
task detekt(type: JavaExec) {
|
||||
task detekt(type: JavaExec, dependsOn: ":detekt-plugins:jar") {
|
||||
main = "io.gitlab.arturbosch.detekt.cli.Main"
|
||||
classpath = configurations.detekt
|
||||
def input = "$projectDir"
|
||||
def config = "$projectDir/detekt-config.yml"
|
||||
def baseline = "$projectDir/detekt-baseline.xml"
|
||||
def params = ['-i', input, '-c', config, '-b', baseline]
|
||||
def plugins = "$projectDir/detekt-plugins/build/libs/detekt-plugins-${version}.jar"
|
||||
def params = ['-i', input, '-c', config, '-b', baseline, '--plugins', plugins]
|
||||
args(params)
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ class CordaRPCClientTest : NodeBasedTest(listOf("net.corda.finance"), notaries =
|
||||
assertThat(outOfProcessRpc.waitFor()).isZero() // i.e. no exceptions were thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(timeout=300_000)
|
||||
fun `nonspecific reconnect errors dont trigger graceful reconnect`() {
|
||||
val inputJar1 = Thread.currentThread().contextClassLoader.getResourceAsStream(testJar)!!
|
||||
val inputJar2 = Thread.currentThread().contextClassLoader.getResourceAsStream(testJar)!!
|
||||
|
@ -72,7 +72,7 @@ class RpcCustomSerializersTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(timeout=300_000)
|
||||
fun `when a custom serializer is missing from the rpc client the resulting exception progagtes and client does not reconnect`() {
|
||||
driver(DriverParameters(startNodesInProcess = false, cordappsForAllNodes = listOf(enclosedCordapp()))) {
|
||||
val server = startNode(providedName = ALICE_NAME).get()
|
||||
|
@ -35,4 +35,5 @@ deterministicRtVersion=1.0-RC02
|
||||
openSourceBranch=https://github.com/corda/corda/blob/release/os/4.4
|
||||
openSourceSamplesBranch=https://github.com/corda/samples/blob/release-V4
|
||||
jolokiaAgentVersion=1.6.1
|
||||
detektVersion=1.0.1
|
||||
|
||||
|
@ -71,7 +71,7 @@ class GenerateData {
|
||||
testSerialization.reset()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(timeout = 300_000)
|
||||
fun verifyTransactions() {
|
||||
URLClassLoader(arrayOf(TEST_DATA.toUri().toURL())).use { cl ->
|
||||
cl.loadResource("txverify/tx-success.bin")
|
||||
|
@ -47,7 +47,7 @@ class RequireSingleCommandTests(private val testFunction: (Collection<CommandWit
|
||||
assertEquals(returnedCommand, validCommandOne, "they should be the same")
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class, timeout=300_000)
|
||||
fun `check error is thrown if more than one valid command`() {
|
||||
val commands = listOf(validCommandOne, validCommandTwo)
|
||||
testFunction(commands)
|
||||
|
@ -181,7 +181,7 @@ class CompositeKeyTests {
|
||||
assertFalse { engine.verify(CompositeSignaturesWithKeys(listOf(aliceSignature, brokenBobSignature)).serialize().bytes) }
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test(timeout=300_000)
|
||||
fun `composite key constraints`() {
|
||||
// Zero weight.
|
||||
assertFailsWith(IllegalArgumentException::class) {
|
||||
@ -223,7 +223,7 @@ class CompositeKeyTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test(timeout=300_000)
|
||||
fun `composite key validation with graph cycle detection`() = kryoSpecific("Cycle exists in the object graph which is not currently supported in AMQP mode") {
|
||||
val key1 = CompositeKey.Builder().addKeys(alicePublicKey, bobPublicKey).build() as CompositeKey
|
||||
val key2 = CompositeKey.Builder().addKeys(alicePublicKey, key1).build() as CompositeKey
|
||||
|
@ -270,7 +270,7 @@ class PartialMerkleTreeTest {
|
||||
assertFalse(pmt.verify(wrongRoot, inclHashes))
|
||||
}
|
||||
|
||||
@Test(expected = Exception::class)
|
||||
@Test(expected = Exception::class, timeout=300_000)
|
||||
fun `hash map serialization not allowed`() {
|
||||
val hm1 = hashMapOf("a" to 1, "b" to 2, "c" to 3, "e" to 4)
|
||||
hm1.serialize()
|
||||
|
@ -35,7 +35,7 @@ class SignedDataTest {
|
||||
assertEquals(data, unwrappedData)
|
||||
}
|
||||
|
||||
@Test(expected = SignatureException::class)
|
||||
@Test(expected = SignatureException::class, timeout=300_000)
|
||||
fun `make sure incorrectly signed data raises an exception`() {
|
||||
val keyPairA = generateKeyPair()
|
||||
val keyPairB = generateKeyPair()
|
||||
|
@ -39,7 +39,7 @@ class TransactionSignatureTest {
|
||||
}
|
||||
|
||||
/** Verification should fail; corrupted metadata - clearData (Merkle root) has changed. */
|
||||
@Test(expected = SignatureException::class)
|
||||
@Test(expected = SignatureException::class,timeout=300_000)
|
||||
fun `Signature metadata full failure clearData has changed`() {
|
||||
val keyPair = Crypto.generateKeyPair("ECDSA_SECP256K1_SHA256")
|
||||
val signableData = SignableData(testBytes.sha256(), SignatureMetadata(1, Crypto.findSignatureScheme(keyPair.public).schemeNumberID))
|
||||
|
@ -127,7 +127,7 @@ class CollectSignaturesFlowTests : WithContracts {
|
||||
Assert.assertThat(missingSigners, `is`(emptySet()))
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class, timeout=300_000)
|
||||
fun `throws exception when extra sessions are initiated`() {
|
||||
bobNode.registerInitiatedFlow(ExtraSessionsFlowResponder::class.java)
|
||||
charlieNode.registerInitiatedFlow(ExtraSessionsFlowResponder::class.java)
|
||||
|
@ -664,7 +664,7 @@ class CryptoUtilsTest {
|
||||
assertFalse(Crypto.publicKeyOnCurve(EDDSA_ED25519_SHA512, EdDSAPublicKey(pubKeySpec)))
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class, timeout = 300_000)
|
||||
fun `Unsupported EC public key type on curve`() {
|
||||
val keyGen = KeyPairGenerator.getInstance("EC") // sun.security.ec.ECPublicKeyImpl
|
||||
keyGen.initialize(256, newSecureRandom())
|
||||
|
@ -69,7 +69,7 @@ class ClassLoadingUtilsTest {
|
||||
.doesNotContain(AbstractClass::class.java.name)
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class,timeout=300_000)
|
||||
fun throwsExceptionWhenClassDoesNotContainProperConstructors() {
|
||||
createInstancesOfClassesImplementing(BaseInterface::class.java.classLoader, BaseInterface2::class.java)
|
||||
}
|
||||
|
26
detekt-plugins/build.gradle
Normal file
26
detekt-plugins/build.gradle
Normal file
@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'kotlin'
|
||||
id 'kotlin-jpa'
|
||||
}
|
||||
|
||||
group 'net.corda'
|
||||
version '4.4-SNAPSHOT'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
testImplementation "io.gitlab.arturbosch.detekt:detekt-test:$detekt_version"
|
||||
testImplementation "org.assertj:assertj-core:$assertj_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "io.gitlab.arturbosch.detekt:detekt-api:$detekt_version"
|
||||
}
|
||||
|
||||
publish {
|
||||
name "corda-detekt-plugins"
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.corda.detekt.plugins
|
||||
|
||||
import io.gitlab.arturbosch.detekt.api.Config
|
||||
import io.gitlab.arturbosch.detekt.api.RuleSet
|
||||
import io.gitlab.arturbosch.detekt.api.RuleSetProvider
|
||||
import net.corda.detekt.plugins.rules.TestWithMissingTimeout
|
||||
|
||||
// When adding new detekt rules, add the new rule to the list of instances below.
|
||||
class CordaDetektProvider : RuleSetProvider {
|
||||
|
||||
override val ruleSetId: String = "corda-detekt"
|
||||
|
||||
override fun instance(config: Config): RuleSet = RuleSet(
|
||||
ruleSetId,
|
||||
listOf(
|
||||
TestWithMissingTimeout()
|
||||
)
|
||||
)
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.corda.detekt.plugins.rules
|
||||
|
||||
import io.gitlab.arturbosch.detekt.api.CodeSmell
|
||||
import io.gitlab.arturbosch.detekt.api.Debt
|
||||
import io.gitlab.arturbosch.detekt.api.Entity
|
||||
import io.gitlab.arturbosch.detekt.api.Issue
|
||||
import io.gitlab.arturbosch.detekt.api.Rule
|
||||
import io.gitlab.arturbosch.detekt.api.Severity
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
|
||||
class TestWithMissingTimeout : Rule() {
|
||||
|
||||
override val issue = Issue(
|
||||
javaClass.simpleName,
|
||||
Severity.Security,
|
||||
"This rule reports a test case with a missing timeout field in the @Test annotation",
|
||||
Debt.FIVE_MINS
|
||||
)
|
||||
|
||||
// Checks that the test is using JUnit 4 by looking at the imports in the file. This is a little questionable, but this information is
|
||||
// otherwise not exposed.
|
||||
private fun isTestAnnotationJunit4(annotationEntry: KtAnnotationEntry): Boolean {
|
||||
return annotationEntry.containingKtFile.importDirectives.any { it.importPath?.fqName?.asString() == "org.junit.Test" }
|
||||
}
|
||||
|
||||
// Look at all annotations. If they are named "Test", and the corresponding file has a JUnit 4 Test import in, assume that all these
|
||||
// annotations are JUnit Tests and report if they do not have a "timeout" argument.
|
||||
// Note that this doesn't apply to JUnit 5 as the test annotation does not take a timeout argument in this case.
|
||||
override fun visitAnnotationEntry(annotationEntry: KtAnnotationEntry) {
|
||||
if (annotationEntry.shortName.toString() == "Test" && isTestAnnotationJunit4(annotationEntry)) {
|
||||
val params = annotationEntry.valueArguments
|
||||
if (params.none { it.getArgumentName()?.asName?.identifier == "timeout" }) {
|
||||
report(CodeSmell(issue, Entity.from(annotationEntry), "Missing timeout parameter from Test annotation"))
|
||||
}
|
||||
}
|
||||
super.visitAnnotationEntry(annotationEntry)
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
net.corda.detekt.plugins.CordaDetektProvider
|
@ -0,0 +1,77 @@
|
||||
package net.corda.detekt.plugins.rules
|
||||
|
||||
import io.gitlab.arturbosch.detekt.test.assertThat
|
||||
import io.gitlab.arturbosch.detekt.test.lint
|
||||
import org.junit.Test
|
||||
|
||||
class TestWithMissingTimeoutTest {
|
||||
|
||||
private val junit4Code = """
|
||||
import org.junit.Test
|
||||
import org.junit.Assert
|
||||
|
||||
class JUnit4Test {
|
||||
@Test
|
||||
@Ignore
|
||||
fun `test that foo is not bar`() {
|
||||
Assert.assertFalse("foo" == "bar")
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
private val junit5Code = """
|
||||
package net.corda.serialization.djvm
|
||||
|
||||
import net.corda.core.serialization.internal._contextSerializationEnv
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.serialization.djvm.SandboxType.KOTLIN
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.junit.jupiter.api.fail
|
||||
import java.time.Instant
|
||||
import java.util.function.Function
|
||||
|
||||
@ExtendWith(LocalSerialization::class)
|
||||
class DeserializeInstantTest : TestBase(KOTLIN) {
|
||||
@Test
|
||||
fun `test deserializing instant`() {
|
||||
val instant = Instant.now()
|
||||
val data = instant.serialize()
|
||||
|
||||
sandbox {
|
||||
_contextSerializationEnv.set(createSandboxSerializationEnv(classLoader))
|
||||
|
||||
val sandboxInstant = data.deserializeFor(classLoader)
|
||||
|
||||
val taskFactory = classLoader.createRawTaskFactory()
|
||||
val showInstant = taskFactory.compose(classLoader.createSandboxFunction()).apply(ShowInstant::class.java)
|
||||
val result = showInstant.apply(sandboxInstant) ?: fail("Result cannot be null")
|
||||
|
||||
assertEquals(instant.toString(), result.toString())
|
||||
assertEquals(SANDBOX_STRING, result::class.java.name)
|
||||
}
|
||||
}
|
||||
|
||||
class ShowInstant : Function<Instant, String> {
|
||||
override fun apply(instant: Instant): String {
|
||||
return instant.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
@Test(timeout = 300_000)
|
||||
fun `catches missing timeout for junit 4 tests`() {
|
||||
val rule = TestWithMissingTimeout()
|
||||
val findings = rule.lint(junit4Code)
|
||||
assertThat(findings).hasSize(1)
|
||||
}
|
||||
|
||||
@Test(timeout = 300_000)
|
||||
fun `does not warn for junit 5 tests`() {
|
||||
val rule = TestWithMissingTimeout()
|
||||
val findings = rule.lint(junit5Code)
|
||||
assertThat(findings).hasSize(0)
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@ class TutorialTestDSL {
|
||||
|
||||
// DOCSTART 2
|
||||
// This example test will fail with this exception.
|
||||
@Test(expected = IllegalStateException::class)
|
||||
@Test(expected = IllegalStateException::class, timeout=300_000)
|
||||
fun simpleCP() {
|
||||
val inState = getPaper()
|
||||
ledgerServices.ledger(dummyNotary.party) {
|
||||
@ -92,7 +92,7 @@ class TutorialTestDSL {
|
||||
|
||||
// DOCSTART 3
|
||||
// This example test will fail with this exception.
|
||||
@Test(expected = TransactionVerificationException.ContractRejection::class)
|
||||
@Test(expected = TransactionVerificationException.ContractRejection::class, timeout=300_000)
|
||||
fun simpleCPMove() {
|
||||
val inState = getPaper()
|
||||
ledgerServices.ledger(dummyNotary.party) {
|
||||
|
@ -121,7 +121,7 @@ class Caplet {
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test(timeout=300_000) @Ignore
|
||||
fun `pretty print`() {
|
||||
println ( prettyPrint(contract) )
|
||||
|
||||
|
@ -117,7 +117,7 @@ class Examples {
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test(timeout=300_000) @Ignore
|
||||
fun `pretty print`() {
|
||||
println ( prettyPrint(cds_contract) )
|
||||
|
||||
|
@ -125,7 +125,7 @@ class FXFwdTimeOption {
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test(timeout=300_000) @Ignore
|
||||
fun `pretty print`() {
|
||||
println ( prettyPrint(initialContract) )
|
||||
|
||||
|
@ -164,7 +164,7 @@ class FXSwap {
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test(timeout=300_000) @Ignore
|
||||
fun `pretty print`() {
|
||||
println ( prettyPrint(contract) )
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class IRS {
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test(timeout=300_000) @Ignore
|
||||
fun `pretty print`() {
|
||||
println ( prettyPrint(contractInitial) )
|
||||
|
||||
|
@ -300,7 +300,7 @@ class CashTests {
|
||||
* Test that the issuance builder rejects building into a transaction with existing
|
||||
* cash inputs.
|
||||
*/
|
||||
@Test(expected = IllegalStateException::class)
|
||||
@Test(expected = IllegalStateException::class, timeout=300_000)
|
||||
fun `reject issuance with inputs`() {
|
||||
// Issue some cash
|
||||
var ptx = TransactionBuilder(dummyNotary.party)
|
||||
@ -762,7 +762,7 @@ class CashTests {
|
||||
assertEquals(6000.DOLLARS `issued by` defaultIssuer, states.sumCashBy(megaCorp.party))
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException::class)
|
||||
@Test(expected = UnsupportedOperationException::class, timeout=300_000)
|
||||
fun `summing by owner throws`() {
|
||||
val states = listOf(
|
||||
Cash.State(2000.DOLLARS `issued by` defaultIssuer, megaCorp.party),
|
||||
@ -778,7 +778,7 @@ class CashTests {
|
||||
assertNull(states.sumCashOrNull())
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException::class)
|
||||
@Test(expected = UnsupportedOperationException::class, timeout=300_000)
|
||||
fun `summing no currencies throws`() {
|
||||
val states = emptyList<Cash.State>()
|
||||
states.sumCash()
|
||||
@ -797,7 +797,7 @@ class CashTests {
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class, timeout=300_000)
|
||||
fun `summing multiple currencies`() {
|
||||
val states = listOf(
|
||||
Cash.State(1000.DOLLARS `issued by` defaultIssuer, megaCorp.party),
|
||||
|
@ -253,7 +253,7 @@ class ObligationTests {
|
||||
* Test that the issuance builder rejects building into a transaction with existing
|
||||
* cash inputs.
|
||||
*/
|
||||
@Test(expected = IllegalStateException::class)
|
||||
@Test(expected = IllegalStateException::class, timeout=300_000)
|
||||
fun `reject issuance with inputs`() {
|
||||
// Issue some obligation
|
||||
val tx = TransactionBuilder(DUMMY_NOTARY).apply {
|
||||
@ -854,7 +854,7 @@ class ObligationTests {
|
||||
fiveKDollarsFromMegaToMega.copy(template = megaCorpDollarSettlement.copy(acceptableIssuedProducts = miniCorpIssuer)).bilateralNetState)
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
@Test(expected = IllegalStateException::class, timeout=300_000)
|
||||
fun `states cannot be netted if not in the normal state`() {
|
||||
inState.copy(lifecycle = Lifecycle.DEFAULTED).bilateralNetState
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class NodeFlowManagerTest {
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
@Test(expected = IllegalStateException::class, timeout = 300_000)
|
||||
fun `should fail to validate if more than one registration with equal weight`() {
|
||||
val nodeFlowManager = NodeFlowManager()
|
||||
nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java)
|
||||
@ -65,7 +65,7 @@ class NodeFlowManagerTest {
|
||||
nodeFlowManager.validateRegistrations()
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test(timeout = 300_000)
|
||||
fun `should allow registration of flows with different weights`() {
|
||||
val nodeFlowManager = NodeFlowManager()
|
||||
nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java)
|
||||
@ -76,7 +76,7 @@ class NodeFlowManagerTest {
|
||||
Assert.assertThat(flow, `is`(instanceOf(RespSub::class.java)))
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test(timeout = 300_000)
|
||||
fun `should allow updating of registered responder at runtime`() {
|
||||
val nodeFlowManager = NodeFlowManager()
|
||||
nodeFlowManager.registerInitiatedFlow(Init::class.java, Resp::class.java)
|
||||
|
@ -45,7 +45,7 @@ class CordappConfigFileProviderTests {
|
||||
assertThat(provider.getConfigByName(cordappName)).isEqualTo(alternateValidConfig)
|
||||
}
|
||||
|
||||
@Test(expected = ConfigException.Parse::class)
|
||||
@Test(expected = ConfigException.Parse::class, timeout=300_000)
|
||||
fun `an invalid config throws an exception`() {
|
||||
cordappConfFile.writeText(invalidConfig)
|
||||
provider.getConfigByName(cordappName)
|
||||
|
@ -37,7 +37,7 @@ class TypesafeCordappConfigTests {
|
||||
assertThat(cordappConf.exists("notexists")).isFalse()
|
||||
}
|
||||
|
||||
@Test(expected = CordappConfigException::class)
|
||||
@Test(expected = CordappConfigException::class, timeout=300_000)
|
||||
fun `test that an exception is thrown when trying to access a non-extant field`() {
|
||||
val config = ConfigFactory.empty()
|
||||
val cordappConf = TypesafeCordappConfig(config)
|
||||
|
@ -145,7 +145,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = InsufficientBalanceException::class)
|
||||
@Test(expected = InsufficientBalanceException::class, timeout=300_000)
|
||||
fun `trade cash for commercial paper fails using soft locking`() {
|
||||
mockNet = InternalMockNetwork(cordappsForAllNodes = listOf(FINANCE_CONTRACTS_CORDAPP), threadPerNode = true)
|
||||
val notaryNode = mockNet.defaultNotaryNode
|
||||
|
@ -77,7 +77,7 @@ class FlowLogicRefFactoryImplTest {
|
||||
flowLogicRefFactory.createKotlin(KotlinFlowLogic::class.java, args)
|
||||
}
|
||||
|
||||
@Test(expected = IllegalFlowLogicException::class)
|
||||
@Test(expected = IllegalFlowLogicException::class, timeout=300_000)
|
||||
fun `create for non-schedulable flow logic`() {
|
||||
flowLogicRefFactory.create(NonSchedulableFlow::class.jvmName)
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class CordaClassResolverTests {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(Foo.Bar::class.java)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Unannotated specialised enum does not work`() {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(BadFood.Mud::class.java)
|
||||
}
|
||||
@ -135,7 +135,7 @@ class CordaClassResolverTests {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(Simple.Easy::class.java)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Unannotated simple enum does not work`() {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(BadSimple.Nasty::class.java)
|
||||
}
|
||||
@ -146,7 +146,7 @@ class CordaClassResolverTests {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(values.javaClass)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Unannotated array elements do not work`() {
|
||||
val values = arrayOf(NotSerializable())
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(values.javaClass)
|
||||
@ -168,13 +168,13 @@ class CordaClassResolverTests {
|
||||
kryo.register(NotSerializable::class.java)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Calling register method on unmodified Kryo does consult the whitelist`() {
|
||||
val kryo = Kryo(CordaClassResolver(emptyWhitelistContext), MapReferenceResolver())
|
||||
kryo.register(NotSerializable::class.java)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Annotation is needed without whitelisting`() {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(NotSerializable::class.java)
|
||||
}
|
||||
@ -195,19 +195,19 @@ class CordaClassResolverTests {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(Integer.TYPE)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Annotation does not work for custom serializable`() {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(CustomSerializable::class.java)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Annotation does not work in conjunction with Kryo annotation`() {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(DefaultSerializable::class.java)
|
||||
}
|
||||
|
||||
private fun importJar(storage: AttachmentStorage, uploader: String = DEPLOYED_CORDAPP_UPLOADER) = ISOLATED_CONTRACTS_JAR_PATH.openStream().use { storage.importAttachment(it, uploader, "") }
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `Annotation does not work in conjunction with AttachmentClassLoader annotation`() {
|
||||
val storage = InternalMockAttachmentStorage(MockAttachmentStorage())
|
||||
val attachmentTrustCalculator = NodeAttachmentTrustCalculator(storage, TestingNamedCacheFactory())
|
||||
@ -217,7 +217,7 @@ class CordaClassResolverTests {
|
||||
CordaClassResolver(emptyWhitelistContext).getRegistration(attachedClass)
|
||||
}
|
||||
|
||||
@Test(expected = TransactionVerificationException.UntrustedAttachmentsException::class)
|
||||
@Test(expected = TransactionVerificationException.UntrustedAttachmentsException::class, timeout=300_000)
|
||||
fun `Attempt to load contract attachment with untrusted uploader should fail with UntrustedAttachmentsException`() {
|
||||
val storage = InternalMockAttachmentStorage(MockAttachmentStorage())
|
||||
val attachmentTrustCalculator = NodeAttachmentTrustCalculator(storage, TestingNamedCacheFactory())
|
||||
|
@ -70,7 +70,7 @@ class SerializationTokenTest {
|
||||
assertThat(tokenizableAfter).isSameAs(tokenizableBefore)
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException::class)
|
||||
@Test(expected = UnsupportedOperationException::class, timeout=300_000)
|
||||
fun `new token encountered after context init`() {
|
||||
val tokenizableBefore = UnitSerializeAsToken()
|
||||
val context = serializeAsTokenContext(emptyList<Any>())
|
||||
@ -78,7 +78,7 @@ class SerializationTokenTest {
|
||||
tokenizableBefore.checkpointSerialize(testContext)
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException::class)
|
||||
@Test(expected = UnsupportedOperationException::class, timeout=300_000)
|
||||
fun `deserialize unregistered token`() {
|
||||
val tokenizableBefore = UnitSerializeAsToken()
|
||||
val context = serializeAsTokenContext(emptyList<Any>())
|
||||
@ -87,13 +87,13 @@ class SerializationTokenTest {
|
||||
serializedBytes.checkpointDeserialize(testContext)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `no context set`() {
|
||||
val tokenizableBefore = UnitSerializeAsToken()
|
||||
tokenizableBefore.checkpointSerialize(context)
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `deserialize non-token`() {
|
||||
val tokenizableBefore = UnitSerializeAsToken()
|
||||
val context = serializeAsTokenContext(tokenizableBefore)
|
||||
@ -119,7 +119,7 @@ class SerializationTokenTest {
|
||||
override fun toToken(context: SerializeAsTokenContext): SerializationToken = UnitSerializationToken
|
||||
}
|
||||
|
||||
@Test(expected = KryoException::class)
|
||||
@Test(expected = KryoException::class, timeout=300_000)
|
||||
fun `token returns unexpected type`() {
|
||||
val tokenizableBefore = WrongTypeSerializeAsToken()
|
||||
val context = serializeAsTokenContext(tokenizableBefore)
|
||||
|
@ -322,7 +322,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
serdes(obj)
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
@Test(expected = IllegalArgumentException::class, timeout=300_000)
|
||||
fun `test dislike of HashMap`() {
|
||||
val obj = WrapHashMap(HashMap())
|
||||
serdes(obj)
|
||||
@ -364,7 +364,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
serdes(obj)
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun `test whitelist`() {
|
||||
val obj = Woo2(4)
|
||||
serdes(obj, SerializerFactoryBuilder.build(EmptyWhitelist,
|
||||
@ -380,7 +380,7 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
))
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun `test generic list subclass is not supported`() {
|
||||
val obj = FooList()
|
||||
serdes(obj)
|
||||
@ -458,13 +458,13 @@ class SerializationOutputTests(private val compression: CordaSerializationEncodi
|
||||
serdes(obj)
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun `test mismatched property and constructor naming`() {
|
||||
val obj = Mismatch(456)
|
||||
serdes(obj)
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun `test mismatched property and constructor type`() {
|
||||
val obj = MismatchType(456)
|
||||
serdes(obj)
|
||||
|
@ -100,47 +100,47 @@ class AMQPTypeIdentifierParserTests {
|
||||
verify("java.util.List<net.corda.core.contracts.Command<net.corda.core.contracts.Command<net.corda.core.contracts.CommandData>>>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test trailing text`() {
|
||||
verify("java.util.Map<java.lang.String, java.lang.Integer>foo")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test trailing comma`() {
|
||||
verify("java.util.Map<java.lang.String, java.lang.Integer,>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test leading comma`() {
|
||||
verify("java.util.Map<,java.lang.String, java.lang.Integer>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test middle comma`() {
|
||||
verify("java.util.Map<,java.lang.String,, java.lang.Integer>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test trailing close`() {
|
||||
verify("java.util.Map<java.lang.String, java.lang.Integer>>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test empty params`() {
|
||||
verify("java.util.Map<>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test mid whitespace`() {
|
||||
verify("java.u til.List<java.lang.String>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test mid whitespace2`() {
|
||||
verify("java.util.List<java.l ng.String>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test wrong number of parameters`() {
|
||||
verify("java.util.List<java.lang.String, java.lang.Integer>")
|
||||
}
|
||||
@ -150,12 +150,12 @@ class AMQPTypeIdentifierParserTests {
|
||||
verify("java.lang.String")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test parameters on non-generic type`() {
|
||||
verify("java.lang.String<java.lang.Integer>")
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout = 300_000)
|
||||
fun `test excessive nesting`() {
|
||||
var nested = "java.lang.Integer"
|
||||
for (i in 1..MAX_TYPE_PARAM_DEPTH) {
|
||||
|
@ -28,7 +28,7 @@ class DeserializeMapTests {
|
||||
DeserializationInput(sf).deserialize(serialisedBytes)
|
||||
}
|
||||
|
||||
@Test(expected = java.io.NotSerializableException::class)
|
||||
@Test(expected = java.io.NotSerializableException::class, timeout=300_000)
|
||||
fun abstractMapFromMapOf() {
|
||||
data class C(val c: AbstractMap<String, Int>)
|
||||
|
||||
@ -38,7 +38,7 @@ class DeserializeMapTests {
|
||||
DeserializationInput(sf).deserialize(serialisedBytes)
|
||||
}
|
||||
|
||||
@Test(expected = java.io.NotSerializableException::class)
|
||||
@Test(expected = java.io.NotSerializableException::class, timeout=300_000)
|
||||
fun abstractMapFromTreeMap() {
|
||||
data class C(val c: AbstractMap<String, Int>)
|
||||
|
||||
|
@ -155,7 +155,7 @@ class EnumTests {
|
||||
assertEquals(c.c, obj.c)
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun changedEnum1() {
|
||||
val url = EnumTests::class.java.getResource("EnumTests.changedEnum1")
|
||||
|
||||
@ -174,7 +174,7 @@ class EnumTests {
|
||||
DeserializationInput(sf1).deserialize(SerializedBytes<C>(sc2))
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun changedEnum2() {
|
||||
val url = EnumTests::class.java.getResource("EnumTests.changedEnum2")
|
||||
|
||||
|
@ -113,7 +113,7 @@ class EvolvabilityTests {
|
||||
assertEquals(null, deserializedC.b)
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
fun addAdditionalParam() {
|
||||
val sf = testDefaultFactory()
|
||||
val url = EvolvabilityTests::class.java.getResource("EvolvabilityTests.addAdditionalParam")
|
||||
@ -321,7 +321,7 @@ class EvolvabilityTests {
|
||||
DeserializationInput(factory).deserialize(SerializedBytes<NetworkParametersExample>(url.readBytes()))
|
||||
}
|
||||
|
||||
@Test(expected = NotSerializableException::class)
|
||||
@Test(expected = NotSerializableException::class, timeout=300_000)
|
||||
@Suppress("UNUSED")
|
||||
fun addMandatoryFieldWithAltConstructorUnAnnotated() {
|
||||
val sf = testDefaultFactory()
|
||||
|
@ -40,7 +40,7 @@ class C2(var b: Int) {
|
||||
}
|
||||
|
||||
class StaticInitialisationOfSerializedObjectTest {
|
||||
@Test(expected = java.lang.ExceptionInInitializerError::class)
|
||||
@Test(expected = java.lang.ExceptionInInitializerError::class, timeout=300_000)
|
||||
fun itBlowsUp() {
|
||||
C()
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class ClassCarpenterTest {
|
||||
assertEquals("Person{age=32, name=Mike}", i.toString())
|
||||
}
|
||||
|
||||
@Test(expected = DuplicateNameException::class)
|
||||
@Test(expected = DuplicateNameException::class, timeout=300_000)
|
||||
fun duplicates() {
|
||||
cc.build(ClassSchema("gen.EmptyClass", emptyMap()))
|
||||
cc.build(ClassSchema("gen.EmptyClass", emptyMap()))
|
||||
@ -301,7 +301,7 @@ class ClassCarpenterTest {
|
||||
assertEquals(testD, i["d"])
|
||||
}
|
||||
|
||||
@Test(expected = java.lang.IllegalArgumentException::class)
|
||||
@Test(expected = java.lang.IllegalArgumentException::class, timeout=300_000)
|
||||
fun `null parameter small int`() {
|
||||
val className = "iEnjoySwede"
|
||||
val schema = ClassSchema(
|
||||
@ -313,7 +313,7 @@ class ClassCarpenterTest {
|
||||
clazz.constructors[0].newInstance(a)
|
||||
}
|
||||
|
||||
@Test(expected = NullablePrimitiveException::class)
|
||||
@Test(expected = NullablePrimitiveException::class, timeout=300_000)
|
||||
fun `nullable parameter small int`() {
|
||||
val className = "iEnjoySwede"
|
||||
val schema = ClassSchema(
|
||||
@ -351,7 +351,7 @@ class ClassCarpenterTest {
|
||||
clazz.constructors[0].newInstance(a)
|
||||
}
|
||||
|
||||
@Test(expected = java.lang.reflect.InvocationTargetException::class)
|
||||
@Test(expected = java.lang.reflect.InvocationTargetException::class, timeout=300_000)
|
||||
fun `non nullable parameter integer with null`() {
|
||||
val className = "iEnjoyWibble"
|
||||
val schema = ClassSchema(
|
||||
@ -383,7 +383,7 @@ class ClassCarpenterTest {
|
||||
assertEquals("$className{a=[1, 2, 3]}", i.toString())
|
||||
}
|
||||
|
||||
@Test(expected = java.lang.reflect.InvocationTargetException::class)
|
||||
@Test(expected = java.lang.reflect.InvocationTargetException::class, timeout=300_000)
|
||||
fun `nullable int array throws`() {
|
||||
val className = "iEnjoySwede"
|
||||
val schema = ClassSchema(
|
||||
|
@ -105,3 +105,5 @@ include 'core-deterministic:testing:verifier'
|
||||
include 'serialization-deterministic'
|
||||
|
||||
include 'tools:checkpoint-agent'
|
||||
include 'detekt-plugins'
|
||||
|
||||
|
@ -50,7 +50,7 @@ class CustomNotaryTest {
|
||||
mockNet.stopNodes()
|
||||
}
|
||||
|
||||
@Test(expected = CustomNotaryException::class)
|
||||
@Test(expected = CustomNotaryException::class, timeout=300_000)
|
||||
fun `custom notary service is active`() {
|
||||
val tx = DummyContract.generateInitial(Random().nextInt(), notary, alice.ref(0))
|
||||
val stx = aliceNode.services.signInitialTransaction(tx)
|
||||
|
@ -49,7 +49,7 @@ class CustomTypeJsonParsingTests {
|
||||
assertEquals("26b37265-a1fd-4c77-b2e0-715917ef619f", state.linearId.id.toString())
|
||||
}
|
||||
|
||||
@Test(expected = JsonMappingException::class)
|
||||
@Test(expected = JsonMappingException::class, timeout=300_000)
|
||||
fun `Deserializing by parsing string contain invalid uuid with underscore`() {
|
||||
val json = """{"linearId":"extkey564_26b37265-a1fd-4c77-b2e0"}"""
|
||||
objectMapper.readValue<State>(json)
|
||||
@ -63,7 +63,7 @@ class CustomTypeJsonParsingTests {
|
||||
assertEquals("26b37265-a1fd-4c77-b2e0-715917ef619f", state.uuid.toString())
|
||||
}
|
||||
|
||||
@Test(expected = JsonMappingException::class)
|
||||
@Test(expected = JsonMappingException::class, timeout=300_000)
|
||||
fun `Deserializing UUID by parsing invalid uuid string`() {
|
||||
val json = """{"uuid":"26b37265-a1fd-4c77-b2e0"}"""
|
||||
objectMapper.readValue<UuidState>(json)
|
||||
|
@ -171,13 +171,13 @@ class InteractiveShellTest {
|
||||
expected = "10 (1)++200 (2)"
|
||||
)
|
||||
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class)
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000)
|
||||
fun flowStartNoArgs() = check("", "")
|
||||
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class)
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000)
|
||||
fun flowMissingParam() = check("d: Yo", "")
|
||||
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class)
|
||||
@Test(expected = InteractiveShell.NoApplicableConstructor::class, timeout=300_000)
|
||||
fun flowTooManyParams() = check("b: 12, c: Yo, d: Bar", "")
|
||||
|
||||
@Test(timeout=300_000)
|
||||
|
Loading…
Reference in New Issue
Block a user