diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/testing/Generators.kt b/contracts/src/main/kotlin/com/r3corda/contracts/testing/Generators.kt index 92fbb0dc82..c8fe101f18 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/testing/Generators.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/testing/Generators.kt @@ -11,6 +11,13 @@ import com.r3corda.core.crypto.SecureHash import com.r3corda.core.testing.* 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::class.java) { override fun generate(random: SourceOfRandomness, status: GenerationStatus): ContractState { return Cash.State( diff --git a/core/src/test/kotlin/com/r3corda/core/protocols/BroadcastTransactionProtocolTest.kt b/core/src/test/kotlin/com/r3corda/core/protocols/BroadcastTransactionProtocolTest.kt index 700f2321a0..1921c64abc 100644 --- a/core/src/test/kotlin/com/r3corda/core/protocols/BroadcastTransactionProtocolTest.kt +++ b/core/src/test/kotlin/com/r3corda/core/protocols/BroadcastTransactionProtocolTest.kt @@ -7,11 +7,10 @@ import com.pholser.junit.quickcheck.generator.GenerationStatus import com.pholser.junit.quickcheck.generator.Generator import com.pholser.junit.quickcheck.random.SourceOfRandomness 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.serialize import com.r3corda.core.testing.PartyGenerator -import com.r3corda.core.testing.SignedTransactionGenerator import com.r3corda.protocols.BroadcastTransactionProtocol import org.junit.runner.RunWith import kotlin.test.assertEquals