node: Add test for LinearState thread clash

This commit is contained in:
Andras Slemmer 2016-06-23 14:20:21 +01:00
parent f233780e08
commit 3a84e2fe9d

View File

@ -4,6 +4,7 @@ import com.r3corda.contracts.cash.Cash
import com.r3corda.contracts.cash.cashBalances
import com.r3corda.contracts.testing.fillWithSomeTestCash
import com.r3corda.core.contracts.*
import com.r3corda.core.crypto.SecureHash
import com.r3corda.core.node.ServiceHub
import com.r3corda.core.node.services.testing.MockKeyManagementService
import com.r3corda.core.node.services.testing.MockStorageService
@ -14,6 +15,7 @@ import com.r3corda.node.services.wallet.NodeWalletService
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.assertNull
@ -96,4 +98,25 @@ class WalletWithCashTest {
// TODO: Flesh out these tests as needed.
}
@Test
fun addingSeveralTransactionsOfTheSameLinearStateThreadFails() {
val (wallet, services) = make()
val freshKey = services.keyManagementService.freshKey()
val thread = SecureHash.sha256("thread")
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)
assertThatThrownBy {
wallet.notify(dummyIssue.tx)
}
assertEquals(1, wallet.currentWallet.states.size)
}
}