Add CLI createoffer smoketest (for bsq swaps)

NEVER RUN ON MAINNET!
This commit is contained in:
ghubstan 2021-11-25 18:21:06 -03:00
parent 132ecc9ac3
commit 0aa0852407
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,85 @@
package bisq.cli;
import static java.lang.System.out;
import static java.util.Arrays.stream;
/**
Smoke tests for createoffer method. Useful for testing CLI command and examining the
format of its console output.
Prerequisites:
- Run `./bisq-apitest --apiPassword=xyz --supportingApps=bitcoind,seednode,arbdaemon,alicedaemon,bobdaemon --shutdownAfterTests=false --enableBisqDebugging=false`
Note: Test harness will not automatically generate BTC blocks to confirm transactions.
Never run on mainnet!
*/
@SuppressWarnings({"CommentedOutCode", "unused"})
public class CreateOfferSmokeTest extends AbstractCliTest {
public static void main(String[] args) {
createBsqSwapOffer("buy");
createBsqSwapOffer("sell");
}
private static void createBsqSwapOffer(String direction) {
String[] args = createBsqSwapOfferCommand(direction, "0.01", "0.005", "0.00005");
out.print(">>>>> bisq-cli ");
stream(args).forEach(a -> out.print(a + " "));
out.println();
CliMain.main(args);
out.println("<<<<<");
args = getMyOffersCommand(direction);
out.print(">>>>> bisq-cli ");
stream(args).forEach(a -> out.print(a + " "));
out.println();
CliMain.main(args);
out.println("<<<<<");
args = getAvailableOffersCommand(direction);
out.print(">>>>> bisq-cli ");
stream(args).forEach(a -> out.print(a + " "));
out.println();
CliMain.main(args);
out.println("<<<<<");
}
private static String[] createBsqSwapOfferCommand(String direction,
String amount,
String minAmount,
String fixedPrice) {
return new String[]{
PASSWORD_OPT,
ALICE_PORT_OPT,
"createoffer",
"--swap=true",
"--direction=" + direction,
"--currency-code=bsq",
"--amount=" + amount,
"--min-amount=" + minAmount,
"--fixed-price=" + fixedPrice
};
}
private static String[] getMyOffersCommand(String direction) {
return new String[]{
PASSWORD_OPT,
ALICE_PORT_OPT,
"getmyoffers",
"--direction=" + direction,
"--currency-code=bsq"
};
}
private static String[] getAvailableOffersCommand(String direction) {
return new String[]{
PASSWORD_OPT,
BOB_PORT_OPT,
"getoffers",
"--direction=" + direction,
"--currency-code=bsq"
};
}
}

View File

@ -12,7 +12,9 @@ import static java.lang.System.out;
This can be run on mainnet.
*/
@SuppressWarnings({"CommentedOutCode", "unused"})
public class GetOffersSmokeTest {
public class GetOffersSmokeTest extends AbstractCliTest {
// TODO use the static password and port opt definitions in superclass
public static void main(String[] args) {
getMyBsqOffers();