mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
node: Add another test testing correct LinearState sequencing
This commit is contained in:
@ -101,12 +101,14 @@ class WalletWithCashTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addingSeveralTransactionsOfTheSameLinearStateThreadFails() {
|
fun branchingLinearStatesFails() {
|
||||||
val (wallet, services) = make()
|
val (wallet, services) = make()
|
||||||
|
|
||||||
val freshKey = services.keyManagementService.freshKey()
|
val freshKey = services.keyManagementService.freshKey()
|
||||||
|
|
||||||
val thread = SecureHash.sha256("thread")
|
val thread = SecureHash.sha256("thread")
|
||||||
|
|
||||||
|
// Issue a linear state
|
||||||
val dummyIssue = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
|
val dummyIssue = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
|
||||||
addOutputState(DummyLinearState(thread = thread, participants = listOf(freshKey.public)))
|
addOutputState(DummyLinearState(thread = thread, participants = listOf(freshKey.public)))
|
||||||
signWith(freshKey)
|
signWith(freshKey)
|
||||||
@ -114,9 +116,44 @@ class WalletWithCashTest {
|
|||||||
|
|
||||||
wallet.notify(dummyIssue.tx)
|
wallet.notify(dummyIssue.tx)
|
||||||
assertEquals(1, wallet.currentWallet.states.size)
|
assertEquals(1, wallet.currentWallet.states.size)
|
||||||
|
|
||||||
|
// Issue another linear state of the same thread (nonce different)
|
||||||
|
val dummyIssue2 = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
|
||||||
|
addOutputState(DummyLinearState(thread = thread, participants = listOf(freshKey.public)))
|
||||||
|
signWith(freshKey)
|
||||||
|
}.toSignedTransaction()
|
||||||
|
|
||||||
assertThatThrownBy {
|
assertThatThrownBy {
|
||||||
wallet.notify(dummyIssue.tx)
|
wallet.notify(dummyIssue2.tx)
|
||||||
}
|
}
|
||||||
assertEquals(1, wallet.currentWallet.states.size)
|
assertEquals(1, wallet.currentWallet.states.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun sequencingLinearStatesWorks() {
|
||||||
|
val (wallet, services) = make()
|
||||||
|
|
||||||
|
val freshKey = services.keyManagementService.freshKey()
|
||||||
|
|
||||||
|
val thread = SecureHash.sha256("thread")
|
||||||
|
|
||||||
|
// Issue a linear state
|
||||||
|
val dummyIssue = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
|
||||||
|
addOutputState(DummyLinearState(thread = thread, participants = listOf(freshKey.public)))
|
||||||
|
signWith(freshKey)
|
||||||
|
}.toSignedTransaction()
|
||||||
|
|
||||||
|
wallet.notify(dummyIssue.tx)
|
||||||
|
assertEquals(1, wallet.currentWallet.states.size)
|
||||||
|
|
||||||
|
// Move the same state
|
||||||
|
val dummyMove = TransactionType.General.Builder(notary = DUMMY_NOTARY).apply {
|
||||||
|
addOutputState(DummyLinearState(thread = thread, participants = listOf(freshKey.public)))
|
||||||
|
addInputState(dummyIssue.tx.outRef<LinearState>(0))
|
||||||
|
signWith(DUMMY_NOTARY_KEY)
|
||||||
|
}.toSignedTransaction()
|
||||||
|
|
||||||
|
wallet.notify(dummyMove.tx)
|
||||||
|
assertEquals(1, wallet.currentWallet.states.size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user