use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class CLIMainTest method registerContractAndPrintProcessingCostBreakWhileUnpacking.
@Test
public void registerContractAndPrintProcessingCostBreakWhileUnpacking() throws Exception {
// Should register contracts and use -cost as key to print cost of processing it.
Contract contract = createCoin();
contract.getStateData().set(FIELD_NAME, new Decimal(100));
contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
contract.seal();
// sealCheckTrace(contract, true);
CLIMain.saveContract(contract, basePath + "contract_for_register_and_cost.unicon");
System.out.println("--- registering contract (with processing cost print) ---");
// Check 4096 bits signature (8) +
// Register a version (20)
int costShouldBe = 28;
Contract.setTestQuantaLimit(1);
callMain("--register", basePath + "contract_for_register_and_cost.unicon", "--cost");
System.out.println(output);
assertTrue(output.indexOf("ERROR: QUANTIZER_COST_LIMIT") >= 0);
Contract.setTestQuantaLimit(-1);
}
use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class CLIMainTest method registerContractAndPrintProcessingCost.
@Test
public void registerContractAndPrintProcessingCost() throws Exception {
// Should register contracts and use -cost as key to print cost of processing it.
Contract contract = createCoin();
contract.getStateData().set(FIELD_NAME, new Decimal(100));
contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
contract.seal();
// sealCheckTrace(contract, true);
CLIMain.saveContract(contract, basePath + "contract_for_register_and_cost.unicon");
System.out.println("--- registering contract (with processing cost print) ---");
// Check 4096 bits signature (8) +
// Register a version (20)
int costShouldBe = (int) Math.floor(28 / Quantiser.quantaPerUTN) + 1;
callMain("--register", basePath + "contract_for_register_and_cost.unicon", "--cost");
System.out.println(output);
assertTrue(output.indexOf("Contract processing cost is " + costShouldBe + " TU") >= 0);
}
use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class CLIMainTest method registerManyContractAndPrintProcessingCost.
@Test
public void registerManyContractAndPrintProcessingCost() throws Exception {
for (int i = 0; i < 2; i++) {
Contract contract = createCoin();
contract.getStateData().set(FIELD_NAME, new Decimal(100));
contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
contract.seal();
// sealCheckTrace(contract, true);
CLIMain.saveContract(contract, basePath + "contract_for_register_and_cost" + i + ".unicon");
}
System.out.println("--- registering contract (with processing cost print) ---");
// Check 4096 bits signature (8) +
// Register a version (20)
int costShouldBe = (int) Math.floor(28 / Quantiser.quantaPerUTN) + 1;
callMain("--register", basePath + "contract_for_register_and_cost0.unicon", basePath + "contract_for_register_and_cost1.unicon", "--cost");
System.out.println(output);
assertTrue(output.indexOf("Contract processing cost is " + costShouldBe + " TU") >= 1);
}
use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class CLIMainTest method registerContractAndPrintProcessingCostBreak.
@Test
public void registerContractAndPrintProcessingCostBreak() throws Exception {
// Should register contracts and use -cost as key to print cost of processing it.
Contract contract = createCoin();
contract.getStateData().set(FIELD_NAME, new Decimal(100));
contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
contract.seal();
// sealCheckTrace(contract, true);
CLIMain.saveContract(contract, basePath + "contract_for_register_and_cost.unicon");
System.out.println("--- registering contract (with processing cost print) ---");
// Check 4096 bits signature (8) +
// Register a version (20)
int costShouldBe = 28;
Contract.setTestQuantaLimit(15);
callMain("--register", basePath + "contract_for_register_and_cost.unicon", "--cost");
System.out.println(output);
assertTrue(output.indexOf("ERROR: QUANTIZER_COST_LIMIT") >= 0);
Contract.setTestQuantaLimit(-1);
}
use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class CLIMainTest method createListOfCoinsWithAmount.
private List<Contract> createListOfCoinsWithAmount(List<Integer> values) throws Exception {
List<Contract> contracts = new ArrayList<>();
for (Integer value : values) {
Contract contract = createCoin();
contract.getStateData().set(FIELD_NAME, new Decimal(value));
contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
contract.seal();
sealCheckTrace(contract, true);
contracts.add(contract);
}
return contracts;
}
Aggregations