mirror of
https://github.com/corda/corda.git
synced 2025-05-31 22:50:53 +00:00
Modify NodeVaultServiceTest to not access makeUpdate() directly
This commit is contained in:
parent
5501d74d29
commit
cb306a22fe
@ -25,6 +25,7 @@ import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
|||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import rx.observers.TestSubscriber
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
@ -443,6 +444,10 @@ class NodeVaultServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `make update`() {
|
fun `make update`() {
|
||||||
val service = (services.vaultService as NodeVaultService)
|
val service = (services.vaultService as NodeVaultService)
|
||||||
|
val vaultSubscriber = TestSubscriber<Vault.Update>().apply {
|
||||||
|
service.updates.subscribe(this)
|
||||||
|
}
|
||||||
|
|
||||||
val anonymousIdentity = services.keyManagementService.freshKeyAndCert(services.myInfo.legalIdentityAndCert, false)
|
val anonymousIdentity = services.keyManagementService.freshKeyAndCert(services.myInfo.legalIdentityAndCert, false)
|
||||||
val thirdPartyIdentity = AnonymousParty(generateKeyPair().public)
|
val thirdPartyIdentity = AnonymousParty(generateKeyPair().public)
|
||||||
val amount = Amount(1000, Issued(BOC.ref(1), GBP))
|
val amount = Amount(1000, Issued(BOC.ref(1), GBP))
|
||||||
@ -454,21 +459,18 @@ class NodeVaultServiceTest {
|
|||||||
}.toWireTransaction()
|
}.toWireTransaction()
|
||||||
val cashState = StateAndRef(issueTx.outputs.single(), StateRef(issueTx.id, 0))
|
val cashState = StateAndRef(issueTx.outputs.single(), StateRef(issueTx.id, 0))
|
||||||
|
|
||||||
database.transaction {
|
database.transaction { service.notify(issueTx) }
|
||||||
val expected = Vault.Update(emptySet(), setOf(cashState), null)
|
val expectedIssueUpdate = Vault.Update(emptySet(), setOf(cashState), null)
|
||||||
val actual = service.makeUpdate(issueTx, setOf(anonymousIdentity.identity.owningKey))
|
|
||||||
assertEquals(expected, actual)
|
|
||||||
services.vaultService.notify(issueTx)
|
|
||||||
}
|
|
||||||
|
|
||||||
database.transaction {
|
database.transaction {
|
||||||
val moveTx = TransactionBuilder(TransactionType.General, services.myInfo.legalIdentity).apply {
|
val moveTx = TransactionBuilder(TransactionType.General, services.myInfo.legalIdentity).apply {
|
||||||
services.vaultService.generateSpend(this, Amount(1000, GBP), thirdPartyIdentity)
|
service.generateSpend(this, Amount(1000, GBP), thirdPartyIdentity)
|
||||||
}.toWireTransaction()
|
}.toWireTransaction()
|
||||||
|
service.notify(moveTx)
|
||||||
val expected = Vault.Update(setOf(cashState), emptySet(), null)
|
|
||||||
val actual = service.makeUpdate(moveTx, setOf(anonymousIdentity.identity.owningKey))
|
|
||||||
assertEquals(expected, actual)
|
|
||||||
}
|
}
|
||||||
|
val expectedMoveUpdate = Vault.Update(setOf(cashState), emptySet(), null)
|
||||||
|
|
||||||
|
val observedUpdates = vaultSubscriber.onNextEvents
|
||||||
|
assertEquals(observedUpdates, listOf(expectedIssueUpdate, expectedMoveUpdate))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user