@Test
public void canonicalSignature() {

    TransactionSignature sig = TransactionSignature.dummy();
    Script scriptOk = ScriptBuilder.createInputScript(sig);
    assertEquals(RuleViolation.NONE,
            DefaultRiskAnalysis.isInputStandard(new TransactionInput(PARAMS, null, scriptOk.getProgram())));
    byte[] sigBytes = sig.encodeToBitcoin();
    // Appending a zero byte makes the signature uncanonical without violating DER encoding.
    Script scriptUncanonicalEncoding = new ScriptBuilder().data(Arrays.copyOf(sigBytes, sigBytes.length + 1))
            .build();
    assertEquals(RuleViolation.SIGNATURE_CANONICAL_ENCODING,
            DefaultRiskAnalysis.isInputStandard(new TransactionInput(PARAMS, null, scriptUncanonicalEncoding
                    .getProgram())));
}