mirror of
https://github.com/corda/corda.git
synced 2025-05-11 04:53:02 +00:00
Merging forward updates from release/os/4.12 to release/os/4.13 - 2025-03-25
This commit is contained in:
commit
190a52212e
@ -37,6 +37,7 @@ import net.corda.testing.node.internal.TestCordappInternal
|
|||||||
import net.corda.testing.node.internal.UriTestCordapp
|
import net.corda.testing.node.internal.UriTestCordapp
|
||||||
import net.corda.testing.node.internal.enclosedCordapp
|
import net.corda.testing.node.internal.enclosedCordapp
|
||||||
import net.corda.testing.node.internal.internalDriver
|
import net.corda.testing.node.internal.internalDriver
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy
|
import org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -114,10 +115,20 @@ class TransactionBuilderDriverTest {
|
|||||||
createTransaction(node, bobParty)
|
createTransaction(node, bobParty)
|
||||||
}.hasMessageContaining("Transaction being built has a missing legacy attachment for class net/corda/finance/contracts/asset/")
|
}.hasMessageContaining("Transaction being built has a missing legacy attachment for class net/corda/finance/contracts/asset/")
|
||||||
|
|
||||||
// Upload the missing dependency
|
node.stop()
|
||||||
legacyDependency.jarFile.inputStream().use(node.rpc::uploadAttachment)
|
FileUtils.deleteDirectory(node.baseDirectory.toFile());
|
||||||
|
|
||||||
val stx = createTransaction(node, bobParty)
|
// Now restart the node with the missing dependency
|
||||||
|
val restartedNode = startNode(NodeParameters(
|
||||||
|
ALICE_NAME,
|
||||||
|
additionalCordapps = listOf(currentContracts),
|
||||||
|
legacyContracts = listOf(legacyContracts, legacyDependency)
|
||||||
|
)).getOrThrow()
|
||||||
|
|
||||||
|
// Attachment does not have a contract in it so needs to be manually installed into attachment db storage
|
||||||
|
legacyDependency.jarFile.inputStream().use(restartedNode.rpc::uploadAttachment)
|
||||||
|
|
||||||
|
val stx = createTransaction(restartedNode, bobParty)
|
||||||
assertThat(stx.tx.legacyAttachments).contains(legacyContracts.jarFile.hash, legacyDependency.jarFile.hash)
|
assertThat(stx.tx.legacyAttachments).contains(legacyContracts.jarFile.hash, legacyDependency.jarFile.hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ interface CordappProviderInternal : CordappProvider {
|
|||||||
val appClassLoader: ClassLoader
|
val appClassLoader: ClassLoader
|
||||||
val attachmentFixups: AttachmentFixups
|
val attachmentFixups: AttachmentFixups
|
||||||
val cordapps: List<CordappImpl>
|
val cordapps: List<CordappImpl>
|
||||||
|
val legacyContractCordapps: List<CordappImpl>
|
||||||
fun getCordappForFlow(flowLogic: FlowLogic<*>): Cordapp?
|
fun getCordappForFlow(flowLogic: FlowLogic<*>): Cordapp?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,9 +349,9 @@ open class TransactionBuilder(
|
|||||||
|
|
||||||
val attachments = serviceHub.getTrustedClassAttachments(missingClass)
|
val attachments = serviceHub.getTrustedClassAttachments(missingClass)
|
||||||
val attachment = if (isLegacy) {
|
val attachment = if (isLegacy) {
|
||||||
// Any attachment which contains the class but isn't a non-legacy CorDapp is *probably* the legacy attachment we're looking for
|
// Any (legacy) missing attachments must also be present in the legacy-contracts folder to be attached to a transaction
|
||||||
val nonLegacyCordapps = serviceHub.cordappProvider.cordapps.mapToSet { it.jarHash }
|
val legacyContractCordapps = serviceHub.cordappProvider.legacyContractCordapps.mapToSet { it.jarHash }
|
||||||
attachments.firstOrNull { it.id !in nonLegacyCordapps }
|
attachments.firstOrNull { it.id in legacyContractCordapps }
|
||||||
} else {
|
} else {
|
||||||
attachments.firstOrNull()
|
attachments.firstOrNull()
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ open class CordappProviderImpl(private val cordappLoader: CordappLoader,
|
|||||||
*/
|
*/
|
||||||
override val cordapps: List<CordappImpl> get() = cordappLoader.cordapps
|
override val cordapps: List<CordappImpl> get() = cordappLoader.cordapps
|
||||||
|
|
||||||
|
override val legacyContractCordapps: List<CordappImpl> get() = cordappLoader.legacyContractCordapps
|
||||||
|
|
||||||
fun start() {
|
fun start() {
|
||||||
loadContractsIntoAttachmentStore(cordappLoader.cordapps)
|
loadContractsIntoAttachmentStore(cordappLoader.cordapps)
|
||||||
loadContractsIntoAttachmentStore(cordappLoader.legacyContractCordapps)
|
loadContractsIntoAttachmentStore(cordappLoader.legacyContractCordapps)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user