From 065d74cf3b13117db8edc19aad353975b7015ede Mon Sep 17 00:00:00 2001 From: Christian Napoles Date: Tue, 11 Jul 2023 17:03:14 +0100 Subject: [PATCH] CORE-15313: release prep for GA-RC10 --- build.gradle | 1 - contracts/build.gradle | 8 - .../ChatContractCreateCommandTest.kt | 150 ----------------- .../ChatContractUpdateCommandTest.kt | 152 ------------------ gradle.properties | 10 +- workflows/build.gradle | 5 - 6 files changed, 2 insertions(+), 324 deletions(-) delete mode 100644 contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractCreateCommandTest.kt delete mode 100644 contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractUpdateCommandTest.kt diff --git a/build.gradle b/build.gradle index d3e1eb0a..0adb33d1 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,6 @@ allprojects { cordaDbContainerName = "CSDEpostgresql" cordaBinDir = "${System.getProperty("user.home")}/.corda/corda5" cordaCliBinDir = "${System.getProperty("user.home")}/.corda/cli" - cpiUploadTimeout = cpiUploadDefault } // Declare the set of Kotlin compiler options we need to build a CorDapp. diff --git a/contracts/build.gradle b/contracts/build.gradle index cd962e81..da264731 100644 --- a/contracts/build.gradle +++ b/contracts/build.gradle @@ -39,12 +39,6 @@ dependencies { // The CorDapp uses the slf4j logging framework. Corda-API provides this so we need a 'cordaProvided' declaration. cordaProvided 'org.slf4j:slf4j-api' - // This are shared so should be here. - // Dependencies Required By Test Tooling - // Todo: these are commented out as the simulator UTXO work has not been merged into Gecko yet. -// testImplementation "net.corda:corda-simulator-api:$simulatorVersion" -// testRuntimeOnly "net.corda:corda-simulator-runtime:$simulatorVersion" - // 3rd party libraries // Required testImplementation "org.slf4j:slf4j-simple:2.0.0" @@ -55,8 +49,6 @@ dependencies { testImplementation "org.mockito:mockito-core:$mockitoVersion" testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion" testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion" - testImplementation "com.r3.corda.ledger.utxo:contract-testing:$contractTestingVersion" - testImplementation "com.r3.corda.ledger.utxo:contract-testing-kotlin:$contractTestingVersion" } // The CordApp section. diff --git a/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractCreateCommandTest.kt b/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractCreateCommandTest.kt deleted file mode 100644 index da12767a..00000000 --- a/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractCreateCommandTest.kt +++ /dev/null @@ -1,150 +0,0 @@ -package com.r3.developers.csdetemplate.utxoexample.contracts - -import com.r3.corda.ledger.utxo.testing.ContractTest -import com.r3.corda.ledger.utxo.testing.buildTransaction -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.CREATE_COMMAND_SHOULD_HAVE_NO_INPUT_STATES -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.CREATE_COMMAND_SHOULD_HAVE_ONLY_ONE_OUTPUT_STATE -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.OUTPUT_STATE_SHOULD_ONLY_HAVE_TWO_PARTICIPANTS -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.REQUIRE_SINGLE_COMMAND -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UNKNOWN_COMMAND -import com.r3.developers.csdetemplate.utxoexample.states.ChatState -import net.corda.v5.ledger.utxo.Command -import org.junit.jupiter.api.Test -import java.util.* - -class ChatContractCreateCommandTest : ContractTest() { - - private val outputChatStateChatName = "aliceChatName" - private val outputChatStateChatMessage = "aliceChatMessage" - internal val outputChatState = ChatState( - UUID.randomUUID(), - outputChatStateChatName, - aliceName, - outputChatStateChatMessage, - listOf(aliceKey, bobKey) - ) - - @Test - fun happyPath() { - val transaction = buildTransaction { - addOutputState(outputChatState) - addCommand(ChatContract.Create()) - addSignatories(outputChatState.participants) - } - assertVerifies(transaction) - } - - @Test - fun missingCommand() { - val transaction = buildTransaction { - addOutputState(outputChatState) - addSignatories(outputChatState.participants) - } - assertFailsWith(transaction, REQUIRE_SINGLE_COMMAND) - } - - @Test - fun shouldNotAcceptUnknownCommand() { - class MyDummyCommand : Command - - val transaction = buildTransaction { - addOutputState(outputChatState) - addCommand(MyDummyCommand()) - addSignatories(outputChatState.participants) - } - - assertFailsWith(transaction, UNKNOWN_COMMAND) - } - - @Test - fun outputStateCannotHaveZeroParticipants() { - val state = ChatState( - UUID.randomUUID(), - "myChatName", - aliceName, - "myChatMessage", - emptyList() - ) - val transaction = buildTransaction { - addOutputState(state) - addCommand(ChatContract.Create()) - } - assertFailsWith(transaction, "Failed requirement: $OUTPUT_STATE_SHOULD_ONLY_HAVE_TWO_PARTICIPANTS") - } - - @Test - fun outputStateCannotHaveOneParticipant() { - val state = ChatState( - UUID.randomUUID(), - "myChatName", - aliceName, - "myChatMessage", - listOf(aliceKey) - ) - val transaction = buildTransaction { - addOutputState(state) - addCommand(ChatContract.Create()) - } - assertFailsWith(transaction, "Failed requirement: $OUTPUT_STATE_SHOULD_ONLY_HAVE_TWO_PARTICIPANTS") - } - - @Test - fun outputStateCannotHaveThreeParticipants() { - val state = ChatState( - UUID.randomUUID(), - "myChatName", - aliceName, - "myChatMessage", - listOf(aliceKey, bobKey, charlieKey) - ) - val transaction = buildTransaction { - addOutputState(state) - addCommand(ChatContract.Create()) - } - assertFailsWith(transaction, "Failed requirement: $OUTPUT_STATE_SHOULD_ONLY_HAVE_TWO_PARTICIPANTS") - } - - @Test - fun shouldBeSigned() { - val transaction = buildTransaction { - addOutputState(outputChatState) - addCommand(ChatContract.Create()) - } - assertFailsWith(transaction, "Failed requirement: $TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS") - } - - @Test - fun cannotBeSignedByOnlyOneParticipant() { - val transaction = buildTransaction { - addOutputState(outputChatState) - addCommand(ChatContract.Create()) - addSignatories(outputChatState.participants[0]) - } - assertFailsWith(transaction, "Failed requirement: $TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS") - } - - @Test - fun shouldNotIncludeInputState() { - happyPath() // generate an existing state to search for - val existingState = ledgerService.findUnconsumedStatesByType(ChatState::class.java).first() // doesn't matter which as this will fail validation - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(outputChatState) - addCommand(ChatContract.Create()) - addSignatories(outputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $CREATE_COMMAND_SHOULD_HAVE_NO_INPUT_STATES") - } - - @Test - fun shouldNotHaveTwoOutputStates() { - val transaction = buildTransaction { - addOutputState(outputChatState) - addOutputState(outputChatState) - addCommand(ChatContract.Create()) - addSignatories(outputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $CREATE_COMMAND_SHOULD_HAVE_ONLY_ONE_OUTPUT_STATE") - } -} \ No newline at end of file diff --git a/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractUpdateCommandTest.kt b/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractUpdateCommandTest.kt deleted file mode 100644 index fbe5189a..00000000 --- a/contracts/src/test/kotlin/com/r3/developers/csdetemplate/utxoexample/contracts/ChatContractUpdateCommandTest.kt +++ /dev/null @@ -1,152 +0,0 @@ -package com.r3.developers.csdetemplate.utxoexample.contracts - -import com.r3.corda.ledger.utxo.testing.ContractTest -import com.r3.corda.ledger.utxo.testing.buildTransaction -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UPDATE_COMMAND_CHATNAME_SHOULD_NOT_CHANGE -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UPDATE_COMMAND_ID_SHOULD_NOT_CHANGE -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UPDATE_COMMAND_PARTICIPANTS_SHOULD_NOT_CHANGE -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UPDATE_COMMAND_SHOULD_HAVE_ONLY_ONE_INPUT_STATE -import com.r3.developers.csdetemplate.utxoexample.contracts.ChatContract.Companion.UPDATE_COMMAND_SHOULD_HAVE_ONLY_ONE_OUTPUT_STATE -import com.r3.developers.csdetemplate.utxoexample.states.ChatState -import net.corda.v5.ledger.utxo.StateAndRef -import org.junit.jupiter.api.Test -import java.util.* - -class ChatContractUpdateCommandTest : ContractTest() { - - @Suppress("UNCHECKED_CAST") - private fun createInitialChatState(): StateAndRef { - val outputState = ChatContractCreateCommandTest().outputChatState - val transaction = buildTransaction { - addOutputState(outputState) - addCommand(ChatContract.Create()) - addSignatories(outputState.participants) - } - transaction.toLedgerTransaction() - return transaction.outputStateAndRefs.first() as StateAndRef - } - - @Test - fun happyPath() { - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertVerifies(transaction) - } - - @Test - fun shouldNotHaveNoInputState(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_SHOULD_HAVE_ONLY_ONE_INPUT_STATE") - } - - @Test - fun shouldNotHaveTwoInputStates(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addInputState(existingState.ref) - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_SHOULD_HAVE_ONLY_ONE_INPUT_STATE") - } - - @Test - fun shouldNotHaveTwoOutputStates(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_SHOULD_HAVE_ONLY_ONE_OUTPUT_STATE") - } - - @Test - fun idShouldNotChange(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState - .updateMessage(bobName, "bobResponse") - .copy(id = UUID.randomUUID()) - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_ID_SHOULD_NOT_CHANGE") - } - - @Test - fun chatNameShouldNotChange(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState - .updateMessage(bobName, "bobResponse") - .copy(chatName = "newName") - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_CHATNAME_SHOULD_NOT_CHANGE") - } - - @Test - fun participantsShouldNotChange(){ - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState - .updateMessage(bobName, "bobResponse") - .copy(participants = listOf(bobKey, charlieKey)) - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants) - } - assertFailsWith(transaction, "Failed requirement: $UPDATE_COMMAND_PARTICIPANTS_SHOULD_NOT_CHANGE") - } - - @Test - fun outputStateMustBeSigned() { - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - } - assertFailsWith(transaction, "Failed requirement: $TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS") - } - - @Test - fun outputStateCannotBeSignedByOnlyOneParticipant() { - val existingState = createInitialChatState() - val updatedOutputChatState = existingState.state.contractState.updateMessage(bobName, "bobResponse") - val transaction = buildTransaction { - addInputState(existingState.ref) - addOutputState(updatedOutputChatState) - addCommand(ChatContract.Update()) - addSignatories(updatedOutputChatState.participants[0]) - } - assertFailsWith(transaction, "Failed requirement: $TRANSACTION_SHOULD_BE_SIGNED_BY_ALL_PARTICIPANTS") - } -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0515780d..c80819a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ kotlin.code.style=official # Specify the version of the Corda-API to use. # This needs to match the version supported by the Corda Cluster the CorDapp will run on. -cordaApiVersion=5.0.0.763-Iguana1.0 +cordaApiVersion=5.0.0.765-GA-RC10 # Specify the version of the notary plugins to use. # Currently packaged as part of corda-runtime-os, so should be set to a corda-runtime-os version. @@ -15,7 +15,7 @@ combinedWorkerJarVersion=5.0.0.0-Iguana1.0 cordaPluginsVersion=7.0.3 # Specify the version of the CSDE gradle plugin to use -csdePluginVersion=1.2.0-alpha-+ +csdePluginVersion=1.1.0 # Specify the name of the workflows module workflowsModule=workflows @@ -35,12 +35,6 @@ junitVersion = 5.8.2 mockitoKotlinVersion=4.0.0 mockitoVersion=4.6.1 hamcrestVersion=2.2 -contractTestingVersion=0.9.0-beta-+ - -# Specify the maximum amount of time allowed for the CPI upload -# As your CorDapp grows you might need to increase this -# Value is in milliseconds -cpiUploadDefault=10000 # R3 internal repository # Use this version when pointing to artefacts in artifactory that have not been published to S3 diff --git a/workflows/build.gradle b/workflows/build.gradle index 4196b471..ddc17908 100644 --- a/workflows/build.gradle +++ b/workflows/build.gradle @@ -40,11 +40,6 @@ dependencies { // The CorDapp uses the slf4j logging framework. Corda-API provides this so we need a 'cordaProvided' declaration. cordaProvided 'org.slf4j:slf4j-api' - // Dependencies Required By Simulator Tests - // Todo: these are commented out as the simulator UTXO work has not been merged into Gecko yet. -// testImplementation "net.corda:corda-simulator-api:$simulatorVersion" -// testRuntimeOnly "net.corda:corda-simulator-runtime:$simulatorVersion" - // 3rd party libraries // Required testImplementation "org.slf4j:slf4j-simple:2.0.0"