Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Migrate method tests to scenario test cases #4717

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cb65de6
Block on tx-fee-request in core TakeOfferModel init
ghubstan Oct 23, 2020
ab20225
Add compiler warning suppression, remove comment
ghubstan Oct 24, 2020
63cf436
Add fields to grpc TradeInfo proto & wrapper
ghubstan Oct 24, 2020
296e4f9
Replace static TradeUtil with singleton TradeUtil
ghubstan Oct 24, 2020
ccd3c99
Fix comment typos
ghubstan Oct 24, 2020
24ba921
Refactor PendingTradesViewModel methods -> TradeUtil & OfferUtil
ghubstan Oct 25, 2020
36ad137
Remove trailing spaces for codacy
ghubstan Oct 25, 2020
95bcb1e
Refactor PendingTradesDataModel methods -> TradeUtil
ghubstan Oct 25, 2020
bbd7a31
Remove unused import
ghubstan Oct 25, 2020
161dbad
Add getRole(tradeId) to core api
ghubstan Oct 25, 2020
3379376
Refactor CLI output formatting code & add trade formatter
ghubstan Oct 25, 2020
d8bc265
Add license comment
ghubstan Oct 25, 2020
31435bb
Move semicolon up from blank line
ghubstan Oct 25, 2020
2b23704
Add 'gettrade' to api method CLI
ghubstan Oct 25, 2020
a2b2923
Add boolean 'showcontract' argument to api's 'gettrade'
ghubstan Oct 25, 2020
a8decaf
Stub out api methods 'keepfunds', 'withdrawfunds'
ghubstan Oct 26, 2020
a3631a0
Implement api methods 'keepfunds', 'withdrawfunds'
ghubstan Oct 26, 2020
f1db254
Make formatSatoshis visible for testing
ghubstan Oct 27, 2020
b8ae566
Add method for printing current jupiter test name
ghubstan Oct 27, 2020
1e25be5
Test trade closing api methods 'keepfunds' withdrawfunds'
ghubstan Oct 27, 2020
2746b27
Fix apitest dummy payment acct init bug
ghubstan Oct 27, 2020
027a7d5
Stub out canceloffer api method
ghubstan Oct 27, 2020
0f1d4f8
Fix typo
ghubstan Oct 27, 2020
b38507c
Implement api method 'canceloffer'
ghubstan Oct 27, 2020
91a2e2c
Add canceloffer test
ghubstan Oct 27, 2020
41f2219
Consolidate all wallet tests into one scenario test
ghubstan Oct 27, 2020
792d74f
Remove dead code
ghubstan Oct 27, 2020
9df122c
Disable offer method test cases, run all from 1 scenario test
ghubstan Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -70,10 +70,8 @@ public boolean hasShutdownExceptions() {

@Override
public void logExceptions(List<Throwable> exceptions, org.slf4j.Logger log) {
StringBuilder errorBuilder = new StringBuilder();
for (Throwable t : exceptions) {
log.error("", t);
errorBuilder.append(t.getMessage()).append("\n");
}
}

Expand Down
30 changes: 30 additions & 0 deletions apitest/src/test/java/bisq/apitest/method/MethodTest.java
Expand Up @@ -43,11 +43,14 @@
import java.util.stream.Collectors;

import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.apitest.config.BisqAppConfig.arbdaemon;
import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
import static bisq.core.payment.payload.PaymentMethod.PERFECT_MONEY;
import static java.util.Arrays.stream;
import static java.util.Comparator.comparing;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;



Expand All @@ -67,6 +70,33 @@ public class MethodTest extends ApiTestCase {
protected PaymentAccount alicesDummyAcct;
protected PaymentAccount bobsDummyAcct;

public static void startSupportingApps(boolean registerDisputeAgents,
boolean generateBtcBlock,
Enum<?>... supportingApps) {
try {
// To run Bisq apps in debug mode, use the other setUpScaffold method:
// setUpScaffold(new String[]{"--supportingApps", "bitcoind,seednode,arbdaemon,alicedaemon,bobdaemon",
// "--enableBisqDebugging", "true"});
setUpScaffold(supportingApps);
if (registerDisputeAgents) {
registerDisputeAgents(arbdaemon);
}

if (stream(supportingApps).map(Enum::name).anyMatch(name -> name.equals(alicedaemon.name())))
aliceStubs = grpcStubs(alicedaemon);

if (stream(supportingApps).map(Enum::name).anyMatch(name -> name.equals(bobdaemon.name())))
bobStubs = grpcStubs(bobdaemon);

// Generate 1 regtest block for alice's and/or bob's wallet to
// show 10 BTC balance, and allow time for daemons parse the new block.
if (generateBtcBlock)
genBtcBlocksThenWait(1, 1500);
} catch (Exception ex) {
fail(ex);
}
}

protected final void initAlicesDummyPaymentAccount() {
alicesDummyAcct = getDefaultPerfectDummyPaymentAccount(alicedaemon);
}
Expand Down
Expand Up @@ -62,30 +62,20 @@ public abstract class AbstractOfferTest extends MethodTest {

@BeforeAll
public static void setUp() {
startSupportingApps();
startSupportingApps(true,
true,
bitcoind,
seednode,
arbdaemon,
alicedaemon,
bobdaemon);
}

@BeforeEach
public void initDummyPaymentAccount() {
super.initAlicesDummyPaymentAccount();
}

static void startSupportingApps() {
try {
// setUpScaffold(new String[]{"--supportingApps", "bitcoind,seednode,arbdaemon,alicedaemon,bobdaemon", "--enableBisqDebugging", "true"});
setUpScaffold(bitcoind, seednode, arbdaemon, alicedaemon, bobdaemon);
registerDisputeAgents(arbdaemon);
aliceStubs = grpcStubs(alicedaemon);
bobStubs = grpcStubs(bobdaemon);

// Generate 1 regtest block for alice's wallet to show 10 BTC balance,
// and give alicedaemon time to parse the new block.
genBtcBlocksThenWait(1, 1500);
} catch (Exception ex) {
fail(ex);
}
}

protected final OfferInfo createAliceOffer(PaymentAccount paymentAccount,
String direction,
String currencyCode,
Expand Down
Expand Up @@ -26,14 +26,15 @@

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import static org.junit.jupiter.api.Assertions.assertEquals;


@Disabled
@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CancelOfferTest extends AbstractOfferTest {
Expand Down
Expand Up @@ -23,6 +23,7 @@

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -32,6 +33,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

@Disabled
@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
Expand Down
Expand Up @@ -26,6 +26,7 @@

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -40,6 +41,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static protobuf.OfferPayload.Direction.BUY;

@Disabled
@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
Expand Down
Expand Up @@ -25,6 +25,7 @@

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -33,6 +34,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@Disabled
@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ValidateCreateOfferTest extends AbstractOfferTest {
Expand Down
74 changes: 74 additions & 0 deletions apitest/src/test/java/bisq/apitest/scenario/OfferTest.java
@@ -0,0 +1,74 @@
package bisq.apitest.scenario;


import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import static bisq.apitest.Scaffold.BitcoinCoreApp.bitcoind;
import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.apitest.config.BisqAppConfig.arbdaemon;
import static bisq.apitest.config.BisqAppConfig.seednode;



import bisq.apitest.method.offer.CancelOfferTest;
import bisq.apitest.method.offer.CreateOfferUsingFixedPriceTest;
import bisq.apitest.method.offer.CreateOfferUsingMarketPriceMarginTest;
import bisq.apitest.method.offer.ValidateCreateOfferTest;

@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class OfferTest extends ScenarioTest {

@BeforeAll
public static void setUp() {
startSupportingApps(true,
true,
bitcoind,
seednode,
arbdaemon,
alicedaemon);
}

@Test
@Order(1)
public void testAmtTooLargeShouldThrowException() {
ValidateCreateOfferTest test = new ValidateCreateOfferTest();
test.initDummyPaymentAccount();
test.testAmtTooLargeShouldThrowException();
}

@Test
@Order(2)
public void testCancelOffer() {
CancelOfferTest test = new CancelOfferTest();
test.initDummyPaymentAccount();
test.testCancelOffer();
}

@Test
@Order(3)
public void testCreateOfferUsingFixedPrice() {
CreateOfferUsingFixedPriceTest test = new CreateOfferUsingFixedPriceTest();
test.initDummyPaymentAccount();
test.testCreateAUDBTCBuyOfferUsingFixedPrice16000();
test.testCreateUSDBTCBuyOfferUsingFixedPrice100001234();
test.testCreateEURBTCSellOfferUsingFixedPrice95001234();
}

@Test
@Order(4)
public void testCreateOfferUsingMarketPriceMargin() {
CreateOfferUsingMarketPriceMarginTest test = new CreateOfferUsingMarketPriceMarginTest();
test.initDummyPaymentAccount();
test.testCreateUSDBTCBuyOffer5PctPriceMargin();
test.testCreateNZDBTCBuyOfferMinus2PctPriceMargin();
test.testCreateGBPBTCSellOfferMinus1Point5PctPriceMargin();
test.testCreateBRLBTCSellOffer6Point55PctPriceMargin();
}
}