diff --git a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt index 100a072288..afc95f777f 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt @@ -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) + } }