Commit b9fef132 authored by Georg Mittendorfer's avatar Georg Mittendorfer

Remove default values for custom command validation.

Default values are set via properties file. Validation set to 0 or max values as fallback.
parent c13541e7
...@@ -39,9 +39,6 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; ...@@ -39,9 +39,6 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
public class AttachToTangle extends IriCommand { public class AttachToTangle extends IriCommand {
static final String COMMAND = "attachToTangle"; static final String COMMAND = "attachToTangle";
public static final int DEFAULT_WEIGHT_MAX = 15;
public static final int DEFAULT_WEIGHT_MIN = 14;
public static final int DEFAULT_MAX_TRYTES_COUNT = 20;
public AttachToTangle() { public AttachToTangle() {
super(); super();
......
...@@ -35,11 +35,6 @@ public class GetTransactionsToApprove extends IriCommand { ...@@ -35,11 +35,6 @@ public class GetTransactionsToApprove extends IriCommand {
static final String COMMAND = "getTransactionsToApprove"; static final String COMMAND = "getTransactionsToApprove";
// 3 is the recommended value
// 15 is the current iri limit but that seems to be too high.
public static final int DEFAULT_DEPTH_MIN = 1;
public static final int DEFAULT_DEPTH_MAX = 10;
@NotNull @NotNull
private int depth; private int depth;
......
...@@ -38,8 +38,6 @@ public class GetTrytes extends IriCommand { ...@@ -38,8 +38,6 @@ public class GetTrytes extends IriCommand {
static final String COMMAND = "getTrytes"; static final String COMMAND = "getTrytes";
public static final int DEFAULT_HASHES_SIZE_MAX = 1000;
//@NotEmpty // can be empty for a new seed (light wallet) //@NotEmpty // can be empty for a new seed (light wallet)
@NotNull @NotNull
@JsonInclude(value=NON_NULL) @JsonInclude(value=NON_NULL)
......
...@@ -40,9 +40,9 @@ public class AttachToTangleValidator implements Validator { ...@@ -40,9 +40,9 @@ public class AttachToTangleValidator implements Validator {
public AttachToTangleValidator(Environment env, MinMaxValidator minMaxValidator) { public AttachToTangleValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator; this.minMaxValidator = minMaxValidator;
min = env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MIN); min = env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, 0);
max = env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MAX); max = env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, Integer.MAX_VALUE);
maxTrytes = env.getProperty("iri.attachToTangle.trytes.max", Integer.class, AttachToTangle.DEFAULT_MAX_TRYTES_COUNT); maxTrytes = env.getProperty("iri.attachToTangle.trytes.max", Integer.class, Integer.MAX_VALUE);
} }
@Override @Override
......
...@@ -34,8 +34,8 @@ public class GetTransactionsToApproveValidator implements Validator { ...@@ -34,8 +34,8 @@ public class GetTransactionsToApproveValidator implements Validator {
public GetTransactionsToApproveValidator(Environment env, MinMaxValidator minMaxValidator) { public GetTransactionsToApproveValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator; this.minMaxValidator = minMaxValidator;
min = env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MIN); min = env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, 0);
max = env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MAX); max = env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, Integer.MAX_VALUE);
} }
@Override @Override
......
...@@ -34,7 +34,7 @@ public class GetTrytesValidator implements Validator { ...@@ -34,7 +34,7 @@ public class GetTrytesValidator implements Validator {
public GetTrytesValidator(Environment env, MinMaxValidator minMaxValidator) { public GetTrytesValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator; this.minMaxValidator = minMaxValidator;
max = env.getProperty("iri.getTrytes.hashes.max", Integer.class, GetTrytes.DEFAULT_HASHES_SIZE_MAX); max = env.getProperty("iri.getTrytes.hashes.max", Integer.class, Integer.MAX_VALUE);
} }
@Override @Override
......
...@@ -42,11 +42,11 @@ public class AttachToTangleValidatorTest { ...@@ -42,11 +42,11 @@ public class AttachToTangleValidatorTest {
@Before @Before
public void initEnvironment() { public void initEnvironment() {
Environment env = mock(Environment.class); Environment env = mock(Environment.class);
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MAX)) when(env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(3); .thenReturn(3);
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MIN)) when(env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, 0))
.thenReturn(2); .thenReturn(2);
when(env.getProperty("iri.attachToTangle.trytes.max", Integer.class, AttachToTangle.DEFAULT_MAX_TRYTES_COUNT)) when(env.getProperty("iri.attachToTangle.trytes.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(5); .thenReturn(5);
validator = new AttachToTangleValidator(env, minMaxValidator); validator = new AttachToTangleValidator(env, minMaxValidator);
} }
......
...@@ -40,9 +40,9 @@ public class GetTransactionsToApproveValidatorTest { ...@@ -40,9 +40,9 @@ public class GetTransactionsToApproveValidatorTest {
@Before @Before
public void initEnvironment() { public void initEnvironment() {
Environment env = mock(Environment.class); Environment env = mock(Environment.class);
when(env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MAX)) when(env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(3); .thenReturn(3);
when(env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MIN)) when(env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, 0))
.thenReturn(2); .thenReturn(2);
validator = new GetTransactionsToApproveValidator(env, minMaxValidator); validator = new GetTransactionsToApproveValidator(env, minMaxValidator);
} }
......
...@@ -42,7 +42,7 @@ public class GetTrytesValidatorTest { ...@@ -42,7 +42,7 @@ public class GetTrytesValidatorTest {
@Before @Before
public void initEnvironment() { public void initEnvironment() {
Environment env = mock(Environment.class); Environment env = mock(Environment.class);
when(env.getProperty("iri.getTrytes.hashes.max", Integer.class, GetTrytes.DEFAULT_HASHES_SIZE_MAX)) when(env.getProperty("iri.getTrytes.hashes.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(42); .thenReturn(42);
validator = new GetTrytesValidator(env, minMaxValidator); validator = new GetTrytesValidator(env, minMaxValidator);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment