Nyzo version 619 (commit on GitHub) improves utility classes used by the client.
This version affects the client only.
A new class, ClientArgumentUtil, provides methods that assist in processing of arguments passed to client commands.
The ClientArgumentUtil.getInteger() methods process int arguments, providing a default value for unparsable inputs and optional range limits.
The ClientArgumentUtil.getLong() methods process long arguments, providing the same options as the getInteger() methods.
The ClientArgumentUtil.getSenderData() method processes sender-data inputs, handling both plain text and normalized sender-data strings.
In ClientTransactionUtil.bytesFromNormalizedSenderDataString(), the underscoreIndex is now set to 66 when there are no underscores in the string. This allows 32-byte values to be decoded properly.
The remaining changes in this version are testing code. The ClientArgumentUtilTest class ensures that the ClientArgumentUtil class interprets arguments as expected.
The ClientArgumentUtilTest.main() method allows this test to be run separately.
The ClientArgumentUtilTest.run() method implements the top level of the test. Both pairs of numerical methods are tested. Then, the sender-data method is tested.
The ClientArgumentUtilTest.testIntegerMethods() method tests both valid and invalid inputs, testing both the simple and range-limited ClientArgumentUtil.getInteger() overloads.
The ClientArgumentUtilTest.testLongMethods() method parallels ClientArgumentUtilTest.testIntegerMethods().
The ClientArgumentUtilTest.testSenderDataMethod() method examines the behavior of ClientArgumentUtil.getSenderData() with a variety of text and normalized sender-data string inputs. One of the test cases in this method revealed the inability of ClientTransactionUtil.bytesFromNormalizedSenderDataString() to process values of 32 bytes in length.
The ClientArgumentUtilTest.array() method is a simple alias to ByteUtil.byteArrayFromHexString(). This method was added to make ClientArgumentUtilTest.testSenderDataMethod() more readable.
The ClientArgumentUtilTest.getFailureCause() exposes failureCause, as required by the NyzoTest interface.
The CommandManagerTest ensures that no ambiguous command strings are present in CommandManager. A similar test is already completed on client initialization. The main() method, following NyzoTest convention, allows separate execution of this test class.
The CommandManagerTest.run() method performs a simple check of the command strings specified by all commands in CommandManager.
ClientArgumentUtilTest and CommandManagerTest were added to TestUtil.