core: Add DummyLinearState and AlwaysSucceedContract for testing

This commit is contained in:
Andras Slemmer 2016-06-23 14:19:52 +01:00
parent 2c7b86fee2
commit f233780e08
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,10 @@
package com.r3corda.core.testing
import com.r3corda.core.contracts.Contract
import com.r3corda.core.contracts.TransactionForContract
import com.r3corda.core.crypto.SecureHash
class AlwaysSucceedContract(override val legalContractReference: SecureHash = SecureHash.sha256("Always succeed contract")) : Contract {
override fun verify(tx: TransactionForContract) {
}
}

View File

@ -0,0 +1,17 @@
package com.r3corda.core.testing
import com.r3corda.core.contracts.Contract
import com.r3corda.core.contracts.LinearState
import com.r3corda.core.crypto.SecureHash
import java.security.PublicKey
import java.util.*
class DummyLinearState(
override val thread: SecureHash = SecureHash.randomSHA256(),
override val contract: Contract = AlwaysSucceedContract(),
override val participants: List<PublicKey> = listOf()) : LinearState {
override fun isRelevant(ourKeys: Set<PublicKey>): Boolean {
return participants.any { ourKeys.contains(it) }
}
}