Check param count only, not param order correctness

This change simplifies client 'createpaymentacct' method parameter
validation.  It no longer assumes parameter ordering is correct, and
only verifies the string parameter count is correct.

A unit test was also added to cli/test.sh

This commit is in response to the requested change in PR 4308.
https://github.com/bisq-network/bisq/pull/4308#pullrequestreview-435052357
This commit is contained in:
ghubstan 2020-06-23 12:42:56 -03:00
parent 52529a912e
commit 9691f35082
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
2 changed files with 10 additions and 10 deletions

View File

@ -202,19 +202,12 @@ public class CliMain {
return; return;
} }
case createpaymentacct: { case createpaymentacct: {
if (nonOptionArgs.size() < 2) if (nonOptionArgs.size() < 4)
throw new IllegalArgumentException("no account name specified"); throw new IllegalArgumentException(
"incorrect parameter count, expecting account name, account number, currency code");
var accountName = nonOptionArgs.get(1); var accountName = nonOptionArgs.get(1);
if (nonOptionArgs.size() < 3)
throw new IllegalArgumentException("no account number specified");
var accountNumber = nonOptionArgs.get(2); var accountNumber = nonOptionArgs.get(2);
if (nonOptionArgs.size() < 4)
throw new IllegalArgumentException("no fiat currency specified");
var fiatCurrencyCode = nonOptionArgs.get(3); var fiatCurrencyCode = nonOptionArgs.get(3);
var request = CreatePaymentAccountRequest.newBuilder() var request = CreatePaymentAccountRequest.newBuilder()

View File

@ -166,6 +166,13 @@
[ "$output" = "Error: address bogus not found in wallet" ] [ "$output" = "Error: address bogus not found in wallet" ]
} }
@test "test createpaymentacct PerfectMoneyDummy (missing nbr, ccy params)" {
run ./bisq-cli --password=xyz createpaymentacct PerfectMoneyDummy
[ "$status" -eq 1 ]
echo "actual output: $output" >&2
[ "$output" = "Error: incorrect parameter count, expecting account name, account number, currency code" ]
}
@test "test createpaymentacct PerfectMoneyDummy 0123456789 USD" { @test "test createpaymentacct PerfectMoneyDummy 0123456789 USD" {
run ./bisq-cli --password=xyz createpaymentacct PerfectMoneyDummy 0123456789 USD run ./bisq-cli --password=xyz createpaymentacct PerfectMoneyDummy 0123456789 USD
[ "$status" -eq 0 ] [ "$status" -eq 0 ]