mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
node: Add test for LinearState thread clash
This commit is contained in:
@ -4,6 +4,7 @@ import com.r3corda.contracts.cash.Cash
|
|||||||
import com.r3corda.contracts.cash.cashBalances
|
import com.r3corda.contracts.cash.cashBalances
|
||||||
import com.r3corda.contracts.testing.fillWithSomeTestCash
|
import com.r3corda.contracts.testing.fillWithSomeTestCash
|
||||||
import com.r3corda.core.contracts.*
|
import com.r3corda.core.contracts.*
|
||||||
|
import com.r3corda.core.crypto.SecureHash
|
||||||
import com.r3corda.core.node.ServiceHub
|
import com.r3corda.core.node.ServiceHub
|
||||||
import com.r3corda.core.node.services.testing.MockKeyManagementService
|
import com.r3corda.core.node.services.testing.MockKeyManagementService
|
||||||
import com.r3corda.core.node.services.testing.MockStorageService
|
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.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertNull
|
import kotlin.test.assertNull
|
||||||
@ -96,4 +98,25 @@ class WalletWithCashTest {
|
|||||||
|
|
||||||
// TODO: Flesh out these tests as needed.
|
// 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user