@Test public void calculateProcessingCostSimpleBreakWhileUnpacking() throws Exception { Contract contract = createCoin100apiv3(); contract.addSignerKeyFromFile(PRIVATE_KEY_PATH); sealCheckTrace(contract, true); int costShouldBe = 28; boolean exceptionThrown = false; try { processContractAsItWillBeOnTheNode(contract, 1); } catch (Quantiser.QuantiserException e) { System.out.println("Thrown correct exception: " + e.getMessage()); exceptionThrown = true; } catch (BiSerializationException e) { System.out.println("Thrown correct exception: " + e.getMessage()); exceptionThrown = true; } assertEquals(true, exceptionThrown); }
public void addSignerKeyFromFile(String fileName) throws IOException { addSignerKey(new PrivateKey(Do.read(fileName))); }
Contract implements Approvable, BiSerializable, Cloneable { public void addSignerKeyFromFile(String fileName) throws IOException { addSignerKey(new PrivateKey(Do.read(fileName))); } }
Contract implements Approvable, BiSerializable, Cloneable { public void addSignerKeyFromFile(String fileName) throws IOException { addSignerKey(new PrivateKey(Do.read(fileName))); } Contract(byte[] sealed, @NonNull TransactionPack pack);  Contract(Binder data, @NonNull TransactionPack pack);  Contract(byte[] data);  Contract(byte[] sealed, Binder data, TransactionPack pack);  Contract();  Contract(PrivateKey key); }
Contract implements Approvable, BiSerializable, Cloneable { public void addSignerKeyFromFile(String fileName) throws IOException { addSignerKey(new PrivateKey(Do.read(fileName))); } Contract(byte[] sealed, @NonNull TransactionPack pack);  Contract(Binder data, @NonNull TransactionPack pack);  Contract(byte[] data);  Contract(byte[] sealed, Binder data, TransactionPack pack);  Contract();  Contract(PrivateKey key); void setVotedByKeys(Set<PublicKey> votedByKeys); void prepareForReferenceMatching(); Quantiser getQuantiser(); static int getTestQuantaLimit(); static void setTestQuantaLimit(int testQuantaLimit); List<ErrorRecord> getErrors(); static Contract fromDslFile(String fileName); static Contract fromDslString(String dslString); static Contract fromDslStream(InputStream dslStream); State getState(); Transactional getTransactional(); int getApiLevel(); void setApiLevel(int apiLevel); @Override HashMap<String, Reference> getReferences(); @Override Set<Approvable> getReferencedItems(); void removeReferencedItem(Contract removed); void removeAllReferencedItems(); @Override Set<Approvable> getRevokingItems(); @Override Set<Approvable> getNewItems(); List<Contract> getAllContractInTree(); boolean isUnlimitKeyContract(Config config); void verifySealedKeys(boolean isQuantise); @Override boolean check(String prefix); void setReferenceContextKeys(Set<PublicKey> effectiveKeys); Set<String> checkReferencedItems(Set<String> roleRefsToResolve); @Override boolean paymentCheck(Set<KeyAddress> issuerKeys); int getProcessedCost(); int getProcessedCostU(); @Deprecated int getProcessedCostTU(); String getRevisionId(); @Override void addError(Errors code, String field, String text); @Override void addError(ErrorRecord er); void addRevokingItems(Contract... toRevoke); @NonNull @Deprecated Role createRole(String roleName, Object roleObject); @NonNull Role addRole(String roleName, Object roleObject); Role createRole(String roleName, Object roleObject,boolean addToContract); Role getRole(String roleName); @Deprecated List<String> getRoleAddresses(String roleName); HashId getId(boolean sealAsNeed); @Override HashId getId(); Role getIssuer(); @Override ZonedDateTime getCreatedAt(); @Override ZonedDateTime getExpiresAt(); Map<String, Role> getRoles(); Map<String, Role> getPredefinedRoles(); Map<String, Role> getCustomRoles(); Definition getDefinition(); @Deprecated KeyRecord testGetOwner(); @Deprecated Role registerRole(Role role); Role addRole(Role role); void anonymizeRole(String roleName); boolean isPermitted(String permissionName, KeyRecord keyRecord); void addPermission(Permission perm); boolean isPermitted(String permissionName, PublicKey key); boolean isPermitted(String permissionName, Collection<PublicKey> keys); ChronoZonedDateTime<?> getEarliestCreationTime(); Set<PublicKey> getSealedByKeys(); Set<PrivateKey> getKeysToSignWith(); void setKeysToSignWith(Set<PrivateKey> keysToSignWith); void addSignerKeyFromFile(String fileName); void addSignerKey(PrivateKey privateKey); void addSignerKeys(Collection<PrivateKey> keys); void addReference(Reference reference); void removeReference(Reference reference); boolean isOk(); byte[] sealAsV2(); byte[] seal(); void addSignatureToSeal(PrivateKey privateKey); void addSignatureToSeal(Set<PrivateKey> privateKeys); void addSignatureToSeal(byte[] signature, PublicKey publicKey); byte[] getContractBytes(); void removeAllSignatures(); boolean findSignatureInSeal(PublicKey publicKey); byte[] extractTheContract(); byte[] getLastSealedBinary(); Contract createRevision(); synchronized Contract createRevision(Transactional transactional); int getRevision(); HashId getParent(); HashId getRawOrigin(); HashId getOrigin(); Contract createRevision(PrivateKey... keys); Contract createRevision(Transactional transactional, PrivateKey... keys); synchronized Contract createRevision(Collection<PrivateKey> keys); synchronized Contract createRevision(Collection<PrivateKey> keys, Transactional transactional); synchronized Contract createRevisionAnonymously(Collection<?> keys); synchronized Contract createRevisionAnonymously(Collection<?> keys, Transactional transactional); synchronized Contract createRevisionWithAddress(Collection<?> keys); synchronized Contract createRevisionWithAddress(Collection<?> keys, Transactional transactional); Role setCreator(Collection<KeyRecord> records); @Deprecated Role setCreator(Role role); @NonNull Role setCreatorKeys(Object... keys); @NonNull Role setCreatorKeys(Collection<?> keys); Role getOwner(); @NonNull Role setOwnerKey(Object keyOrRecord); @NonNull Role setOwnerKeys(Collection<?> keys); Role setRoleKeys(String roleName, Object... keys); Role setRoleKeys(String roleName, Collection<?> keys); @NonNull Role setOwnerKeys(Object... keys); Role getCreator(); Multimap<String, Permission> getPermissions(); Binder getStateData(); Role setIssuerKeys(Collection<?> keys); Role setIssuerKeys(Object... keys); void setExpiresAt(ZonedDateTime dateTime); @Override void deserialize(Binder data, BiDeserializer deserializer); @Override Binder serialize(BiSerializer s); Contract[] split(int count); Contract splitValue(String fieldName, Decimal valueToExtract); Set<Contract> getSiblings(); void addNewItems(Contract... newContracts); T get(String name); void set(String name, Binder value); static Contract fromSealedFile(String contractFileName); ZonedDateTime getIssuedAt(); byte[] getLastSealedBinary(boolean sealAsNeed); byte[] getPackedTransaction(); Binder getTransactionalData(); static Contract fromPackedTransaction(@NonNull byte[] packedItem); void setTransactionPack(TransactionPack transactionPack); synchronized TransactionPack getTransactionPack(); Contract createRevocation(PrivateKey... keys); List<Contract> getRevoking(); List<? extends Contract> getNew(); List<? extends Contract> getReferenced(); boolean canBeRevoked(Set<PublicKey> keys); Transactional createTransactionalSection(); void checkApplicablePermissionQuantized(Permission permission); Reference findReferenceByName(String name); Reference findReferenceByName(String name, String section); Set<String> getValidRoleReferences(); Set<PublicKey> getEffectiveKeys(); Set<PublicKey> getReferenceContextKeys(); Contract getContract(); void traceErrors(); String getErrorsString(); synchronized Contract copy(); @Override boolean isU(Set<KeyAddress> issuerKeys, String issuerName); @Override boolean shouldBeU(); void setShouldBeU(boolean shouldBeU); void setLimitedForTestnet(boolean limitedForTestnet); boolean isLimitedForTestnet(); boolean isSuitableForTestnet(); @Override boolean isInWhiteList(List<PublicKey> whiteList); static ZonedDateTime decodeDslTime(Object t); Object execJS(JSApiExecOptions execOptions, byte[] jsFileContent, String... params); Object execJS(byte[] jsFileContent, String... params); Object execJSByScriptHash(JSApiExecOptions execOptions, HashId scriptHash, String... params); Object execJSByScriptHash(HashId scriptHash, String... params); Object execJSByName(JSApiExecOptions execOptions, String jsFileName, String... params); Object execJSByName(String jsFileName, String... params); List<String> extractJSNames(); static Contract fromSealedBinary(byte[] sealedBinary); static Contract fromSealedBinary(byte[] sealedBinary, TransactionPack tp); void attachToNetwork(Client client); }
Contract implements Approvable, BiSerializable, Cloneable { public void addSignerKeyFromFile(String fileName) throws IOException { addSignerKey(new PrivateKey(Do.read(fileName))); } Contract(byte[] sealed, @NonNull TransactionPack pack);  Contract(Binder data, @NonNull TransactionPack pack);  Contract(byte[] data);  Contract(byte[] sealed, Binder data, TransactionPack pack);  Contract();  Contract(PrivateKey key); void setVotedByKeys(Set<PublicKey> votedByKeys); void prepareForReferenceMatching(); Quantiser getQuantiser(); static int getTestQuantaLimit(); static void setTestQuantaLimit(int testQuantaLimit); List<ErrorRecord> getErrors(); static Contract fromDslFile(String fileName); static Contract fromDslString(String dslString); static Contract fromDslStream(InputStream dslStream); State getState(); Transactional getTransactional(); int getApiLevel(); void setApiLevel(int apiLevel); @Override HashMap<String, Reference> getReferences(); @Override Set<Approvable> getReferencedItems(); void removeReferencedItem(Contract removed); void removeAllReferencedItems(); @Override Set<Approvable> getRevokingItems(); @Override Set<Approvable> getNewItems(); List<Contract> getAllContractInTree(); boolean isUnlimitKeyContract(Config config); void verifySealedKeys(boolean isQuantise); @Override boolean check(String prefix); void setReferenceContextKeys(Set<PublicKey> effectiveKeys); Set<String> checkReferencedItems(Set<String> roleRefsToResolve); @Override boolean paymentCheck(Set<KeyAddress> issuerKeys); int getProcessedCost(); int getProcessedCostU(); @Deprecated int getProcessedCostTU(); String getRevisionId(); @Override void addError(Errors code, String field, String text); @Override void addError(ErrorRecord er); void addRevokingItems(Contract... toRevoke); @NonNull @Deprecated Role createRole(String roleName, Object roleObject); @NonNull Role addRole(String roleName, Object roleObject); Role createRole(String roleName, Object roleObject,boolean addToContract); Role getRole(String roleName); @Deprecated List<String> getRoleAddresses(String roleName); HashId getId(boolean sealAsNeed); @Override HashId getId(); Role getIssuer(); @Override ZonedDateTime getCreatedAt(); @Override ZonedDateTime getExpiresAt(); Map<String, Role> getRoles(); Map<String, Role> getPredefinedRoles(); Map<String, Role> getCustomRoles(); Definition getDefinition(); @Deprecated KeyRecord testGetOwner(); @Deprecated Role registerRole(Role role); Role addRole(Role role); void anonymizeRole(String roleName); boolean isPermitted(String permissionName, KeyRecord keyRecord); void addPermission(Permission perm); boolean isPermitted(String permissionName, PublicKey key); boolean isPermitted(String permissionName, Collection<PublicKey> keys); ChronoZonedDateTime<?> getEarliestCreationTime(); Set<PublicKey> getSealedByKeys(); Set<PrivateKey> getKeysToSignWith(); void setKeysToSignWith(Set<PrivateKey> keysToSignWith); void addSignerKeyFromFile(String fileName); void addSignerKey(PrivateKey privateKey); void addSignerKeys(Collection<PrivateKey> keys); void addReference(Reference reference); void removeReference(Reference reference); boolean isOk(); byte[] sealAsV2(); byte[] seal(); void addSignatureToSeal(PrivateKey privateKey); void addSignatureToSeal(Set<PrivateKey> privateKeys); void addSignatureToSeal(byte[] signature, PublicKey publicKey); byte[] getContractBytes(); void removeAllSignatures(); boolean findSignatureInSeal(PublicKey publicKey); byte[] extractTheContract(); byte[] getLastSealedBinary(); Contract createRevision(); synchronized Contract createRevision(Transactional transactional); int getRevision(); HashId getParent(); HashId getRawOrigin(); HashId getOrigin(); Contract createRevision(PrivateKey... keys); Contract createRevision(Transactional transactional, PrivateKey... keys); synchronized Contract createRevision(Collection<PrivateKey> keys); synchronized Contract createRevision(Collection<PrivateKey> keys, Transactional transactional); synchronized Contract createRevisionAnonymously(Collection<?> keys); synchronized Contract createRevisionAnonymously(Collection<?> keys, Transactional transactional); synchronized Contract createRevisionWithAddress(Collection<?> keys); synchronized Contract createRevisionWithAddress(Collection<?> keys, Transactional transactional); Role setCreator(Collection<KeyRecord> records); @Deprecated Role setCreator(Role role); @NonNull Role setCreatorKeys(Object... keys); @NonNull Role setCreatorKeys(Collection<?> keys); Role getOwner(); @NonNull Role setOwnerKey(Object keyOrRecord); @NonNull Role setOwnerKeys(Collection<?> keys); Role setRoleKeys(String roleName, Object... keys); Role setRoleKeys(String roleName, Collection<?> keys); @NonNull Role setOwnerKeys(Object... keys); Role getCreator(); Multimap<String, Permission> getPermissions(); Binder getStateData(); Role setIssuerKeys(Collection<?> keys); Role setIssuerKeys(Object... keys); void setExpiresAt(ZonedDateTime dateTime); @Override void deserialize(Binder data, BiDeserializer deserializer); @Override Binder serialize(BiSerializer s); Contract[] split(int count); Contract splitValue(String fieldName, Decimal valueToExtract); Set<Contract> getSiblings(); void addNewItems(Contract... newContracts); T get(String name); void set(String name, Binder value); static Contract fromSealedFile(String contractFileName); ZonedDateTime getIssuedAt(); byte[] getLastSealedBinary(boolean sealAsNeed); byte[] getPackedTransaction(); Binder getTransactionalData(); static Contract fromPackedTransaction(@NonNull byte[] packedItem); void setTransactionPack(TransactionPack transactionPack); synchronized TransactionPack getTransactionPack(); Contract createRevocation(PrivateKey... keys); List<Contract> getRevoking(); List<? extends Contract> getNew(); List<? extends Contract> getReferenced(); boolean canBeRevoked(Set<PublicKey> keys); Transactional createTransactionalSection(); void checkApplicablePermissionQuantized(Permission permission); Reference findReferenceByName(String name); Reference findReferenceByName(String name, String section); Set<String> getValidRoleReferences(); Set<PublicKey> getEffectiveKeys(); Set<PublicKey> getReferenceContextKeys(); Contract getContract(); void traceErrors(); String getErrorsString(); synchronized Contract copy(); @Override boolean isU(Set<KeyAddress> issuerKeys, String issuerName); @Override boolean shouldBeU(); void setShouldBeU(boolean shouldBeU); void setLimitedForTestnet(boolean limitedForTestnet); boolean isLimitedForTestnet(); boolean isSuitableForTestnet(); @Override boolean isInWhiteList(List<PublicKey> whiteList); static ZonedDateTime decodeDslTime(Object t); Object execJS(JSApiExecOptions execOptions, byte[] jsFileContent, String... params); Object execJS(byte[] jsFileContent, String... params); Object execJSByScriptHash(JSApiExecOptions execOptions, HashId scriptHash, String... params); Object execJSByScriptHash(HashId scriptHash, String... params); Object execJSByName(JSApiExecOptions execOptions, String jsFileName, String... params); Object execJSByName(String jsFileName, String... params); List<String> extractJSNames(); static Contract fromSealedBinary(byte[] sealedBinary); static Contract fromSealedBinary(byte[] sealedBinary, TransactionPack tp); void attachToNetwork(Client client); static String JSAPI_SCRIPT_FIELD; }