if(getDefinition().getExtendedType() == null || !getDefinition().getExtendedType().equals(SmartContractType.SLOT1.name())) getDefinition().setExtendedType(SmartContractType.SLOT1.name());
assertTrue(slotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.get("definition.extended_type")); assertEquals(100 * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), slotContract.getPrepaidKilobytesDays().doubleValue(), 0.01);
assertTrue(slotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.get("definition.extended_type")); assertEquals(100 * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), slotContract.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(slotContract2.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract2.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract2.get("definition.extended_type")); assertEquals(100 * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), slotContract2.getPrepaidKilobytesDays().doubleValue(), 0.01);
assertTrue(slotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.get("definition.extended_type")); assertEquals(100 * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), slotContract.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(refilledSlotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract.get("definition.extended_type")); assertEquals((100 + 300) * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), refilledSlotContract.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(refilledSlotContract2.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract2.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract2.get("definition.extended_type")); assertEquals((100 + 300 + 300) * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), refilledSlotContract2.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(refilledSlotContract3.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract3.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract3.get("definition.extended_type")); assertEquals((100 + 300 + 300 + 300) * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), refilledSlotContract3.getPrepaidKilobytesDays().doubleValue(), 0.01);
slotContract.setApiLevel(3); Contract.Definition cd = slotContract.getDefinition(); cd.setExpiresAt(slotContract.getCreatedAt().plusMonths(60));
assertTrue(slotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), slotContract.get("definition.extended_type")); assertEquals(100 * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), slotContract.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(refilledSlotContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract.get("definition.extended_type")); assertEquals((100 + 300) * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), refilledSlotContract.getPrepaidKilobytesDays().doubleValue(), 0.01); assertTrue(refilledSlotContract2.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract2.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), refilledSlotContract2.get("definition.extended_type")); assertEquals((100 + 300 + 300) * config.getServiceRate(NSmartContract.SmartContractType.SLOT1.name()).doubleValue(), refilledSlotContract2.getPrepaidKilobytesDays().doubleValue(), 0.01);