Added tests to cover validity checks on group min/max block delay values

This commit is contained in:
catbref
2020-04-23 17:06:23 +01:00
parent a7d0ad27b1
commit 1375372380
5 changed files with 133 additions and 0 deletions

View File

@@ -77,6 +77,16 @@ public class CreateGroupTransaction extends Transaction {
if (createGroupTransactionData.getApprovalThreshold() == null)
return ValidationResult.INVALID_GROUP_APPROVAL_THRESHOLD;
// Check min/max block delay values
if (createGroupTransactionData.getMinimumBlockDelay() < 0)
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
if (createGroupTransactionData.getMaximumBlockDelay() < 1)
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
if (createGroupTransactionData.getMaximumBlockDelay() < createGroupTransactionData.getMinimumBlockDelay())
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
// Check group name size bounds
int groupNameLength = Utf8.encodedLength(createGroupTransactionData.getGroupName());
if (groupNameLength < 1 || groupNameLength > Group.MAX_NAME_SIZE)

View File

@@ -242,6 +242,7 @@ public abstract class Transaction {
ACCOUNT_CANNOT_REWARD_SHARE(90),
SELF_SHARE_EXISTS(91),
ACCOUNT_ALREADY_EXISTS(92),
INVALID_GROUP_BLOCK_DELAY(93),
NOT_YET_RELEASED(1000);
public final int value;

View File

@@ -83,6 +83,16 @@ public class UpdateGroupTransaction extends Transaction {
if (updateGroupTransactionData.getNewApprovalThreshold() == null)
return ValidationResult.INVALID_GROUP_APPROVAL_THRESHOLD;
// Check min/max block delay values
if (updateGroupTransactionData.getNewMinimumBlockDelay() < 0)
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
if (updateGroupTransactionData.getNewMaximumBlockDelay() < 1)
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
if (updateGroupTransactionData.getNewMaximumBlockDelay() < updateGroupTransactionData.getNewMinimumBlockDelay())
return ValidationResult.INVALID_GROUP_BLOCK_DELAY;
// Check new description size bounds
int newDescriptionLength = Utf8.encodedLength(updateGroupTransactionData.getNewDescription());
if (newDescriptionLength < 1 || newDescriptionLength > Group.MAX_DESCRIPTION_SIZE)