mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
makeNotaryService now enforces post condition with type system.
This commit is contained in:
parent
a74c491745
commit
85dce390f4
@ -257,7 +257,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
|
||||
val notaryServiceType = serviceTypes.singleOrNull { it.isSubTypeOf(NotaryService.Type) }
|
||||
if (notaryServiceType != null) {
|
||||
makeNotaryService(notaryServiceType)
|
||||
inNodeNotaryService = makeNotaryService(notaryServiceType)
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,19 +313,17 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
inNodeNetworkMapService = InMemoryNetworkMapService(net, reg, services.networkMapCache)
|
||||
}
|
||||
|
||||
open protected fun makeNotaryService(type: ServiceType) {
|
||||
open protected fun makeNotaryService(type: ServiceType): NotaryService {
|
||||
val uniquenessProvider = InMemoryUniquenessProvider()
|
||||
val timestampChecker = TimestampChecker(platformClock, 30.seconds)
|
||||
|
||||
inNodeNotaryService = when (type) {
|
||||
return when (type) {
|
||||
SimpleNotaryService.Type -> SimpleNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache)
|
||||
ValidatingNotaryService.Type -> ValidatingNotaryService(smm, net, timestampChecker, uniquenessProvider, services.networkMapCache)
|
||||
else -> {
|
||||
throw IllegalArgumentException("Notary type ${type.id} is not handled by makeNotaryService.")
|
||||
}
|
||||
}
|
||||
|
||||
require(inNodeNotaryService != null)
|
||||
}
|
||||
|
||||
protected open fun makeIdentityService(): IdentityService {
|
||||
|
@ -5,6 +5,7 @@ import com.r3corda.core.node.services.NetworkMapCache
|
||||
import com.r3corda.node.services.api.RegulatorService
|
||||
import com.r3corda.node.services.messaging.ArtemisMessagingComponent
|
||||
import com.r3corda.node.services.transactions.NotaryService
|
||||
import com.r3corda.node.services.transactions.SimpleNotaryService
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
@ -32,7 +33,7 @@ class DriverTests {
|
||||
@Test
|
||||
fun simpleNodeStartupShutdownWorks() {
|
||||
val (notary, regulator) = driver {
|
||||
val notary = startNode("TestNotary", setOf(NotaryService.Type))
|
||||
val notary = startNode("TestNotary", setOf(SimpleNotaryService.Type))
|
||||
val regulator = startNode("Regulator", setOf(RegulatorService.Type))
|
||||
|
||||
nodeMustBeUp(networkMapCache, notary, "TestNotary")
|
||||
|
Loading…
x
Reference in New Issue
Block a user