use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.
the class AbstractScriptBuilderTest method test_optimize3_sb.
@Test
public void test_optimize3_sb() {
Script s = new ScriptBuilder2().op(OP_TOALTSTACK).op(OP_FROMALTSTACK).number(4).op(OP_TOALTSTACK).op(OP_FROMALTSTACK).optimize().build();
assertEquals(1, s.getChunks().size());
assertArrayEquals(s.getProgram(), new byte[] { OP_4 });
}
use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.
the class AbstractScriptBuilderTest method test_optimize_sb.
@Test
public void test_optimize_sb() {
Script s = new ScriptBuilder2().op(OP_TOALTSTACK).op(OP_FROMALTSTACK).optimize().build();
assertEquals(0, s.getChunks().size());
assertArrayEquals(s.getProgram(), new byte[] {});
}
use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.
the class AbstractScriptBuilderTest method test_optimize4_sb.
@Test
public void test_optimize4_sb() {
Script s = new ScriptBuilder2().op(OP_TOALTSTACK).op(OP_TOALTSTACK).op(OP_FROMALTSTACK).op(OP_FROMALTSTACK).number(4).optimize().build();
assertEquals(1, s.getChunks().size());
assertArrayEquals(s.getProgram(), new byte[] { OP_4 });
}
use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.
the class ScriptBuilder2Test method test_size.
@Test
public void test_size() {
ScriptBuilder2 sb = new ScriptBuilder2();
assertEquals(0, sb.size());
assertEquals(0, sb.getFreeVariables().size());
assertEquals(0, sb.signatureSize());
sb.number(5);
assertEquals(1, sb.size());
assertEquals(0, sb.getFreeVariables().size());
assertEquals(0, sb.signatureSize());
}
use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.
the class ScriptBuilder2Test method test_signature.
@Test
public void test_signature() throws KeyStoreException {
ScriptBuilder2 sb = new ScriptBuilder2();
assertEquals(0, sb.size());
assertEquals(0, sb.getFreeVariables().size());
assertEquals(0, sb.signatureSize());
ECKey k1 = new ECKey();
ECKey k2 = new ECKey();
ecks.addKey(k1);
ecks.addKey(k2);
sb.signaturePlaceholder(k1, SigHash.ALL, false);
sb.signaturePlaceholder(k2, SigHash.ALL, false);
System.out.println(sb);
assertEquals(2, sb.size());
assertEquals(0, sb.getFreeVariables().size());
assertEquals(2, sb.signatureSize());
Transaction tx = new Transaction(new MainNetParams());
tx.addInput(new TransactionInput(new MainNetParams(), null, new byte[] { 42, 42 }));
sb.setAllSignatures(ecks, tx, 0, new byte[] {});
System.out.println(sb);
assertEquals(2, sb.size());
assertEquals(0, sb.getFreeVariables().size());
assertEquals(0, sb.signatureSize());
}
Aggregations