Replaced all uses of assert with require (#3309)

JVM assertions have to be enabled with the -ea flag so it's possible for these checks to be ignored.
This commit is contained in:
Shams Asari
2018-06-06 00:31:41 +01:00
committed by GitHub
parent 75f2c4a0a4
commit d620e71bb6
16 changed files with 65 additions and 64 deletions

View File

@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
import static net.corda.core.contracts.ContractsDSL.requireThat;
import static net.corda.core.crypto.Crypto.generateKeyPair;
@ -662,7 +663,7 @@ public class FlowCookbookJava {
requireThat(require -> {
// Any additional checking we see fit...
DummyState outputState = (DummyState) stx.getTx().getOutputs().get(0).getData();
assert (outputState.getMagicNumber() == 777);
checkArgument(outputState.getMagicNumber() == 777);
return null;
});
}

View File

@ -642,7 +642,7 @@ class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
override fun checkTransaction(stx: SignedTransaction) = requireThat {
// Any additional checking we see fit...
val outputState = stx.tx.outputsOfType<DummyState>().single()
assert(outputState.magicNumber == 777)
require(outputState.magicNumber == 777)
}
}