client: Some refactor of Expect dsl, docs

This commit is contained in:
Andras Slemmer
2016-08-30 10:55:45 +01:00
parent bdb22e1b74
commit cb956e0979
2 changed files with 17 additions and 25 deletions

View File

@ -1,6 +1,5 @@
package com.r3corda.client
import co.paralleluniverse.strands.SettableFuture
import com.r3corda.core.contracts.*
import com.r3corda.core.serialization.OpaqueBytes
import com.r3corda.node.driver.driver
@ -21,7 +20,6 @@ val log: Logger = LoggerFactory.getLogger(WalletMonitorServiceTests::class.java)
class WalletMonitorServiceTests {
@Test
fun cashIssueWorksEndToEnd() {
driver {
val aliceNodeFuture = startNode("Alice")
val notaryNodeFuture = startNode("Notary", advertisedServices = setOf(SimpleNotaryService.Type))
@ -46,26 +44,20 @@ class WalletMonitorServiceTests {
notary = notaryNode.identity
))
val buildFuture = SettableFuture<ServiceToClientEvent.TransactionBuild>()
val eventFuture = SettableFuture<ServiceToClientEvent.OutputState>()
aliceInStream.subscribe {
if (it is ServiceToClientEvent.OutputState)
eventFuture.set(it)
else if (it is ServiceToClientEvent.TransactionBuild)
buildFuture.set(it)
else
log.warn("Unexpected event $it")
aliceInStream.expectEvents(isStrict = false) {
parallel(
expect { build: ServiceToClientEvent.TransactionBuild ->
val state = build.state
if (state is TransactionBuildResult.Failed) {
fail(state.message)
}
},
expect { output: ServiceToClientEvent.OutputState ->
require(output.consumed.size == 0)
require(output.produced.size == 1)
}
)
}
val buildEvent = buildFuture.get()
val state = buildEvent.state
if (state is TransactionBuildResult.Failed) {
fail(state.message)
}
val outputEvent = eventFuture.get()
require(outputEvent.consumed.size == 0)
require(outputEvent.produced.size == 1)
}
}