Skip to content

Commit

Permalink
Check param count only, not param order correctness
Browse files Browse the repository at this point in the history
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.
bisq-network#4308 (review)
  • Loading branch information
ghubstan authored and eigentsmis committed Jun 26, 2020
1 parent 62a1f4c commit 2484a96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cli/src/main/java/bisq/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,12 @@ public static void run(String[] args) {
return;
}
case createpaymentacct: {
if (nonOptionArgs.size() < 2)
throw new IllegalArgumentException("no account name specified");
if (nonOptionArgs.size() < 4)
throw new IllegalArgumentException(
"incorrect parameter count, expecting account name, account number, currency code");

var accountName = nonOptionArgs.get(1);

if (nonOptionArgs.size() < 3)
throw new IllegalArgumentException("no account number specified");

var accountNumber = nonOptionArgs.get(2);

if (nonOptionArgs.size() < 4)
throw new IllegalArgumentException("no fiat currency specified");

var fiatCurrencyCode = nonOptionArgs.get(3);

var request = CreatePaymentAccountRequest.newBuilder()
Expand Down
7 changes: 7 additions & 0 deletions cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@
[ "$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" {
run ./bisq-cli --password=xyz createpaymentacct PerfectMoneyDummy 0123456789 USD
[ "$status" -eq 0 ]
Expand Down

0 comments on commit 2484a96

Please sign in to comment.