mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Renamed CordappInfoResolver to CordappResolver (#4419)
This commit is contained in:
parent
1a065ef13d
commit
9d7be5cf21
@ -5,7 +5,7 @@ import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.crypto.isFulfilledBy
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.identity.groupAbstractPartyByWellKnownParty
|
||||
import net.corda.core.internal.cordapp.CordappInfoResolver
|
||||
import net.corda.core.internal.cordapp.CordappResolver
|
||||
import net.corda.core.internal.pushToLoggingContext
|
||||
import net.corda.core.node.StatesToRecord
|
||||
import net.corda.core.node.StatesToRecord.ONLY_RELEVANT
|
||||
@ -82,7 +82,7 @@ class FinalityFlow private constructor(val transaction: SignedTransaction,
|
||||
@Throws(NotaryException::class)
|
||||
override fun call(): SignedTransaction {
|
||||
if (sessions == null) {
|
||||
require(CordappInfoResolver.currentTargetVersion < 4) {
|
||||
require(CordappResolver.currentTargetVersion < 4) {
|
||||
"A flow session for each external participant to the transaction must be provided. If you wish to continue " +
|
||||
"using this insecure API then specify a target platform version of less than 4 for your CorDapp."
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
/**
|
||||
* Provides a way to acquire information about the calling CorDapp.
|
||||
*/
|
||||
object CordappInfoResolver {
|
||||
private val logger = loggerFor<CordappInfoResolver>()
|
||||
object CordappResolver {
|
||||
private val logger = loggerFor<CordappResolver>()
|
||||
private val cordappClasses: ConcurrentHashMap<String, Set<Cordapp>> = ConcurrentHashMap()
|
||||
|
||||
// TODO Use the StackWalker API once we migrate to Java 9+
|
@ -4,7 +4,7 @@ import com.natpryce.hamkrest.and
|
||||
import com.natpryce.hamkrest.assertion.assert
|
||||
import net.corda.core.flows.mixins.WithFinality
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.cordapp.CordappInfoResolver
|
||||
import net.corda.core.internal.cordapp.CordappResolver
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
@ -65,7 +65,7 @@ class FinalityFlowTests : WithFinality {
|
||||
fun `prevent use of the old API if the CorDapp target version is 4`() {
|
||||
val bob = createBob()
|
||||
val stx = aliceNode.issuesCashTo(bob)
|
||||
val resultFuture = CordappInfoResolver.withCordapp(targetPlatformVersion = 4) {
|
||||
val resultFuture = CordappResolver.withCordapp(targetPlatformVersion = 4) {
|
||||
@Suppress("DEPRECATION")
|
||||
aliceNode.startFlowAndRunNetwork(FinalityFlow(stx)).resultFuture
|
||||
}
|
||||
@ -79,7 +79,7 @@ class FinalityFlowTests : WithFinality {
|
||||
// We need Bob to load at least one old CorDapp so that its FinalityHandler is enabled
|
||||
val bob = createBob(cordapps = listOf(cordappForPackages("com.template").withTargetVersion(3)))
|
||||
val stx = aliceNode.issuesCashTo(bob)
|
||||
val resultFuture = CordappInfoResolver.withCordapp(targetPlatformVersion = 3) {
|
||||
val resultFuture = CordappResolver.withCordapp(targetPlatformVersion = 3) {
|
||||
@Suppress("DEPRECATION")
|
||||
aliceNode.startFlowAndRunNetwork(FinalityFlow(stx)).resultFuture
|
||||
}
|
||||
|
@ -6,44 +6,44 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CordappInfoResolverTest {
|
||||
class CordappResolverTest {
|
||||
@Before
|
||||
@After
|
||||
fun clearCordappInfoResolver() {
|
||||
CordappInfoResolver.clear()
|
||||
CordappResolver.clear()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the correct cordapp resolver is used after calling withCordappInfo`() {
|
||||
val defaultTargetVersion = 222
|
||||
|
||||
CordappInfoResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
CordappResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
contractClassNames = listOf(javaClass.name),
|
||||
minimumPlatformVersion = 3,
|
||||
targetPlatformVersion = defaultTargetVersion
|
||||
))
|
||||
assertEquals(defaultTargetVersion, CordappInfoResolver.currentTargetVersion)
|
||||
assertEquals(defaultTargetVersion, CordappResolver.currentTargetVersion)
|
||||
|
||||
val expectedTargetVersion = 555
|
||||
CordappInfoResolver.withCordapp(targetPlatformVersion = expectedTargetVersion) {
|
||||
val actualTargetVersion = CordappInfoResolver.currentTargetVersion
|
||||
CordappResolver.withCordapp(targetPlatformVersion = expectedTargetVersion) {
|
||||
val actualTargetVersion = CordappResolver.currentTargetVersion
|
||||
assertEquals(expectedTargetVersion, actualTargetVersion)
|
||||
}
|
||||
assertEquals(defaultTargetVersion, CordappInfoResolver.currentTargetVersion)
|
||||
assertEquals(defaultTargetVersion, CordappResolver.currentTargetVersion)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when more than one cordapp is registered for the same class, the resolver returns null`() {
|
||||
CordappInfoResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
CordappResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
contractClassNames = listOf(javaClass.name),
|
||||
minimumPlatformVersion = 3,
|
||||
targetPlatformVersion = 222
|
||||
))
|
||||
CordappInfoResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
CordappResolver.register(CordappImpl.TEST_INSTANCE.copy(
|
||||
contractClassNames = listOf(javaClass.name),
|
||||
minimumPlatformVersion = 2,
|
||||
targetPlatformVersion = 456
|
||||
))
|
||||
assertThat(CordappInfoResolver.currentCordapp).isNull()
|
||||
assertThat(CordappResolver.currentCordapp).isNull()
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import net.corda.core.flows.*
|
||||
import net.corda.core.internal.*
|
||||
import net.corda.core.internal.cordapp.CordappImpl
|
||||
import net.corda.core.internal.cordapp.CordappImpl.Companion.UNKNOWN_INFO
|
||||
import net.corda.core.internal.cordapp.CordappInfoResolver
|
||||
import net.corda.core.internal.cordapp.CordappResolver
|
||||
import net.corda.core.internal.cordapp.get
|
||||
import net.corda.core.internal.notary.NotaryService
|
||||
import net.corda.core.internal.notary.SinglePartyNotaryService
|
||||
@ -129,7 +129,7 @@ class JarScanningCordappLoader private constructor(private val cordappJarPaths:
|
||||
}
|
||||
}
|
||||
}
|
||||
cordapps.forEach(CordappInfoResolver::register)
|
||||
cordapps.forEach(CordappResolver::register)
|
||||
return cordapps
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import net.corda.core.contracts.TransactionVerificationException
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.flows.FinalityFlow
|
||||
import net.corda.core.flows.StateMachineRunId
|
||||
import net.corda.core.internal.cordapp.CordappInfoResolver
|
||||
import net.corda.core.internal.cordapp.CordappResolver
|
||||
import net.corda.core.internal.packageName
|
||||
import net.corda.core.toFuture
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
@ -121,7 +121,7 @@ class FinalityHandlerTest {
|
||||
}
|
||||
|
||||
private fun TestStartedNode.finaliseWithOldApi(stx: SignedTransaction): CordaFuture<SignedTransaction> {
|
||||
return CordappInfoResolver.withCordapp(targetPlatformVersion = 3) {
|
||||
return CordappResolver.withCordapp(targetPlatformVersion = 3) {
|
||||
@Suppress("DEPRECATION")
|
||||
services.startFlow(FinalityFlow(stx)).resultFuture.apply {
|
||||
mockNet.runNetwork()
|
||||
|
Loading…
Reference in New Issue
Block a user