mirror of
https://github.com/corda/corda.git
synced 2024-12-22 14:22:28 +00:00
contracts: Add comment explaining Generators
This commit is contained in:
parent
9ff1ad7769
commit
6faf19cccc
@ -11,6 +11,13 @@ import com.r3corda.core.crypto.SecureHash
|
|||||||
import com.r3corda.core.testing.*
|
import com.r3corda.core.testing.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file contains generators for quickcheck style testing. The idea is that we can write random instance generators
|
||||||
|
* for each type we have in the code and test against those instead of predefined mock data. This style of testing can
|
||||||
|
* catch corner case bugs and test algebraic properties of the code, for example deserialize(serialize(generatedThing)) == generatedThing
|
||||||
|
*
|
||||||
|
* TODO add combinators for easier Generator writing
|
||||||
|
*/
|
||||||
class ContractStateGenerator : Generator<ContractState>(ContractState::class.java) {
|
class ContractStateGenerator : Generator<ContractState>(ContractState::class.java) {
|
||||||
override fun generate(random: SourceOfRandomness, status: GenerationStatus): ContractState {
|
override fun generate(random: SourceOfRandomness, status: GenerationStatus): ContractState {
|
||||||
return Cash.State(
|
return Cash.State(
|
||||||
|
@ -7,11 +7,10 @@ import com.pholser.junit.quickcheck.generator.GenerationStatus
|
|||||||
import com.pholser.junit.quickcheck.generator.Generator
|
import com.pholser.junit.quickcheck.generator.Generator
|
||||||
import com.pholser.junit.quickcheck.random.SourceOfRandomness
|
import com.pholser.junit.quickcheck.random.SourceOfRandomness
|
||||||
import com.pholser.junit.quickcheck.runner.JUnitQuickcheck
|
import com.pholser.junit.quickcheck.runner.JUnitQuickcheck
|
||||||
import com.r3corda.core.generators.*
|
import com.r3corda.contracts.testing.SignedTransactionGenerator
|
||||||
import com.r3corda.core.serialization.createKryo
|
import com.r3corda.core.serialization.createKryo
|
||||||
import com.r3corda.core.serialization.serialize
|
import com.r3corda.core.serialization.serialize
|
||||||
import com.r3corda.core.testing.PartyGenerator
|
import com.r3corda.core.testing.PartyGenerator
|
||||||
import com.r3corda.core.testing.SignedTransactionGenerator
|
|
||||||
import com.r3corda.protocols.BroadcastTransactionProtocol
|
import com.r3corda.protocols.BroadcastTransactionProtocol
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
Loading…
Reference in New Issue
Block a user