mirror of
https://github.com/corda/corda.git
synced 2025-01-19 19:26:27 +00:00
RELEASE - Fixed release branch due to various issues with back porting (#4588)
* Add back V3 TransactionBuilder c'tor (#4587) (cherry picked from commit5bb38e455c
) * Regen isolated jar to fix failing test(s) (#4583) https://github.com/corda/corda/pull/4541 removed TransactionBuilder c'tor (which was introduced post-V3) which the frozen isolated jar was using (cherry picked from commitf592025273
) * Fixed AttachmentLoadingTests (#4565) There were two issues: * The original "sealing violation: can't seal package net.corda.nodeapi" issue was due to the isolated CorDapp containing some code in the net.corda.nodeapi namespace. This has been moved to the isolated namespace. * The test was not correctly creating the second transaction with the dummy command (cherry picked from commit3b8347e150
) * Regen isolated.jar to make sure it's based on the branch
This commit is contained in:
parent
31d799f636
commit
c68e1c3edd
@ -42,7 +42,7 @@ import kotlin.collections.component2
|
||||
@DeleteForDJVM
|
||||
open class TransactionBuilder(
|
||||
var notary: Party? = null,
|
||||
var lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
|
||||
var lockId: UUID = defaultLockId(),
|
||||
protected val inputs: MutableList<StateRef> = arrayListOf(),
|
||||
protected val attachments: MutableList<SecureHash> = arrayListOf(),
|
||||
protected val outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
|
||||
@ -52,9 +52,20 @@ open class TransactionBuilder(
|
||||
protected val references: MutableList<StateRef> = arrayListOf(),
|
||||
protected val serviceHub: ServiceHub? = (Strand.currentStrand() as? FlowStateMachine<*>)?.serviceHub
|
||||
) {
|
||||
constructor(notary: Party? = null,
|
||||
lockId: UUID = defaultLockId(),
|
||||
inputs: MutableList<StateRef> = arrayListOf(),
|
||||
attachments: MutableList<SecureHash> = arrayListOf(),
|
||||
outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
|
||||
commands: MutableList<Command<*>> = arrayListOf(),
|
||||
window: TimeWindow? = null,
|
||||
privacySalt: PrivacySalt = PrivacySalt()
|
||||
) : this(notary, lockId, inputs, attachments, outputs, commands, window, privacySalt, arrayListOf())
|
||||
|
||||
constructor(notary: Party) : this(notary, window = null)
|
||||
|
||||
private companion object {
|
||||
private fun defaultLockId() = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID()
|
||||
private val log = contextLogger()
|
||||
private const val CORDA_VERSION_THAT_INTRODUCED_FLATTENED_COMMANDS = 4
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.core.utilities.ByteSequence
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.nodeapi.DummyContractBackdoor
|
||||
import net.corda.isolated.contracts.DummyContractBackdoor
|
||||
import net.corda.testing.core.DUMMY_NOTARY_NAME
|
||||
import net.corda.testing.core.SerializationEnvironmentRule
|
||||
import net.corda.testing.core.TestIdentity
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.corda.nodeapi
|
||||
package net.corda.isolated.contracts
|
||||
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.PartyAndReference
|
Binary file not shown.
@ -11,6 +11,9 @@ dependencies {
|
||||
cordapp {
|
||||
targetPlatformVersion corda_platform_version.toInteger()
|
||||
minimumPlatformVersion 1
|
||||
sealing {
|
||||
enabled false // This needs to be disabled for AttachmentsClassLoaderSerializationTests to work
|
||||
}
|
||||
contract {
|
||||
name "Isolated Test CorDapp"
|
||||
versionId 1
|
||||
|
@ -5,7 +5,6 @@ import net.corda.core.identity.AbstractParty
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.nodeapi.DummyContractBackdoor
|
||||
|
||||
@Suppress("UNUSED")
|
||||
class AnotherDummyContract : Contract, DummyContractBackdoor {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.corda.nodeapi
|
||||
package net.corda.isolated.contracts
|
||||
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.PartyAndReference
|
@ -1,32 +1,34 @@
|
||||
package net.corda.node.services
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable
|
||||
import net.corda.core.contracts.ContractState
|
||||
import net.corda.core.contracts.StateRef
|
||||
import net.corda.core.contracts.*
|
||||
import net.corda.core.flows.*
|
||||
import net.corda.core.identity.AbstractParty
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.*
|
||||
import net.corda.core.internal.concurrent.transpose
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.serialization.MissingAttachmentsException
|
||||
import net.corda.core.serialization.internal.UntrustedAttachmentsException
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.testing.common.internal.checkNotOnClasspath
|
||||
import net.corda.testing.core.*
|
||||
import net.corda.testing.core.ALICE_NAME
|
||||
import net.corda.testing.core.BOB_NAME
|
||||
import net.corda.testing.core.DUMMY_NOTARY_NAME
|
||||
import net.corda.testing.core.singleIdentity
|
||||
import net.corda.testing.driver.DriverDSL
|
||||
import net.corda.testing.driver.DriverParameters
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.node.NotarySpec
|
||||
import net.corda.testing.node.internal.cordappsForPackages
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
|
||||
@Ignore("Temporarily ignored as it fails with: java.lang.SecurityException: sealing violation: can't seal package net.corda.nodeapi: already loaded")
|
||||
class AttachmentLoadingTests {
|
||||
private companion object {
|
||||
val isolatedJar: URL = AttachmentLoadingTests::class.java.getResource("/isolated.jar")
|
||||
@ -59,11 +61,10 @@ class AttachmentLoadingTests {
|
||||
|
||||
val stateRef = alice.rpc.startFlowDynamic(issuanceFlowClass, 1234).returnValue.getOrThrow()
|
||||
|
||||
// The exception that we actually want is MissingAttachmentsException, but this is thrown in a responder flow on Bob. To work
|
||||
// around that it's re-thrown as a FlowException so that it can be propagated to Alice where we pick it here.
|
||||
assertThatThrownBy {
|
||||
alice.rpc.startFlow(::ConsumeAndBroadcastFlow, stateRef, bob.nodeInfo.singleIdentity()).returnValue.getOrThrow()
|
||||
}.hasMessage("Attempting to load Contract Attachments downloaded from the network")
|
||||
assertThatThrownBy { alice.rpc.startFlow(::ConsumeAndBroadcastFlow, stateRef, bob.nodeInfo.singleIdentity()).returnValue.getOrThrow() }
|
||||
// ConsumeAndBroadcastResponderFlow re-throws any non-FlowExceptions with just their class name in the message so that
|
||||
// we can verify here Bob threw the correct exception
|
||||
.hasMessage(UntrustedAttachmentsException::class.java.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +101,10 @@ class AttachmentLoadingTests {
|
||||
val notary = serviceHub.networkMapCache.notaryIdentities[0]
|
||||
val stateAndRef = serviceHub.toStateAndRef<ContractState>(stateRef)
|
||||
val stx = serviceHub.signInitialTransaction(
|
||||
TransactionBuilder(notary).addInputState(stateAndRef).addCommand(dummyCommand(ourIdentity.owningKey))
|
||||
TransactionBuilder(notary)
|
||||
.addInputState(stateAndRef)
|
||||
.addOutputState(ConsumeContract.State())
|
||||
.addCommand(Command(ConsumeContract.Cmd, ourIdentity.owningKey))
|
||||
)
|
||||
stx.verify(serviceHub, checkSufficientSignatures = false)
|
||||
val session = initiateFlow(otherSide)
|
||||
@ -116,10 +120,24 @@ class AttachmentLoadingTests {
|
||||
override fun call() {
|
||||
try {
|
||||
subFlow(ReceiveFinalityFlow(otherSide))
|
||||
} catch (e: MissingAttachmentsException) {
|
||||
throw FlowException(e.message)
|
||||
} catch (e: FlowException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
throw FlowException(e.javaClass.name)
|
||||
}
|
||||
otherSide.send("OK")
|
||||
}
|
||||
}
|
||||
|
||||
class ConsumeContract : Contract {
|
||||
override fun verify(tx: LedgerTransaction) {
|
||||
// Accept everything
|
||||
}
|
||||
|
||||
class State : ContractState {
|
||||
override val participants: List<AbstractParty> get() = emptyList()
|
||||
}
|
||||
|
||||
object Cmd : TypeOnlyCommandData()
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user