mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Tighten createoffer param validation (only bsq swaps supported)
This commit is contained in:
parent
35aeb61338
commit
eff10842b9
@ -86,6 +86,9 @@ public class CreateOfferOptionParser extends AbstractMethodOptionParser implemen
|
||||
throw new IllegalArgumentException("no btc amount specified");
|
||||
|
||||
if (getIsSwap()) {
|
||||
if (!options.valueOf(currencyCodeOpt).equalsIgnoreCase("bsq"))
|
||||
throw new IllegalArgumentException("only bsq swaps are currently supported");
|
||||
|
||||
if (options.has(paymentAccountIdOpt))
|
||||
throw new IllegalArgumentException("cannot use a payment account id in bsq swap offer");
|
||||
|
||||
@ -97,7 +100,7 @@ public class CreateOfferOptionParser extends AbstractMethodOptionParser implemen
|
||||
|
||||
if (!options.has(fixedPriceOpt) || options.valueOf(fixedPriceOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no fixed price specified");
|
||||
|
||||
|
||||
} else {
|
||||
if (!options.has(paymentAccountIdOpt) || options.valueOf(paymentAccountIdOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no payment account id specified");
|
||||
|
@ -204,6 +204,23 @@ public class OptionParsersTest {
|
||||
assertEquals("no fixed price specified", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateBsqSwapOfferWithIncorrectCurrencyCodeOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createoffer.name(),
|
||||
"--" + OPT_SWAP + "=" + "true",
|
||||
"--" + OPT_DIRECTION + "=" + "sell",
|
||||
"--" + OPT_CURRENCY_CODE + "=" + "xmr",
|
||||
"--" + OPT_MIN_AMOUNT + "=" + "0.075",
|
||||
"--" + OPT_AMOUNT + "=" + "0.125",
|
||||
"--" + OPT_FIXED_PRICE + "=" + "0.00005555"
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateOfferOptionParser(args).parse());
|
||||
assertEquals("only bsq swaps are currently supported", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidCreateBsqSwapOfferOpts() {
|
||||
String[] args = new String[]{
|
||||
|
Loading…
Reference in New Issue
Block a user