From f0b4dda0471a59d6ce114293e08ccde612a6b0de Mon Sep 17 00:00:00 2001 From: Takeda Date: Tue, 6 Dec 2022 19:21:31 +0900 Subject: [PATCH] Make validation for max description length configurable Signed-off-by: Takeda --- .../co/soramitsu/iroha/java/BlocksQuery.java | 16 ++--- .../iroha/java/BlocksQueryBuilder.java | 15 ++--- .../soramitsu/iroha/java/FieldValidator.java | 18 +++++- .../jp/co/soramitsu/iroha/java/Query.java | 32 +++++----- .../jp/co/soramitsu/iroha/java/QueryAPI.java | 61 ++++++++----------- .../co/soramitsu/iroha/java/QueryBuilder.java | 28 ++++----- .../co/soramitsu/iroha/java/Transaction.java | 36 +++++------ .../iroha/java/TransactionBuilder.java | 29 +++++---- .../jp/co/soramitsu/iroha/java/Utils.java | 24 ++++---- .../soramitsu/iroha/java/CommandsTest.groovy | 24 ++++---- .../iroha/java/ConcurrencyTest.groovy | 4 +- .../iroha/java/Ed25519Sha2Test.groovy | 14 ++--- .../iroha/java/FieldValidatorTest.groovy | 2 +- .../iroha/java/IntegrationTest.groovy | 27 ++++---- .../soramitsu/iroha/java/IrohaAPITest.groovy | 8 +-- .../jp/co/soramitsu/iroha/java/MstTest.groovy | 5 +- .../java/TransactionStatusObserverTest.groovy | 4 +- .../co/soramitsu/iroha/java/UtilsTest.groovy | 2 +- .../java/query/GetAccountTransactions.groovy | 7 ++- .../iroha/java/query/QueryApiTest.groovy | 26 ++++---- .../iroha/java/routers/RouterTest.groovy | 3 +- .../co/soramitsu/iroha/java/BatchExample.java | 15 ++--- .../jp/co/soramitsu/iroha/java/Example1.java | 16 ++--- .../jp/co/soramitsu/iroha/java/Example2.java | 22 +++---- .../jp/co/soramitsu/iroha/java/Example3.java | 20 +++--- .../detail/GenesisBlockBuilder.java | 5 +- .../testcontainers/network/IrohaNetwork.java | 3 +- .../testcontainers/IrohaContainerTest.groovy | 2 +- .../testcontainers/IrohaNetworkTest.groovy | 3 +- .../iroha/testcontainers/IrohaTlsTest.groovy | 7 ++- 30 files changed, 249 insertions(+), 229 deletions(-) diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQuery.java b/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQuery.java index b16badd16..dabf2caaf 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQuery.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQuery.java @@ -52,19 +52,19 @@ public Queries.BlocksQuery buildUnsigned() { return q.build(); } - public static BlocksQueryBuilder builder(String accountId, Instant time, long counter) { - return new BlocksQueryBuilder(accountId, time, counter); + public static BlocksQueryBuilder builder(String accountId, Instant time, long counter, FieldValidator.Config config) { + return new BlocksQueryBuilder(accountId, time, counter, config); } - public static BlocksQueryBuilder builder(String accountId, Date time, long counter) { - return new BlocksQueryBuilder(accountId, time, counter); + public static BlocksQueryBuilder builder(String accountId, Date time, long counter, FieldValidator.Config config) { + return new BlocksQueryBuilder(accountId, time, counter, config); } - public static BlocksQueryBuilder builder(String accountId, Long time, long counter) { - return new BlocksQueryBuilder(accountId, time, counter); + public static BlocksQueryBuilder builder(String accountId, Long time, long counter, FieldValidator.Config config) { + return new BlocksQueryBuilder(accountId, time, counter, config); } - public static BlocksQueryBuilder builder(String accountId, long counter) { - return builder(accountId, System.currentTimeMillis(), counter); + public static BlocksQueryBuilder builder(String accountId, long counter, FieldValidator.Config config) { + return builder(accountId, System.currentTimeMillis(), counter, config); } } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQueryBuilder.java b/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQueryBuilder.java index 8a332a518..64fb7b3b4 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQueryBuilder.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/BlocksQueryBuilder.java @@ -10,7 +10,7 @@ import jp.co.soramitsu.crypto.ed25519.Ed25519Sha3.CryptoException; public class BlocksQueryBuilder { - + private final FieldValidator.Config config; private FieldValidator validator; private QueryPayloadMeta.Builder meta = QueryPayloadMeta.newBuilder(); @@ -25,20 +25,21 @@ private void init(String accountId, Long time, long counter) { setCounter(counter); } - public BlocksQueryBuilder(String accountId, Instant time, long counter) { - init(accountId, time.toEpochMilli(), counter); + public BlocksQueryBuilder(String accountId, Instant time, long counter, FieldValidator.Config config) { + this(accountId, time.toEpochMilli(), counter, config); } - public BlocksQueryBuilder(String accountId, Date time, long counter) { - init(accountId, time.getTime(), counter); + public BlocksQueryBuilder(String accountId, Date time, long counter, FieldValidator.Config config) { + this(accountId, time.getTime(), counter, config); } - public BlocksQueryBuilder(String accountId, Long time, long counter) { + public BlocksQueryBuilder(String accountId, Long time, long counter, FieldValidator.Config config) { + this.config = config; init(accountId, time, counter); } public BlocksQueryBuilder enableValidation() { - this.validator = new FieldValidator(); + this.validator = new FieldValidator(this.config); return this; } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/FieldValidator.java b/client/src/main/java/jp/co/soramitsu/iroha/java/FieldValidator.java index d6de25071..4f5f4601c 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/FieldValidator.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/FieldValidator.java @@ -14,6 +14,20 @@ * Stateless validator for transaction and query fields. */ public class FieldValidator { + private final int maxDescriptionLength; + + static final class Config { + int maxDescriptionLength; + Config(int maxDescriptionLength) { + this.maxDescriptionLength = maxDescriptionLength; + } + } + + public static final Config defaultConfig = new Config(64); + + FieldValidator(Config config){ + this.maxDescriptionLength = config.maxDescriptionLength; + } public void checkAmount(@NonNull String amount) { BigDecimal am; @@ -154,7 +168,7 @@ public void checkEvmAddress(@NonNull String address) { } } - public void checkPublicKey(@NonNull byte[] peerKey) { + public void checkPublicKey(byte[] peerKey) { if (peerKey.length != 32 && peerKey.length != 35) { throw new ValidationException(PUBKEY, "Public key must be 32 or 35 bytes length, got '%d'", peerKey.length); @@ -205,7 +219,7 @@ public void checkDescription(String description) { } int len = description.length(); - if (len > 64) { + if (len > this.maxDescriptionLength) { throw new ValidationException(DESCRIPTION, "Max length is 64, given string length is '%d'", len); } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/Query.java b/client/src/main/java/jp/co/soramitsu/iroha/java/Query.java index e10888af9..08e4fc1c7 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/Query.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/Query.java @@ -63,35 +63,35 @@ public Queries.Query buildUnsigned() { return q.build(); } - public static QueryBuilder builder(String accountId, Long time, long counter) { - return new QueryBuilder(accountId, time, counter); + public static QueryBuilder builder(String accountId, Long time, long counter, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, config); } - public static QueryBuilder builder(String accountId, Date time, long counter) { - return new QueryBuilder(accountId, time, counter); + public static QueryBuilder builder(String accountId, Date time, long counter, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, config); } - public static QueryBuilder builder(String accountId, Instant time, long counter) { - return new QueryBuilder(accountId, time, counter); + public static QueryBuilder builder(String accountId, Instant time, long counter, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, config); } - public static QueryBuilder builder(String accountId, long counter) { - return new QueryBuilder(accountId, Instant.now(), counter); + public static QueryBuilder builder(String accountId, long counter, FieldValidator.Config config) { + return new QueryBuilder(accountId, Instant.now(), counter, config); } - public static QueryBuilder builder(String accountId, Long time, long counter, SignatureBuilder signatureBuilder) { - return new QueryBuilder(accountId, time, counter, signatureBuilder); + public static QueryBuilder builder(String accountId, Long time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, signatureBuilder, config); } - public static QueryBuilder builder(String accountId, Date time, long counter, SignatureBuilder signatureBuilder) { - return new QueryBuilder(accountId, time, counter, signatureBuilder); + public static QueryBuilder builder(String accountId, Date time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, signatureBuilder, config); } - public static QueryBuilder builder(String accountId, Instant time, long counter, SignatureBuilder signatureBuilder) { - return new QueryBuilder(accountId, time, counter, signatureBuilder); + public static QueryBuilder builder(String accountId, Instant time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new QueryBuilder(accountId, time, counter, signatureBuilder, config); } - public static QueryBuilder builder(String accountId, long counter, SignatureBuilder signatureBuilder) { - return new QueryBuilder(accountId, Instant.now(), counter, signatureBuilder); + public static QueryBuilder builder(String accountId, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new QueryBuilder(accountId, Instant.now(), counter, signatureBuilder, config); } } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java index 22eeafe6d..a65200798 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java @@ -35,36 +35,29 @@ public class QueryAPI { private String accountId; @NonNull private KeyPair keyPair; - + @NonNull + private final FieldValidator.Config config; // default signature builder private SignatureBuilder signatureBuilder; - public QueryAPI(IrohaAPI api, String accountId, KeyPair keyPair) { - this.api = api; - this.accountId = accountId; - this.keyPair = keyPair; - signatureBuilder = Ed25519Sha3SignatureBuilder.getInstance(); + public QueryAPI(IrohaAPI api, String accountId, KeyPair keyPair, FieldValidator.Config config) { + this(api, accountId, keyPair, Ed25519Sha3SignatureBuilder.getInstance(), config); } - public QueryAPI(IrohaAPI api, String accountId, KeyPair keyPair, SignatureBuilder signatureBuilder) { + public QueryAPI(IrohaAPI api, String accountId, KeyPair keyPair, SignatureBuilder signatureBuilder, FieldValidator.Config config) { this.api = api; this.accountId = accountId; this.keyPair = keyPair; this.signatureBuilder = signatureBuilder; + this.config = config; } - public QueryAPI(IrohaAPI api, Account account) { - this.api = api; - this.accountId = account.getId(); - this.keyPair = account.getKeyPair(); - signatureBuilder = Ed25519Sha3SignatureBuilder.getInstance(); + public QueryAPI(IrohaAPI api, Account account, FieldValidator.Config config) { + this(api, account.getId(), account.getKeyPair(), Ed25519Sha3SignatureBuilder.getInstance(), config); } - public QueryAPI(IrohaAPI api, Account account, SignatureBuilder signatureBuilder) { - this.api = api; - this.accountId = account.getId(); - this.keyPair = account.getKeyPair(); - this.signatureBuilder = signatureBuilder; + public QueryAPI(IrohaAPI api, Account account, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this(api, account.getId(), account.getKeyPair(), signatureBuilder, config); } private static AtomicInteger counter = new AtomicInteger(1); @@ -77,7 +70,7 @@ private void checkErrorResponse(QueryResponse response) { } public EngineReceiptsResponse getEngineReceipts(String txHash) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getEngineReceipts(txHash) .buildSigned(keyPair); @@ -89,7 +82,7 @@ public EngineReceiptsResponse getEngineReceipts(String txHash) { } public PeersResponse getPeers() { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getPeers() .buildSigned(keyPair); @@ -111,7 +104,7 @@ public String getAccountDetails( String writer, String key ) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountDetail(accountId, writer, key) .buildSigned(keyPair); @@ -132,7 +125,7 @@ public AccountDetailResponse getAccountDetails( String accountDetailRecordIdWriter, String accountDetailRecordIdKey ) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountDetail( accountId, writer, @@ -160,7 +153,7 @@ public AccountDetailResponse getAccountDetails( } public AccountResponse getAccount(String accountId) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccount(accountId) .buildSigned(keyPair); @@ -172,7 +165,7 @@ public AccountResponse getAccount(String accountId) { } public BlockResponse getBlock(Long height) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getBlock(height) .buildSigned(keyPair); @@ -190,7 +183,7 @@ public TransactionsPageResponse getAccountTransactions(String accountId, Timestamp lastTxTime, Integer firstTxHeight, Integer lastTxHeight) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountTransactions(accountId, pageSize, firstHashHex, ordering, firstTxTime, lastTxTime, firstTxHeight, lastTxHeight) .buildSigned(keyPair); @@ -243,7 +236,7 @@ public TransactionsPageResponse getAccountAssetTransactions(String accountId, Integer firstTxHeight, Integer lastTxHeight) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountAssetTransactions(accountId, assetId, pageSize, firstHashHex, ordering, firstTxTime, lastTxTime, firstTxHeight, lastTxHeight) .buildSigned(keyPair); @@ -283,7 +276,7 @@ public TransactionsResponse getTransactions(List hashes) { } public TransactionsResponse getTransactions(Iterable hashes) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getTransactions(hashes) .buildSigned(keyPair); @@ -295,7 +288,7 @@ public TransactionsResponse getTransactions(Iterable hashes) { } public AssetResponse getAssetInfo(String assetId) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAssetInfo(assetId) .buildSigned(keyPair); @@ -313,7 +306,7 @@ public AssetResponse getAssetInfo(String assetId) { */ @Deprecated public AccountAssetResponse getAccountAssets(String accountId) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountAssets(accountId) .buildSigned(keyPair); @@ -329,7 +322,7 @@ public AccountAssetResponse getAccountAssets( Integer pageSize, String firstAssetId ) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getAccountAssets(accountId, pageSize, firstAssetId) .buildSigned(keyPair); @@ -348,7 +341,7 @@ public AccountAssetResponse getAccountAssets( } public SignatoriesResponse getSignatories(String accountId) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getSignatories(accountId) .buildSigned(keyPair); @@ -366,7 +359,7 @@ public SignatoriesResponse getSignatories(String accountId) { */ @Deprecated public TransactionsResponse getPendingTransactions() { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getPendingTransactions() .buildSigned(keyPair); @@ -386,7 +379,7 @@ public TransactionsResponse getPendingTransactions( Integer firstTxHeight, Integer lastTxHeight ) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getPendingTransactions(pageSize, firstHashHex, ordering, firstTxTime, lastTxTime, firstTxHeight, lastTxHeight) .buildSigned(keyPair); @@ -426,7 +419,7 @@ public TransactionsResponse getPendingTransactions( } public RolesResponse getRoles() { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getRoles() .buildSigned(keyPair); @@ -438,7 +431,7 @@ public RolesResponse getRoles() { } public RolePermissionsResponse getRolePermissions(String roleId) { - val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder) + val q = Query.builder(this.accountId, counter.getAndIncrement(), signatureBuilder, this.config) .getRolePermissions(roleId) .buildSigned(keyPair); diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java index a7bba555f..19c3a0d63 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java @@ -3,7 +3,6 @@ import static jp.co.soramitsu.iroha.java.Utils.nonNull; import com.google.protobuf.Timestamp; -import com.google.protobuf.TimestampOrBuilder; import iroha.protocol.Primitive.AccountDetailRecordId; import iroha.protocol.Queries; import iroha.protocol.Queries.Field; @@ -37,7 +36,6 @@ import lombok.val; public class QueryBuilder { - public class Ordering { List fieldOrdering = new ArrayList<>(); @@ -74,6 +72,7 @@ Queries.Ordering.Builder toBuilder() { private SignatureBuilder signatureBuilder; + private final FieldValidator.Config config; private FieldValidator validator; private QueryPayloadMeta.Builder meta = QueryPayloadMeta.newBuilder(); @@ -91,32 +90,33 @@ private void init(String accountId, Long time, long counter, SignatureBuilder si enableValidation(); } - public QueryBuilder(String accountId, Instant time, long counter) { - init(accountId, time.toEpochMilli(), counter, Ed25519Sha3SignatureBuilder.getInstance()); + public QueryBuilder(String accountId, Instant time, long counter, FieldValidator.Config config) { + this(accountId, time.toEpochMilli(), counter, Ed25519Sha3SignatureBuilder.getInstance(), config); } - public QueryBuilder(String accountId, Date time, long counter) { - init(accountId, time.getTime(), counter, Ed25519Sha3SignatureBuilder.getInstance()); + public QueryBuilder(String accountId, Date time, long counter, FieldValidator.Config config) { + this(accountId, time.getTime(), counter, Ed25519Sha3SignatureBuilder.getInstance(), config); } - public QueryBuilder(String accountId, Long time, long counter) { - init(accountId, time, counter, Ed25519Sha3SignatureBuilder.getInstance()); + public QueryBuilder(String accountId, Long time, long counter, FieldValidator.Config config) { + this(accountId, time, counter, Ed25519Sha3SignatureBuilder.getInstance(), config); } - public QueryBuilder(String accountId, Instant time, long counter, SignatureBuilder signatureBuilder) { - init(accountId, time.toEpochMilli(), counter, signatureBuilder); + public QueryBuilder(String accountId, Instant time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this(accountId, time.toEpochMilli(), counter, signatureBuilder, config); } - public QueryBuilder(String accountId, Date time, long counter, SignatureBuilder signatureBuilder) { - init(accountId, time.getTime(), counter, signatureBuilder); + public QueryBuilder(String accountId, Date time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this(accountId, time.getTime(), counter, signatureBuilder, config); } - public QueryBuilder(String accountId, Long time, long counter, SignatureBuilder signatureBuilder) { + public QueryBuilder(String accountId, Long time, long counter, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this.config = config; init(accountId, time, counter, signatureBuilder); } public QueryBuilder enableValidation() { - this.validator = new FieldValidator(); + this.validator = new FieldValidator(this.config); return this; } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/Transaction.java b/client/src/main/java/jp/co/soramitsu/iroha/java/Transaction.java index 339045ec3..c45346e6c 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/Transaction.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/Transaction.java @@ -88,9 +88,9 @@ public String getReducedHashHex() { return Utils.toHex(getReducedHash()); } - public TransactionBuilder makeMutable() { + public TransactionBuilder makeMutable(FieldValidator.Config config) { tx.clearSignatures(); - return new TransactionBuilder(this); + return new TransactionBuilder(this, config); } public static Transaction parseFrom(TransactionOuterClass.Transaction input) { @@ -102,35 +102,35 @@ public static Transaction parseFrom(byte[] input) throws InvalidProtocolBufferEx return new Transaction(proto); } - public static TransactionBuilder builder(String accountId, Long date) { - return new TransactionBuilder(accountId, date); + public static TransactionBuilder builder(String accountId, Long date, FieldValidator.Config config) { + return new TransactionBuilder(accountId, date, config); } - public static TransactionBuilder builder(String accountId, Date date) { - return new TransactionBuilder(accountId, date); + public static TransactionBuilder builder(String accountId, Date date, FieldValidator.Config config) { + return new TransactionBuilder(accountId, date, config); } - public static TransactionBuilder builder(String accountId, Instant time) { - return new TransactionBuilder(accountId, time); + public static TransactionBuilder builder(String accountId, Instant time, FieldValidator.Config config) { + return new TransactionBuilder(accountId, time, config); } - public static TransactionBuilder builder(String accountId) { - return builder(accountId, System.currentTimeMillis()); + public static TransactionBuilder builder(String accountId, FieldValidator.Config config) { + return builder(accountId, System.currentTimeMillis(), config); } - public static TransactionBuilder builder(String accountId, Long date, SignatureBuilder signatureBuilder) { - return new TransactionBuilder(accountId, date, signatureBuilder); + public static TransactionBuilder builder(String accountId, Long date, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new TransactionBuilder(accountId, date, signatureBuilder, config); } - public static TransactionBuilder builder(String accountId, Date date, SignatureBuilder signatureBuilder) { - return new TransactionBuilder(accountId, date, signatureBuilder); + public static TransactionBuilder builder(String accountId, Date date, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new TransactionBuilder(accountId, date, signatureBuilder, config); } - public static TransactionBuilder builder(String accountId, Instant time, SignatureBuilder signatureBuilder) { - return new TransactionBuilder(accountId, time, signatureBuilder); + public static TransactionBuilder builder(String accountId, Instant time, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return new TransactionBuilder(accountId, time, signatureBuilder, config); } - public static TransactionBuilder builder(String accountId, SignatureBuilder signatureBuilder) { - return builder(accountId, System.currentTimeMillis(), signatureBuilder); + public static TransactionBuilder builder(String accountId, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + return builder(accountId, System.currentTimeMillis(), signatureBuilder, config); } } diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/TransactionBuilder.java b/client/src/main/java/jp/co/soramitsu/iroha/java/TransactionBuilder.java index d3bbc1121..ae2841b45 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/TransactionBuilder.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/TransactionBuilder.java @@ -43,6 +43,7 @@ public class TransactionBuilder { // Ed25519/Sha3 is default signature private SignatureBuilder signatureBuilder; + private final FieldValidator.Config config; private FieldValidator validator; private Transaction tx; @@ -59,41 +60,43 @@ private void init(String accountId, Long time, SignatureBuilder signatureBuilder setQuorum(1 /* default value */); - this.validator = new FieldValidator(); + this.validator = new FieldValidator(this.config); } /** * Both fields are required, therefore we can not create builder without them. However, in genesis * block they can be null. */ - public TransactionBuilder(String accountId, Instant time) { - init(accountId, time.toEpochMilli(), Ed25519Sha3SignatureBuilder.getInstance()); + public TransactionBuilder(String accountId, Instant time, FieldValidator.Config config) { + this(accountId, time.toEpochMilli(), Ed25519Sha3SignatureBuilder.getInstance(), config); } - public TransactionBuilder(String accountId, Date time) { - init(accountId, time.getTime(), Ed25519Sha3SignatureBuilder.getInstance()); + public TransactionBuilder(String accountId, Date time, FieldValidator.Config config) { + this(accountId, time.getTime(), Ed25519Sha3SignatureBuilder.getInstance(), config); } - public TransactionBuilder(String accountId, Long time) { - init(accountId, time, Ed25519Sha3SignatureBuilder.getInstance()); + public TransactionBuilder(String accountId, Long time, FieldValidator.Config config) { + this(accountId, time, Ed25519Sha3SignatureBuilder.getInstance(), config); } - public TransactionBuilder(String accountId, Instant time, SignatureBuilder signatureBuilder) { - init(accountId, time.toEpochMilli(), signatureBuilder); + public TransactionBuilder(String accountId, Instant time, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this(accountId, time.toEpochMilli(), signatureBuilder, config); } - public TransactionBuilder(String accountId, Date time, SignatureBuilder signatureBuilder) { - init(accountId, time.getTime(), signatureBuilder); + public TransactionBuilder(String accountId, Date time, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this(accountId, time.getTime(), signatureBuilder, config); } - public TransactionBuilder(String accountId, Long time, SignatureBuilder signatureBuilder) { + public TransactionBuilder(String accountId, Long time, SignatureBuilder signatureBuilder, FieldValidator.Config config) { + this.config = config; init(accountId, time, signatureBuilder); } /* default */ - TransactionBuilder(Transaction transaction) { + TransactionBuilder(Transaction transaction, FieldValidator.Config config) { signatureBuilder = Ed25519Sha3SignatureBuilder.getInstance(); tx = transaction; + this.config = config; } public TransactionBuilder disableValidation() { diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/Utils.java b/client/src/main/java/jp/co/soramitsu/iroha/java/Utils.java index a739c9a60..94ec69bed 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/Utils.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/Utils.java @@ -180,30 +180,30 @@ public static TxList createTxList(Iterable li * Create Ordered Batch of transactions created by single user from iterable */ public static Iterable createTxOrderedBatch( - Iterable list, KeyPair keyPair) { - return createBatch(list, BatchType.ORDERED, keyPair); + Iterable list, KeyPair keyPair, FieldValidator.Config config) { + return createBatch(list, BatchType.ORDERED, keyPair, config); } /** * Create unsigned Ordered Batch of any transactions from iterable */ - public static Iterable createTxUnsignedOrderedBatch(Iterable list) { - return createBatch(list, BatchType.ORDERED); + public static Iterable createTxUnsignedOrderedBatch(Iterable list, FieldValidator.Config config) { + return createBatch(list, BatchType.ORDERED, config); } /** * Create Atomic Batch of transactions created by single user from iterable */ public static Iterable createTxAtomicBatch( - Iterable list, KeyPair keyPair) { - return createBatch(list, BatchType.ATOMIC, keyPair); + Iterable list, KeyPair keyPair, FieldValidator.Config config) { + return createBatch(list, BatchType.ATOMIC, keyPair, config); } /** * Create unsigned Atomic Batch of any signed transactions from iterable */ - public static Iterable createTxUnsignedAtomicBatch(Iterable list) { - return createBatch(list, BatchType.ATOMIC); + public static Iterable createTxUnsignedAtomicBatch(Iterable list, FieldValidator.Config config) { + return createBatch(list, BatchType.ATOMIC, config); } /** @@ -257,12 +257,12 @@ public static Iterable getProtoBatchHashesHex( } private static Iterable createBatch( - Iterable list, BatchType batchType, KeyPair keyPair) { + Iterable list, BatchType batchType, KeyPair keyPair, FieldValidator.Config config) { final Iterable batchHashes = getProtoBatchHashesHex(list); return StreamSupport.stream(list.spliterator(), false) .map(tx -> Transaction .parseFrom(tx) - .makeMutable() + .makeMutable(config) .setBatchMeta(batchType, batchHashes) .sign(keyPair) .build() @@ -277,11 +277,11 @@ public static Iterable getBatchHashesHex(Iterable list) { } private static Iterable createBatch(Iterable list, - BatchType batchType) { + BatchType batchType, FieldValidator.Config config) { final Iterable batchHashes = getBatchHashesHex(list); return StreamSupport.stream(list.spliterator(), false) .map(tx -> tx - .makeMutable() + .makeMutable(config) .setBatchMeta(batchType, batchHashes) .build() ) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/CommandsTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/CommandsTest.groovy index 0663f7f62..f96e7fc53 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/CommandsTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/CommandsTest.groovy @@ -34,14 +34,14 @@ class CommandsTest extends Specification { } static def setDetail(Account account, String key, String value) { - return builder(account.id) + return builder(account.id, FieldValidator.defaultConfig) .setAccountDetail(account.id, key, value) .sign(account.keyPair) .build() } static def createAccount(Account a) { - return Transaction.builder(defaultAccountId) + return builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount(a.id, a.keyPair.public) .sign(defaultKeyPair) .build() @@ -77,10 +77,10 @@ class CommandsTest extends Specification { @Unroll def "compareAndSet command: key=#key, value=#value, oldValue=#oldValue, checkEmpty=#checkEmpty"() { given: - def qapi = new QueryAPI(api, account) + def qapi = new QueryAPI(api, account, FieldValidator.defaultConfig) when: - def tx = Transaction.builder(account.getId()) + def tx = builder(account.getId(), FieldValidator.defaultConfig) .compareAndSetAccountDetail(account.getId(), key, value, oldValue, checkEmpty) .sign(account.keyPair) .build() @@ -110,14 +110,14 @@ class CommandsTest extends Specification { @Unroll def "callEngine command deploy contract: caller=#caller, input=input"() { given: - def qapi = new QueryAPI(api, account) + def qapi = new QueryAPI(api, account, FieldValidator.defaultConfig) when: - def tx = Transaction.builder(account.getId()) + def tx = builder(account.getId(), FieldValidator.defaultConfig) .callEngine(caller, null, input) .sign(account.keyPair) .build() - def hash = Utils.hash(tx); + def hash = Utils.hash(tx) def transaction_observer = new TestTransactionStatusObserver() api.transaction(tx).blockingSubscribe(transaction_observer) @@ -143,24 +143,24 @@ class CommandsTest extends Specification { @Unroll def "callEngine command call contract: caller=#caller, input=input"() { given: - def qapi = new QueryAPI(api, account) + def qapi = new QueryAPI(api, account, FieldValidator.defaultConfig) // deploy contract - def deploy_tx = Transaction.builder(account.getId()) + def deploy_tx = builder(account.getId(), FieldValidator.defaultConfig) .callEngine(account.getId(), null, evm_binary_code) .sign(account.keyPair) .build() - def deploy_hash = Utils.hash(deploy_tx); + def deploy_hash = Utils.hash(deploy_tx) api.transaction(deploy_tx).blockingSubscribe() def deploy_receipt = qapi.getEngineReceipts(Utils.toHex(deploy_hash)) def callee = deploy_receipt.getEngineReceipts(0).contractAddress when: - def tx = Transaction.builder(account.getId()) + def tx = builder(account.getId(), FieldValidator.defaultConfig) .callEngine(caller, callee, input) .sign(account.keyPair) .build() - def hash = Utils.hash(tx); + def hash = Utils.hash(tx) def transaction_observer = new TestTransactionStatusObserver() api.transaction(tx).blockingSubscribe(transaction_observer) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/ConcurrencyTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/ConcurrencyTest.groovy index 26489fc03..15adcd344 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/ConcurrencyTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/ConcurrencyTest.groovy @@ -45,14 +45,14 @@ class ConcurrencyTest extends Specification { } static def getTx(int n) { - return Transaction.builder(defaultAccountId) + return Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount("${n}", defaultDomainName, defaultKeyPair.public) .sign(defaultKeyPair) .build() } def subscribeForBlocks() { - def bq = BlocksQuery.builder(defaultAccountId, 1) + def bq = BlocksQuery.builder(defaultAccountId, 1, FieldValidator.defaultConfig) .buildSigned(defaultKeyPair) return api.blocksQuery(bq) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/Ed25519Sha2Test.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/Ed25519Sha2Test.groovy index 5dfbc7918..35f927854 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/Ed25519Sha2Test.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/Ed25519Sha2Test.groovy @@ -17,7 +17,7 @@ import static jp.co.soramitsu.iroha.testcontainers.detail.GenesisBlockBuilder.de class Ed25519Sha2Test extends Specification { static Account account = Account.createWithEd25519Sha2("a@test") - + static config = FieldValidator.defaultConfig static IrohaAPI api static def iroha = new IrohaContainer() .withIrohaDockerImage(IrohaContainer.defaultIrohaDockerImageWithURSA) @@ -36,7 +36,7 @@ class Ed25519Sha2Test extends Specification { } static def createAccount(Account a) { - return Transaction.builder(defaultAccountId) + return Transaction.builder(defaultAccountId, config) .createAccount("a", defaultDomainName, a.getHexPublicKey()) .sign(defaultKeyPair) .build() @@ -51,10 +51,10 @@ class Ed25519Sha2Test extends Specification { @Unroll def "setAccountDetail and getAccountDetail by Ed25519 crypto"() { given: - def qapi = new QueryAPI(api, account, new Ed25519Sha2SignatureBuilder()) + def qapi = new QueryAPI(api, account, new Ed25519Sha2SignatureBuilder(), config) when: "send tx with Iroha builtin Ed25519/Sha3 with default builder without specifying SignatureBuilder" - def tx = Transaction.builder(defaultAccountId,) + def tx = Transaction.builder(defaultAccountId, config) .setAccountDetail(defaultAccountId, "key", "value") .sign(defaultKeyPair) .build() @@ -65,7 +65,7 @@ class Ed25519Sha2Test extends Specification { transaction_observer.assertAllTransactionsCommitted() when: "create account with Ed25519/Sha2 pubkey" - tx = Transaction.builder(defaultAccountId, new Ed25519Sha3SignatureBuilder()) + tx = Transaction.builder(defaultAccountId, new Ed25519Sha3SignatureBuilder(), FieldValidator.defaultConfig) .createAccount("a", defaultDomainName, account.getHexPublicKey()) .sign(defaultKeyPair) .build() @@ -76,7 +76,7 @@ class Ed25519Sha2Test extends Specification { transaction_observer.assertAllTransactionsCommitted() when: "send tx from account with Ed25519/Sha2 pubkey" - tx = Transaction.builder(account.getId(), new Ed25519Sha2SignatureBuilder()) + tx = Transaction.builder(account.getId(), new Ed25519Sha2SignatureBuilder(), config) .setAccountDetail(account.getId(), "key", "value") .sign(account.keyPair) .build() @@ -87,7 +87,7 @@ class Ed25519Sha2Test extends Specification { transaction_observer.assertAllTransactionsCommitted() when: "query with Ed25519/Sha3 as default SignatureBuilder" - def defaultQueryApi = new QueryAPI(api, defaultAccountId, defaultKeyPair) + def defaultQueryApi = new QueryAPI(api, defaultAccountId, defaultKeyPair, config) def actual_value = defaultQueryApi.getAccountDetails(account.getId(), account.getId(), "key", 1).getDetail() then: diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/FieldValidatorTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/FieldValidatorTest.groovy index 28d792603..47b32fc8f 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/FieldValidatorTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/FieldValidatorTest.groovy @@ -9,7 +9,7 @@ import static jp.co.soramitsu.iroha.java.ValidationException.Type.* class FieldValidatorTest extends Specification { - def fv = new FieldValidator() + def fv = new FieldValidator(FieldValidator.defaultConfig) def "valid data is valid"() { diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/IntegrationTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/IntegrationTest.groovy index a91df4eef..dfdbd4a1f 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/IntegrationTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/IntegrationTest.groovy @@ -22,6 +22,7 @@ class IntegrationTest extends Specification { static final def defaultDomain = "test" static final def defaultKeypair = GenesisBlockBuilder.defaultKeyPair static final def defaultAccountId = String.format("%s@%s", defaultAccount, defaultDomain) + static final validatorConfig = FieldValidator.defaultConfig static IrohaContainer iroha = new IrohaContainer() @@ -30,7 +31,7 @@ class IntegrationTest extends Specification { static PeerConfig config = PeerConfig.builder() .genesisBlock( new GenesisBlockBuilder() - .addTransaction(Transaction.builder((String) null, Instant.now()) + .addTransaction(Transaction.builder((String) null, Instant.now(), FieldValidator.defaultConfig) .addPeer("0.0.0.0:10001", defaultKeypair.getPublic() as PublicKey) .createRole( defaultRole, @@ -58,7 +59,7 @@ class IntegrationTest extends Specification { def "big integration test"() { when: "subscribe on new blocks" - def bq = BlocksQuery.builder(defaultAccountId, Instant.now(), 1L) + def bq = BlocksQuery.builder(defaultAccountId, Instant.now(), 1L, validatorConfig) .buildSigned(defaultKeypair) def t1 = new TestObserver() @@ -78,7 +79,7 @@ class IntegrationTest extends Specification { def account = "account1" def domain = "domain" def role = "role" - def tx = Transaction.builder(defaultAccountId, Instant.now()) + def tx = Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .createRole("${role}", [Primitive.RolePermission.can_add_peer]) .createAccount("${account}", defaultDomain, defaultKeypair.getPublic()) .createDomain("${domain}", defaultRole) @@ -118,7 +119,7 @@ class IntegrationTest extends Specification { status.txStatus == Endpoint.TxStatus.COMMITTED when: "query account" - def qapi = new QueryAPI(api, defaultAccountId, defaultKeypair) + def qapi = new QueryAPI(api, defaultAccountId, defaultKeypair, validatorConfig) def res = qapi.getAccount(defaultAccountId) then: @@ -128,21 +129,21 @@ class IntegrationTest extends Specification { def anotherAccount = "a" def anotherAccountId = "${anotherAccount}@${defaultDomain}" def atomicBatch = [ - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .createAccount(anotherAccount, defaultDomain, defaultKeypair.getPublic()) .sign(defaultKeypair) .build(), - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .appendRole(anotherAccountId, role) .sign(defaultKeypair) .build(), - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .setAccountDetail(anotherAccountId, "key", "value1") .sign(defaultKeypair) .build() ] - def trueBatch = Utils.createTxAtomicBatch(atomicBatch, defaultKeypair) + def trueBatch = Utils.createTxAtomicBatch(atomicBatch, defaultKeypair, validatorConfig) api.transactionListSync(trueBatch) Thread.sleep(10000) @@ -158,21 +159,21 @@ class IntegrationTest extends Specification { anotherAccount = "b" anotherAccountId = "${anotherAccount}@${defaultDomain}" def orderedBatch = [ - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .createAccount(anotherAccount, defaultDomain, defaultKeypair.getPublic()) .sign(defaultKeypair) .build(), // invalid tx, intentionally - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .appendRole(anotherAccountId, "unknownrole") .build().build(), - Transaction.builder(defaultAccountId, Instant.now()) + Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .setAccountDetail(anotherAccountId, "key", "value2") .sign(defaultKeypair) .build() ] - trueBatch = Utils.createTxOrderedBatch(orderedBatch, defaultKeypair) + trueBatch = Utils.createTxOrderedBatch(orderedBatch, defaultKeypair, validatorConfig) api.transactionListSync(trueBatch) Thread.sleep(10000) @@ -244,7 +245,7 @@ class IntegrationTest extends Specification { accountKey == Utils.toHex(defaultKeypair.public.encoded).toLowerCase() - def pendingTx = Transaction.builder(defaultAccountId, Instant.now()) + def pendingTx = Transaction.builder(defaultAccountId, Instant.now(), validatorConfig) .createAccount(anotherAccount, defaultDomain, defaultKeypair.getPublic()) .setQuorum(2) .sign(defaultKeypair) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/IrohaAPITest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/IrohaAPITest.groovy index 05653600d..b5888a4e9 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/IrohaAPITest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/IrohaAPITest.groovy @@ -28,7 +28,7 @@ class IrohaAPITest extends Specification { def api = iroha.getApi() when: "send valid transaction" - def valid = Transaction.builder(defaultAccountId) + def valid = Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount("zzpppzp", defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) .build() @@ -49,7 +49,7 @@ class IrohaAPITest extends Specification { when: "send stateless invalid transaction" // invalid account name in create account - def statelessInvalid = Transaction.builder(defaultAccountId) + def statelessInvalid = Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .disableValidation() .createAccount("...", defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) @@ -72,7 +72,7 @@ class IrohaAPITest extends Specification { when: "send stateful invalid transaction" // unknown creator - def statefulInvalid = Transaction.builder("random@account") + def statefulInvalid = Transaction.builder("random@account", FieldValidator.defaultConfig) .createAccount("x", defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) .build() @@ -95,7 +95,7 @@ class IrohaAPITest extends Specification { .map(String.&valueOf) .map( { String name -> - return Transaction.builder(defaultAccountId) + return Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount(name, defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) .build() diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/MstTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/MstTest.groovy index c3b25c574..e9640b259 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/MstTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/MstTest.groovy @@ -20,6 +20,7 @@ class MstTest extends Specification { static def keyPairA = crypto.generateKeypair() static def keyPairB = crypto.generateKeypair() static def mstAccountId = "mst@test" + static final config = FieldValidator.defaultConfig static def getPeerConfig() { return PeerConfig.builder() @@ -32,7 +33,7 @@ class MstTest extends Specification { return new GenesisBlockBuilder() .addDefaultTransaction() .addTransaction( - Transaction.builder(null) + Transaction.builder(null, config) .createAccount(mstAccountId, keyPairA.getPublic()) .addSignatory(mstAccountId, keyPairB.getPublic()) .setAccountQuorum(mstAccountId, 2) @@ -51,7 +52,7 @@ class MstTest extends Specification { def tx() { int i = counter.getAndIncrement() - return Transaction.builder(mstAccountId) + return Transaction.builder(mstAccountId, config) .createAsset("usd${i}", defaultDomainName, 2) .build() } diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/TransactionStatusObserverTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/TransactionStatusObserverTest.groovy index e9331973b..190ab5b76 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/TransactionStatusObserverTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/TransactionStatusObserverTest.groovy @@ -76,7 +76,7 @@ class TransactionStatusObserverTest extends Specification { def api = iroha.getApi() when: - def tx = Transaction.builder(defaultAccountId) + def tx = Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount('z', defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) .build() @@ -113,7 +113,7 @@ class TransactionStatusObserverTest extends Specification { def api = iroha.getApi() when: - def tx = Transaction.builder(defaultAccountId) + def tx = Transaction.builder(defaultAccountId, FieldValidator.defaultConfig) .createAccount('z', defaultDomainName, defaultKeyPair.getPublic()) .sign(defaultKeyPair) .build() diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/UtilsTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/UtilsTest.groovy index 7cf9a5b60..3e5cabc33 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/UtilsTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/UtilsTest.groovy @@ -10,7 +10,7 @@ class UtilsTest extends Specification { def "hash works as expected"() { given: - Transaction tx = Transaction.builder("a@a", Instant.ofEpochMilli(0)) + Transaction tx = Transaction.builder("a@a", Instant.ofEpochMilli(0), FieldValidator.defaultConfig) .createAsset("asset", "domain", 3) .build() diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/GetAccountTransactions.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/GetAccountTransactions.groovy index 8ce9f7b3b..4f383db4e 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/GetAccountTransactions.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/GetAccountTransactions.groovy @@ -17,6 +17,7 @@ class GetAccountTransactions extends Specification { static final def defaultAccount = "test" static final def defaultDomain = "test" static final def defaultAccountId = String.format("%s@%s", defaultAccount, defaultDomain) + static final config = FieldValidator.defaultConfig static Account A = Account.create("a@test") static Date now = new Date() static tx1 = setDetail(A, "key1", "Avalue1", now.getTime() + 1) @@ -41,14 +42,14 @@ class GetAccountTransactions extends Specification { } static def createAccount(Account a) { - return builder(defaultAccountId) + return builder(defaultAccountId, config) .createAccount(a.id, a.keyPair.public) .sign(defaultKeyPair) .build() } static def setDetail(Account account, String key, String value, Long createdTime) { - return builder(account.id) + return builder(account.id, config) .setAccountDetail(account.id, key, value) .setCreatedTime(createdTime) .sign(account.keyPair) @@ -69,7 +70,7 @@ class GetAccountTransactions extends Specification { @Unroll def "getAccountTransactions"() { given: - def qapi = new QueryAPI(api, A) + def qapi = new QueryAPI(api, A, config) when: "get account transactions without ordering returns txs in order of creation (tx1, tx2, tx3, tx4)" def response = qapi.getAccountTransactions(A.id, 100) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/QueryApiTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/QueryApiTest.groovy index 289d210bd..cae0fb3db 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/QueryApiTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/query/QueryApiTest.groovy @@ -26,6 +26,8 @@ class QueryApiTest extends Specification { .genesisBlock(getGenesisBlock()) .build()) + static config = FieldValidator.defaultConfig + def setupSpec() { iroha.start() api = iroha.getApi() @@ -36,14 +38,14 @@ class QueryApiTest extends Specification { } static def setDetail(Account account, String key, String value) { - return builder(account.id) + return builder(account.id, config) .setAccountDetail(account.id, key, value) .sign(account.keyPair) .build() } static def createAccount(Account a) { - return builder(defaultAccountId) + return builder(defaultAccountId, config) .createAccount(a.id, a.keyPair.public) .sign(defaultKeyPair) .build() @@ -71,7 +73,7 @@ class QueryApiTest extends Specification { @Unroll def "getPeer query: issuer=#issuer.id"() { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: def response = qapi.getPeers() @@ -89,7 +91,7 @@ class QueryApiTest extends Specification { @Unroll def "getRoles query"() { given: - def qapi = new QueryAPI(api, A) + def qapi = new QueryAPI(api, A, config) when: def response = qapi.getRoles() @@ -102,7 +104,7 @@ class QueryApiTest extends Specification { @Unroll def "getRolePermissions query"() { given: - def qapi = new QueryAPI(api, A) + def qapi = new QueryAPI(api, A, config) when: def response = qapi.getRolePermissions(defaultRoleName) @@ -114,7 +116,7 @@ class QueryApiTest extends Specification { @Unroll def "all getAccountDetail: issuer=#issuer.id, accountId=#accountId, writer=#writer, key=#key"() { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: def actual_value = qapi.getAccountDetails(accountId, writer, key, 10).getDetail() @@ -140,7 +142,7 @@ class QueryApiTest extends Specification { @Unroll def "getAccountDetail pagination test: accountId=#accountId, writer=#writer, key=#key, nextWriter=#nextWriter, nextKet=#nextKey"() { given: - def qapi = new QueryAPI(api, A) + def qapi = new QueryAPI(api, A, config) when: def res = qapi.getAccountDetails(accountId, writer, key, 1, nextWriter, nextKey) @@ -162,7 +164,7 @@ class QueryApiTest extends Specification { @Unroll def "exception in @Deprecated getAccountDetails"(Account issuer, String accountId, String writer, String key) { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: qapi.getAccountDetails(accountId, writer, key, 1) @@ -177,7 +179,7 @@ class QueryApiTest extends Specification { def "validation exception in getAccountDetails"(Account issuer, String accountId, String writer, String key, Integer pageSize) { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: qapi.getAccountDetails(accountId, writer, key, pageSize) @@ -194,7 +196,7 @@ class QueryApiTest extends Specification { def "exception in getAccountDetails"(Account issuer, String accountId, String writer, String key, Integer pageSize) { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: qapi.getAccountDetails(accountId, writer, key, pageSize) @@ -210,7 +212,7 @@ class QueryApiTest extends Specification { @Unroll def "validation exception in getAccount"(Account issuer, String accountId) { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: qapi.getAccount(accountId) @@ -226,7 +228,7 @@ class QueryApiTest extends Specification { @Unroll def "exception in getAccount"(Account issuer, String accountId) { given: - def qapi = new QueryAPI(api, issuer) + def qapi = new QueryAPI(api, issuer, config) when: qapi.getAccount(accountId) diff --git a/client/src/test/groovy/jp/co/soramitsu/iroha/java/routers/RouterTest.groovy b/client/src/test/groovy/jp/co/soramitsu/iroha/java/routers/RouterTest.groovy index 1871ea6ee..6aafd38ff 100644 --- a/client/src/test/groovy/jp/co/soramitsu/iroha/java/routers/RouterTest.groovy +++ b/client/src/test/groovy/jp/co/soramitsu/iroha/java/routers/RouterTest.groovy @@ -2,6 +2,7 @@ package jp.co.soramitsu.iroha.java.routers import iroha.protocol.TransactionOuterClass +import jp.co.soramitsu.iroha.java.FieldValidator import jp.co.soramitsu.iroha.java.Transaction import jp.co.soramitsu.iroha.java.detail.router.Router import spock.lang.Specification @@ -79,7 +80,7 @@ class RouterTest extends Specification { where: tx << [ - Transaction.builder(null) + Transaction.builder(null, FieldValidator.defaultConfig) .disableValidation() .addPeer("127.0.0.1:123", defaultKeyPair.public) .addPeer("1.1.1.1:11111", defaultKeyPair.public) diff --git a/client/src/test/java/jp/co/soramitsu/iroha/java/BatchExample.java b/client/src/test/java/jp/co/soramitsu/iroha/java/BatchExample.java index 5a418dec5..1b63c3d48 100644 --- a/client/src/test/java/jp/co/soramitsu/iroha/java/BatchExample.java +++ b/client/src/test/java/jp/co/soramitsu/iroha/java/BatchExample.java @@ -17,11 +17,11 @@ public class BatchExample { private static WaitForTerminalStatus waiter = new WaitForTerminalStatus(); private static TransactionStatusObserver statusObserver = TransactionStatusObserver.builder() - .onTransactionFailed(t -> System.out.println(String.format( - "transaction %s failed with msg: %s", + .onTransactionFailed(t -> System.out.printf( + "transaction %s failed with msg: %s%n", t.getTxHash(), t.getErrOrCmdName() - ))) + )) // executed when got any exception in handlers or grpc .onError(e -> System.out.println("Failed with exception: " + e)) // executed when we receive "committed" status @@ -38,14 +38,15 @@ public static void main(String[] args) { irohaContainer.start(); IrohaAPI irohaAPI = irohaContainer.getApi(); + val config = FieldValidator.defaultConfig; // create 1st transactions - val tx1 = Transaction.builder(defaultAccountId) + val tx1 = Transaction.builder(defaultAccountId, config) .setAccountDetail(defaultAccountId, "key1", "value1") .sign(defaultKeyPair) .build(); // create 2nd transactions - val tx2 = Transaction.builder(defaultAccountId) + val tx2 = Transaction.builder(defaultAccountId, config) .setAccountDetail(defaultAccountId, "key2", "value2") .sign(defaultKeyPair) .build(); @@ -56,7 +57,7 @@ public static void main(String[] args) { lst.add(tx2); // convert list to batch - val atomicBatch = Utils.createTxAtomicBatch(lst, defaultKeyPair); + val atomicBatch = Utils.createTxAtomicBatch(lst, defaultKeyPair, config); // send irohaAPI.transactionListSync(atomicBatch); @@ -69,7 +70,7 @@ public static void main(String[] args) { } // build protobuf query, sign it - val q = Query.builder(defaultAccountId, 1) + val q = Query.builder(defaultAccountId, 1, config) .getAccountDetail(defaultAccountId, null, null) .buildSigned(defaultKeyPair); diff --git a/client/src/test/java/jp/co/soramitsu/iroha/java/Example1.java b/client/src/test/java/jp/co/soramitsu/iroha/java/Example1.java index f117adcae..5a63a2d16 100644 --- a/client/src/test/java/jp/co/soramitsu/iroha/java/Example1.java +++ b/client/src/test/java/jp/co/soramitsu/iroha/java/Example1.java @@ -30,6 +30,8 @@ private static String user(String name) { private static final String usd = String.format("%s#%s", usdName, bankDomain); + private static final FieldValidator.Config config = FieldValidator.defaultConfig; + /** *
    * Our initial state cosists of:
@@ -44,7 +46,7 @@ private static BlockOuterClass.Block getGenesisBlock() {
         // first transaction
         .addTransaction(
             // transactions in genesis block can have no creator
-            Transaction.builder(null)
+            Transaction.builder(null, config)
                 // by default peer is listening on port 10001
                 .addPeer("0.0.0.0:10001", peerKeypair.getPublic())
                 // create default "user" role
@@ -69,7 +71,7 @@ private static BlockOuterClass.Block getGenesisBlock() {
         )
         // we want to increase user_a balance by 100 usd
         .addTransaction(
-            Transaction.builder(user("user_a"))
+            Transaction.builder(user("user_a"), config)
                 .addAssetQuantity(usd, new BigDecimal("100"))
                 .build()
                 .build()
@@ -93,7 +95,7 @@ public static PeerConfig getPeerConfig() {
    */
   public static int getBalance(IrohaAPI api, String userId, KeyPair keyPair) {
     // build protobuf query, sign it
-    val q = Query.builder(userId, 1)
+    val q = Query.builder(userId, 1, config)
         .getAccountAssets(userId)
         .buildSigned(keyPair);
 
@@ -127,7 +129,7 @@ public static void main(String[] args) {
     IrohaAPI api = new IrohaAPI(iroha.getToriiAddress());
 
     // transfer 100 usd from user_a to user_b
-    val tx = Transaction.builder("user_a@bank")
+    val tx = Transaction.builder("user_a@bank", config)
         .transferAsset("user_a@bank", "user_b@bank", usd, "For pizza", "10")
         .sign(useraKeypair)
         .build();
@@ -136,11 +138,11 @@ public static void main(String[] args) {
     // here you can specify any kind of handlers on transaction statuses
     val observer = TransactionStatusObserver.builder()
         // executed when stateless or stateful validation is failed
-        .onTransactionFailed(t -> System.out.println(String.format(
-            "transaction %s failed with msg: %s",
+        .onTransactionFailed(t -> System.out.printf(
+                "transaction %s failed with msg: %s%n",
             t.getTxHash(),
             t.getErrOrCmdName()
-        )))
+        ))
         // executed when got any exception in handlers or grpc
         .onError(e -> System.out.println("Failed with exception: " + e))
         // executed when we receive "committed" status
diff --git a/client/src/test/java/jp/co/soramitsu/iroha/java/Example2.java b/client/src/test/java/jp/co/soramitsu/iroha/java/Example2.java
index 1c2468310..397b379dd 100644
--- a/client/src/test/java/jp/co/soramitsu/iroha/java/Example2.java
+++ b/client/src/test/java/jp/co/soramitsu/iroha/java/Example2.java
@@ -30,7 +30,7 @@ public static void main(String[] args) {
     IrohaAPI api = iroha.getApi();
 
     // create a transaction
-    val tx = Transaction.builder(defaultAccountId)
+    val tx = Transaction.builder(defaultAccountId, FieldValidator.defaultConfig)
         .createAccount("0", defaultDomainName, defaultKeyPair.getPublic())
         .createAsset("usd", defaultDomainName, 2)
         .createRole("role", Collections.singletonList(RolePermission.can_add_asset_qty))
@@ -44,23 +44,19 @@ public static void main(String[] args) {
     // handle CREATE_ACCOUNT command
     cmdRouter.handle(CommandCase.CREATE_ACCOUNT, cmd -> {
       CreateAccount c = cmd.getCreateAccount();
-      System.out.println(
-          String.format("[create account] name=%s domain=%s publickey=%s",
-              c.getAccountName(),
-              c.getDomainId(),
-              c.getPublicKey())
-      );
+      System.out.printf("[create account] name=%s domain=%s publickey=%s%n",
+          c.getAccountName(),
+          c.getDomainId(),
+          c.getPublicKey());
     });
 
     // handle CREATE_ASSET
     cmdRouter.handle(CommandCase.CREATE_ASSET, cmd -> {
       CreateAsset c = cmd.getCreateAsset();
-      System.out.println(
-          String.format("[create asset] name=%s domain=%s precision=%d",
-              c.getAssetName(),
-              c.getDomainId(),
-              c.getPrecision())
-      );
+      System.out.printf("[create asset] name=%s domain=%s precision=%d%n",
+          c.getAssetName(),
+          c.getDomainId(),
+          c.getPrecision());
     });
 
     val observer = TransactionStatusObserver.builder()
diff --git a/client/src/test/java/jp/co/soramitsu/iroha/java/Example3.java b/client/src/test/java/jp/co/soramitsu/iroha/java/Example3.java
index 79c1e6171..0145f9139 100644
--- a/client/src/test/java/jp/co/soramitsu/iroha/java/Example3.java
+++ b/client/src/test/java/jp/co/soramitsu/iroha/java/Example3.java
@@ -31,7 +31,7 @@ private static String user(String name) {
     }
 
     private static final String usd = String.format("%s#%s", usdName, bankDomain);
-
+    private static final FieldValidator.Config config = FieldValidator.defaultConfig;
     /**
      * 
      * Our initial state consists of:
@@ -46,7 +46,7 @@ private static BlockOuterClass.Block getGenesisBlock() {
                 // first transaction
                 .addTransaction(
                         // transactions in genesis block can have no creator
-                        Transaction.builder(null)
+                        Transaction.builder(null, config)
                                 // by default peer is listening on port 10001
                                 .addPeer("0.0.0.0:10001", peerKeypair.getPublic())
                                 // create default "user" role
@@ -73,7 +73,7 @@ private static BlockOuterClass.Block getGenesisBlock() {
                 )
                 // we want to increase user_a balance by 100 usd
                 .addTransaction(
-                        Transaction.builder(user("user_a"))
+                        Transaction.builder(user("user_a"), config)
                                 .addAssetQuantity(usd, new BigDecimal("100"))
                                 .build()
                                 .build()
@@ -94,7 +94,7 @@ public static PeerConfig getPeerConfig() {
 
     public static long getAccountTransactionsExample(IrohaAPI api, String userId, KeyPair keyPair) {
         // build protobuf query, sign it
-        val q = Query.builder(userId,1).getAccountTransactions(userId, 5,null, null, null, null, 2, 2).buildSigned(keyPair);
+        val q = Query.builder(userId,1, config).getAccountTransactions(userId, 5,null, null, null, null, 2, 2).buildSigned(keyPair);
         // make query and get it results
         val res = api.query(q);
         System.out.println("Query GetAccountTransactions response:");
@@ -108,14 +108,14 @@ public static void getAccountAssetTransactionsExample(IrohaAPI api, String userI
                 .setNanos(firstTime.getNano()).build();
         Timestamp lastTxTime = Timestamp.newBuilder().setSeconds(lastTime.getEpochSecond())
                 .setNanos(lastTime.getNano()).build();
-        val q = Query.builder(userId,1).getAccountAssetTransactions(userId, "usd#bank", 5, null, null, firstTxTime,lastTxTime, null, null).buildSigned(keyPair);
+        val q = Query.builder(userId,1, config).getAccountAssetTransactions(userId, "usd#bank", 5, null, null, firstTxTime,lastTxTime, null, null).buildSigned(keyPair);
         // make query and get it results
         val res = api.query(q);
         System.out.println("Query GetAccountAssetTransactions response:");
         System.out.println(res.getTransactionsPageResponse());
     }
 
-    public static void main(String[] args) throws InterruptedException {
+    public static void main(String[] args) {
         // for simplicity, we will create Iroha peer in place
         IrohaContainer iroha = new IrohaContainer()
                 .withPeerConfig(getPeerConfig());
@@ -127,7 +127,7 @@ public static void main(String[] args) throws InterruptedException {
         IrohaAPI api = new IrohaAPI(iroha.getToriiAddress());
 
         // transfer 100 usd from user_a to user_b
-        val tx = Transaction.builder("user_a@bank")
+        val tx = Transaction.builder("user_a@bank", config)
                 .transferAsset("user_a@bank", "user_b@bank", usd, "For pizza", "10")
                 .sign(useraKeypair)
                 .build();
@@ -135,11 +135,11 @@ public static void main(String[] args) throws InterruptedException {
         // here you can specify any kind of handlers on transaction statuses
         val observer = TransactionStatusObserver.builder()
                 // executed when stateless or stateful validation is failed
-                .onTransactionFailed(t -> System.out.println(String.format(
-                        "transaction %s failed with msg: %s",
+                .onTransactionFailed(t -> System.out.printf(
+                        "transaction %s failed with msg: %s%n",
                         t.getTxHash(),
                         t.getErrOrCmdName()
-                )))
+                ))
                 // executed when got any exception in handlers or grpc
                 .onError(e -> System.out.println("Failed with exception: " + e))
                 // executed when we receive "committed" status
diff --git a/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/detail/GenesisBlockBuilder.java b/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/detail/GenesisBlockBuilder.java
index 80d76fa62..2d94adbf3 100644
--- a/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/detail/GenesisBlockBuilder.java
+++ b/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/detail/GenesisBlockBuilder.java
@@ -11,6 +11,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import jp.co.soramitsu.crypto.ed25519.Ed25519Sha3;
+import jp.co.soramitsu.iroha.java.FieldValidator;
 import jp.co.soramitsu.iroha.java.Transaction;
 import lombok.NoArgsConstructor;
 import lombok.NonNull;
@@ -40,7 +41,7 @@ public class GenesisBlockBuilder {
 
   public GenesisBlockBuilder addDefaultPeer() {
     return this.addTransaction(
-        Transaction.builder(null)
+        Transaction.builder(null, FieldValidator.defaultConfig)
             .addPeer("0.0.0.0:10001", defaultKeyPair.getPublic().getEncoded())
             .build()
             .build()
@@ -63,7 +64,7 @@ public GenesisBlockBuilder addDefaultTransaction() {
    * (false)
    */
   public GenesisBlockBuilder addDefaultTransaction(boolean withDefaultPeer) {
-    val builder = Transaction.builder(null);
+    val builder = Transaction.builder(null, FieldValidator.defaultConfig);
 
     if (withDefaultPeer) {
       // for multi-peer environment it is possible to disable default peer inclusion
diff --git a/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/network/IrohaNetwork.java b/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/network/IrohaNetwork.java
index db56903c9..6ac47c47c 100644
--- a/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/network/IrohaNetwork.java
+++ b/testcontainers/src/main/java/jp/co/soramitsu/iroha/testcontainers/network/IrohaNetwork.java
@@ -8,6 +8,7 @@
 import java.util.List;
 import java.util.stream.Collectors;
 import jp.co.soramitsu.crypto.ed25519.Ed25519Sha3;
+import jp.co.soramitsu.iroha.java.FieldValidator;
 import jp.co.soramitsu.iroha.java.IrohaAPI;
 import jp.co.soramitsu.iroha.java.Transaction;
 import jp.co.soramitsu.iroha.testcontainers.IrohaContainer;
@@ -69,7 +70,7 @@ public IrohaNetwork(int peers) {
 
       // add this peer to genesis block
       genesisBlockBuilder.addTransaction(
-          Transaction.builder(null)
+          Transaction.builder(null, FieldValidator.defaultConfig)
               .addPeer(address, kp.getPublic())
               .build()
               .build()
diff --git a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaContainerTest.groovy b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaContainerTest.groovy
index c85e89d9a..8bc505bfd 100644
--- a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaContainerTest.groovy
+++ b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaContainerTest.groovy
@@ -56,7 +56,7 @@ class IrohaContainerTest extends Specification {
         and: "immediately send transaction"
         def api = new IrohaAPI(ir.getToriiAddress())
         def s = new TestObserver<>()
-        api.transaction(Transaction.builder("test@test")
+        api.transaction(Transaction.builder("test@test", FieldValidator.defaultConfig)
                 .createDomain("dom", GenesisBlockBuilder.defaultRoleName)
                 .sign(GenesisBlockBuilder.defaultKeyPair)
                 .build()
diff --git a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaNetworkTest.groovy b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaNetworkTest.groovy
index 333b0fbcb..0bd68f264 100644
--- a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaNetworkTest.groovy
+++ b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaNetworkTest.groovy
@@ -1,6 +1,7 @@
 package jp.co.soramitsu.iroha.testcontainers
 
 import io.reactivex.observers.TestObserver
+import jp.co.soramitsu.iroha.java.FieldValidator
 import jp.co.soramitsu.iroha.java.Transaction
 import jp.co.soramitsu.iroha.testcontainers.detail.GenesisBlockBuilder
 import jp.co.soramitsu.iroha.testcontainers.network.IrohaNetwork
@@ -30,7 +31,7 @@ class IrohaNetworkTest extends Specification {
         })
 
         when: "valid tx is created"
-        def tx = Transaction.builder("bogdan@test")
+        def tx = Transaction.builder("bogdan@test", FieldValidator.defaultConfig)
                 .setAccountDetail("bogdan@test", "key", "value")
                 .sign(kp)
                 .build()
diff --git a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaTlsTest.groovy b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaTlsTest.groovy
index 8d199c83a..bc957ef10 100644
--- a/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaTlsTest.groovy
+++ b/testcontainers/src/test/groovy/jp/co/soramitsu/iroha/testcontainers/IrohaTlsTest.groovy
@@ -1,5 +1,6 @@
 package jp.co.soramitsu.iroha.testcontainers
 
+import jp.co.soramitsu.iroha.java.FieldValidator
 import jp.co.soramitsu.iroha.java.IrohaAPI
 import jp.co.soramitsu.iroha.java.QueryAPI
 import jp.co.soramitsu.iroha.java.Transaction
@@ -31,7 +32,7 @@ class IrohaTlsTest extends Specification {
 
     static IrohaConfig irohaConfig = IrohaConfig.builder()
             .torii_tls_params(new ToriiTlsConfig())
-            .build();
+            .build()
 
     static peerConfig = PeerConfig.builder()
             .irohaConfig(irohaConfig)
@@ -59,12 +60,12 @@ class IrohaTlsTest extends Specification {
     @Unroll
     def "run Iroha with secure TLS connection"() {
         given:
-        def qapi = new QueryAPI(api, defaultAccount)
+        def qapi = new QueryAPI(api, defaultAccount, FieldValidator.defaultConfig)
         def key = "key"
         def value = "value"
 
         when:
-        def tx = Transaction.builder(defaultAccount.getId())
+        def tx = Transaction.builder(defaultAccount.getId(), FieldValidator.defaultConfig)
                 .setAccountDetail(defaultAccount.getId(), key, value)
                 .sign(defaultAccount.keyPair)
                 .build()