Commit Graph

400 Commits

Author SHA1 Message Date
ghubstan
fdb89a26d0
Test new api method 'getpaymentacctform' 2020-11-18 16:18:57 -03:00
ghubstan
ec381522ff
Add api method 'getpaymentmethods'
Returns a list of supported payment method IDs.  This gives CLI users
the correct payment method id for creating a new payment account.

- Added gRPC service GetPaymentMethods to grpc.proto.

- Added gRPC boilerplate method to GrpcPaymentAccountsService.

- Added implimentation to CoreApi -> CorePaymentAccountsService.

- Refactored PaymentAccountTest hierarchy.

- Add api method to CLI.
2020-11-18 12:03:22 -03:00
ghubstan
34efc049f8
Remove unnecessary fully qualified name 2020-11-14 13:34:22 -03:00
ghubstan
7e9ab22d65
Refactor api getbalance methods.
This change fixes the recently bloated wallet balances api.  Now there
is one CLI getbalance [bsq|btc] method that calls a getbalances(currency-code)
on the server.  The server returns full wallet balance information for
BSQ, BTC, or both if the CLI's currency argument is absent.

- grpc.proto:  Reduced number of getbalance(s) proto services from
  four to one.

- GrpcWalletsService:  Reduced number of getbalance(s) gRPC service
  boilerplate methods from four to one.

- CoreApi, CoreWalletsService:  Reduced number of getbalance(s) gRPC
  service implementation methods from four to one.

- CliMain:  Reduced number of getbalance(s) commands from four to one.

- BalancesInfo: Changed BsqBalanceInfo & BtcBalanceInfo field names
  to bsq and btc, respectively, to make calling their accessors
  more readable, less verbose.

- BtcBalanceInfo, BsqBalanceInfo: Defined static final EMPTY instances
  as place holders in a BalancesInfo returned by the gRPC server, when
  one or the other balance types is not requested.  Would be nice
  to serve Optional.empty() instead, but protobuf does not support
  it or null.

- Adjusted affected api tests and build doc.
2020-11-14 13:08:10 -03:00
ghubstan
8157f8fc4e
Delete deprecated api test, adjust api build/run doc 2020-11-13 16:57:18 -03:00
ghubstan
722460e7e5
Support paying trade fees in bsq or btc (api)
- Add optional makerFeeCurrencyCode argument to CLI's 'createoffer'.

- Add optional takerFeeCurrencyCode argument to CLI's 'takeoffer'.

- Add isCurrencyForMakerFeeBtc field to OfferInfo proto wrapper.

- Pass fee currency argument down to CoreOffersService and CoreTradesService's
  create and take offer methods.

- Add maybeSetFeePaymentCurrencyPreference method to OfferUtil to
  conditionally set the 'payFeeInBtc' preference before creating
  or taking an offer.

- Adjust affected tests.
2020-11-13 16:36:06 -03:00
ghubstan
446bd328d8
Refactor desktop's BsqSendView, share with api
Moved just enough code out of BsqSendView to avoid desktop/api
'sendbsq' duplication, at the cost of adding 1 new method to
BsqSendView.

- Created new BsqTransferModel to hold tx details shared by desktop and api.

- Created new BsqTransferService to send bsq using a BsqTransferModel shared
  by desktop and api.

- Uncommented CoreWalletsService#sendBsq implementation.

- Uncommented sendbsq tests.
2020-11-13 15:34:18 -03:00
ghubstan
dc3274ff5f
Re comment sendbsq tests so travis ci does not fail 2020-11-13 14:59:31 -03:00
ghubstan
0d3b3a6ead
Stub out api method 'sendbsq' in core
All the boilerplate for this method is included in this change, but
the implementation in CoreWalletsService#sendBsq is commented out
until the needed logic to send bsq is refactored out of desktop's
BsqSendView class -- to be included in the next PR.

- Added new method to CLI.

- Added the gRPC server boilerplate.

- Added the core implementation, commented out.

- Enabled tests.
2020-11-13 14:57:28 -03:00
ghubstan
7f0f949a2d
Resolve unnecessary use of fully qualified name for codacy 2020-11-13 14:35:26 -03:00
ghubstan
208a37b339
Implement and test new getbalance(s) api methods
- Added three new methods to CLI:

      getbalances   ...	returns complete bsq and btc balance info
      getbsqbalance ...	returns complete bsq balance info
      getbtcbalance ...	returns complete btc balance info

      The old getbalance method is deprecated and will be removed
      if there is agreement to do that.

- Made the needed changes in the CLI's output formatting classes.

- Added new tests to existing BsqWalletTest, added new BtcWalletTest
  and WalletBalancesTest.

- Added disabled tests for funding a bsq wallet (todo in next PR).
2020-11-13 14:21:26 -03:00
ghubstan
7c2068e3c1
Add teardown to test case 2020-11-13 12:45:40 -03:00
ghubstan
c1c099c832
Implement and test api method 'getunusedbsqaddress'
- Added new method to CLI, split some long msg strings into two lines,
  and added a white space after a braceless else statement.

- Added the gRPC server boilerplate.

- Added the core implementation.

- Added a test, and moved method wallet tests into their own package.
2020-11-13 12:40:16 -03:00
ghubstan
6f159bcb48
Fix usage comment 2020-11-02 12:55:18 -03:00
ghubstan
c2f8db3c7d
Reduce apitest case execution time
Consolidated all method tests into fewer test cases by running them
from new 'scenario' test cases.  This cuts the current scaffold
setup & teardown times by almost 1/2.  No method tests were deleted
or duplicated.

(1)  Disabled all method (unit) test cases at the class level.
(2)  Added new scenario test cases to run all disabled test cases (1).

The method test cases can still be run by commenting out the @Disabled
annotation.
2020-10-28 18:17:59 -03:00
ghubstan
e8e55d2286
Remove redundant ScenarioTest superclass 2020-10-28 18:01:49 -03:00
ghubstan
f61f148db1
Refactor api test fixture setup
- Remove dead code from AbstractLinuxProcess.

- Make default dummy accts static in MethodTest.

- Simplify gRPC stub creation, btc block generation, dispute agent
  registration, and dummy acct initialization in test case startup.

- Make ExpectedProtocolStatus visible to scenario test pkg.
2020-10-28 17:59:15 -03:00
ghubstan
2a05203519
Remove dead code 2020-10-28 17:46:30 -03:00
ghubstan
91a2e2ce1f
Add canceloffer test 2020-10-27 19:06:59 -03:00
ghubstan
2746b27674
Fix apitest dummy payment acct init bug
This commit fixes non-trade tests broken by the last refactoring.
2020-10-27 13:47:23 -03:00
ghubstan
1e25be5bdc
Test trade closing api methods 'keepfunds' withdrawfunds'
Some refactoring of the api test case hierarchy is included in this commit.
2020-10-27 13:04:53 -03:00
ghubstan
b8ae566b69
Add method for printing current jupiter test name 2020-10-27 13:03:48 -03:00
ghubstan
3379376bab
Refactor CLI output formatting code & add trade formatter
- Move output column header specs to its own shared constants class.

- Add new TradeFormat class for printing trade details in the console.

- Print formatted trade in api trade tests -- to see output before
  using formatter in CLI (in next PR).
2020-10-25 16:50:22 -03:00
ghubstan
ac8ed8dd06
Add 'confirmpaymentreceived' api method
- Implement confirmpaymentsent on server and cli side

- Enable confirmpaymentreceived method tests
2020-10-20 16:51:48 -03:00
ghubstan
3d2b90fb96
Add 'confirmpaymentsent' api method
- Implement confirmpaymentsent on server and cli side

- Enable confirmpaymentsent method tests
2020-10-20 16:20:40 -03:00
ghubstan
e809af37cc
Add 'takeoffer' API method
- Add new core.offer.takeoffer.TakeOfferModel

	Would have been nice to move more logic from
	bisq.desktop.main.offer.takeoffer.TakeOfferDataModel,
	but it has JFX dependencies that cannot be use in :core.

- Add grpc protos to support takeoffer, confirmpaymentsent, confirmpaymentreceived

	Only takeoffer is implemented in this commit.

- Refactor OfferInfo grpc proto wrapper, and add offer state field

- Add new TradeInfo grpc proto wrapper

- Implement takeoffer on server and cli side

- Refactor offer/trade tests, add test cases
2020-10-20 16:00:05 -03:00
sqrrm
44394adb1e
Merge pull request #4608 from ghubstan/getoffer-for-id
Add new 'getoffer offer-id' api method
2020-10-15 11:14:05 +02:00
ghubstan
29d1905f31
Add new 'getoffer offer-id' api method
There are a number of use cases where a user may want to see a single
offer instead of every offer for a currency pair on the buy or sell side.
The changes are:

- Add getoffer to grpc.proto
- Add new method to GrpcOffersService, CoreApi, CoreOffersService
- Add new method to CLI
- Adjust create offer tests to use this new convenience
2020-10-07 12:09:13 -03:00
ghubstan
1a8f97afab
Fix register dipute agent test assert
This should have been included in commit 5f9b1e6, PR 4595.
2020-10-07 11:19:05 -03:00
ghubstan
9942529448
Remove redundant DisputeAgentType enum
Use existing SupportType enum instead, and map the valid api
'registerdisputeagent' method's dispute-agent-type parameter
names to SupportType.
2020-10-03 15:42:27 -03:00
ghubstan
d3d6d98666
Revert all changes since commit d55114e
Revert Task.java back to the state it was in prior to
my attempts to make it work for passing error msgs to a
gRPC CLI running 'placeoffer'.  Adjust the affected test
accordingly.
2020-10-03 11:55:58 -03:00
ghubstan
631c3f4f12
Log provenance of Task error on server, but pass only exception msg to clients
Adjusted create offer validation test
2020-10-02 15:02:37 -03:00
ghubstan
fc94b97a00
Throw exception to CLI if attempted offer placement fails 2020-09-28 18:11:08 -03:00
ghubstan
fa5c21c0b2
Fix BitcoinCli wrapper create bug 2020-09-28 14:30:30 -03:00
ghubstan
94996a5e25
Fix tx result handling in GrpcOffersService
Separates offer placement from offer creation to fix tx result
handling problem in GrpcOffersService, and readies the core api
for a new CLI 'placeoffer' implementation.  Offer placement still
happens in the api's 'createoffer', but we may want to change it
to show the created offer to a CLI user for review, prior to manual
placement via a new 'placeoffer offer-id' (of 'confirmoffer offer-id'?)
api method.
2020-09-28 11:48:56 -03:00
ghubstan
70531693f0
Fix asserts 2020-09-27 17:02:38 -03:00
ghubstan
35a77be7e4
Redefine DisputeAgentType REFUNDAGENT as REFUND_AGENT
The CLI needs to be able to register a REFUND_AGENT using the
'refund_agent' or 'refundagent' parameter value (in any case),
so an alt-name mapping was added to the enum def.
2020-09-27 15:23:19 -03:00
ghubstan
96abda4e2d
Tidy up create offer using mkt price margin % test 2020-09-26 13:40:10 -03:00
ghubstan
18df1e2fd4
Fix abs(dbl) comparison 2020-09-25 20:53:45 -03:00
ghubstan
2f3e3a31e1
Add simple mkt-price service & test calculated offer prices
A gRPC price service was added, and api create-offer tests can check
mkt based price margin calculations.
2020-09-25 20:48:26 -03:00
ghubstan
6cf9bbbaa9
Minor createoffer test changes 2020-09-25 13:58:32 -03:00
ghubstan
6cdbc137c1
Move 'createoffer' price arg transform to server & test it
The CreateOfferRequest's price field type was changed from long to string,
so a CLI param like 10000.0055 can be passed to the server as is, to be
scaled and converted there.  In general, we want to keep validation logic
on the CLI as simple as possible, and use existing core logic to
validate args and convert arg types when needed.
2020-09-24 18:13:19 -03:00
ghubstan
9999c95a9e
Change 'createoffer' argument order
And list the args in CLI --help outout.
2020-09-24 13:48:50 -03:00
ghubstan
ec9c1b0f10
Uppercase direction & ccy-code CLI arguments in core
Don't convert parameter case in CLI.
2020-09-24 09:18:13 -03:00
ghubstan
d190d09e2b
Fix unnecessary use of fully qualified name 2020-09-22 22:58:32 -03:00
ghubstan
fc1f0bac60
Fix imports 2020-09-22 22:56:08 -03:00
ghubstan
70e3be0032
Add API CreateOfferTest case 2020-09-22 22:16:55 -03:00
ghubstan
92f36ed03a
Add get default payment acct helper 2020-09-22 22:08:01 -03:00
ghubstan
c4dd041d97
Don't use static boilerplate helpers if not necessary 2020-09-22 18:20:23 -03:00
ghubstan
1d88d27330
Remove final modifiers 2020-09-22 18:11:55 -03:00
ghubstan
6a5040228e
Add simple create payment acct test
And make test dispute agent registration work from static fixture
setup methods.
2020-09-22 18:05:09 -03:00
ghubstan
8896372a0f
Move test dispute agent type constants to core
The string constants deleted from the test case are re-defined as enums,
but the test harness still passes around strings (enum.name()) because
the handling of invalid dispute agent type string args needs to be
tested.  (Reminder:  CLI does not accept any enum arguments.)
2020-09-22 15:31:38 -03:00
ghubstan
34cfe9532f
Remove comment 2020-09-22 14:51:31 -03:00
ghubstan
9132722bbf
Replace hardcoded version with Version.java value
Bats version check tests now use a bash script for parsing
the value from the Bisq class file, and these test cases
no longer need to be manually updated.
2020-09-22 14:45:21 -03:00
sqrrm
c814e3b8ed
Merge pull request #4540 from ghubstan/remove-strings
Reduce apitest harness' dependency on string matching
2020-09-22 11:39:32 +02:00
ghubstan
ab282c2c77
Reduce apitest harness' dependency on string matching
- Pass list of supporting app names as enum vararg to scaffold setup.
- Use dispute agent type constants in RegisterDisputeAgentsTest case.
2020-09-19 15:41:12 -03:00
ghubstan
e2bd89f39a
Refactor API & add registerdisputeagent method to CLI
This commit contains most of the changes suggested by @chimp1984 in
his api-suggestions branch.  See
961703ecea

A new 'registerdisputeagent' method was also added to MainCli, finishing
the work to support registration of mediators and refund agents on
arbitration daemons running in regtest mode.  This method cannot be
used to register dispute agents on mainnet;  users will see an error
msg if they try.
2020-09-18 11:33:16 -03:00
ghubstan
3f0394f722
Bump version to 1.3.8 2020-09-14 12:14:37 -03:00
ghubstan
8384dd8004
Add api dispute agent registration test case
This test case checks that mediators and refund agents can be
registered over grpc, but not on mainnet.
2020-09-14 12:13:36 -03:00
ghubstan
148a0f1200
Refactor test cases to use arbitrary grpc stubs
Most test cases send requests to the alicedaemon, but new test cases
will need to be able to send requests to arbitration and bob daemons.
2020-09-14 12:09:04 -03:00
ghubstan
899bea8df5
Replace "localhost" strings with InetAddress.getLoopbackAddress calls 2020-09-14 11:53:02 -03:00
ghubstan
4d12b8f3d3
Allow remote debugging of background Bisq apps
A unique hard coded debug listening port is assigned to the different
Bisq app types in the BisqAppConfig enum, and background Bisq apps
will be started with remote debug options if the scaffold-setup method
is passed an --enableBisqDebugging=true option.

* Added enableBisqDebugging (default=false) option to ApiTestConfig.

* Added remoteDebugPort field to BisqAppConfig enum.

* Added debugOpts field to BisqApp (using BisqAppConfig#remoteDebugPort).

* Appends debugOpts to exported JAVA_OPTS environment variable if present.

* Removed messy quotes from BisqAppConfig enum javaOpts values.

* Removed redundant return statement from BisqApp#shutdown().
2020-08-25 12:59:55 -03:00
ghubstan
b9c1feba9a
Remove redundant ApiTestConfig options
This change removes three options: runArbNodeAsDesktop,
runAliceNodeAsDesktop, and runBobNodeAsDesktop, which should have
been deleted when the supportingApps option was added.  The comma
delimited list of apps passed with the supportingApps option
now determines whether arbitration / bob / alice nodes are started as
desktops or daemons.
2020-08-25 12:35:57 -03:00
ghubstan
cb6166c65f
Remove duplicated grpc stub creation logic
The :apitest GrpcStubs class was removed and recreated in the :cli
subproject, to be used by both :cli and :apitest.  CliMain was changed
to use the new GrpcStubs.
2020-08-25 12:01:29 -03:00
ghubstan
2c803ef811
Move :cli test.sh to :apitest mainnet-test.sh
* The bats test script was moved to the apitest subproject and renamed.

* Version tests were updated for release 1.3.7.

* The duplicated "test getoffers buy eur check return status" was
  replaced by a new "test getoffers sell eur check return status" test.

* The bats dependency was switched to bats-core because development
  has halted on https://github.com/sstephenson/bats/tree/master.
  The new bats repository is
          https://github.com/bats-core/bats-core/tree/master
2020-08-25 11:42:09 -03:00
ghubstan
ac3c6e07f0
Fix setUpScaffold() signature
Adds the missing String[] params to the method signature, so test cases
can pass any needed combination of options to the scaffolding setup
from a @BeforeAll method.
2020-08-25 11:29:27 -03:00
ghubstan
c4023869bf
Remove duplicate CompositeOptionSet class
This commit changes the access modifier on
bisq.common.config.CompositeOptionSet to make
it visible to bisq.apitest.config.ApiTestConfig,
and the duplicate bisq.apitest.config.ApiTestConfig
was deleted from 'apitest'.
2020-08-24 15:29:32 -03:00
ghubstan
1de6239527
Shorten line length < 120 chars 2020-08-24 11:03:26 -03:00
ghubstan
ba8b9ccf54
Put 'empty' comments inside ignored catch blocks
Follow codacy rule against empty blocks.
2020-08-19 11:49:21 -03:00
ghubstan
2ba0ee9d5d
Change access modifer
This commit is for forcing a codacy check.  The previous
change to an .md doc did not force a codacy check.
2020-08-19 11:14:33 -03:00
ghubstan
fa11dab28b
Add punctuation & re-phrase sentence in README
A new commit was needed to force a codacy check after changes were
made to codacy rules.
2020-08-19 11:04:21 -03:00
ghubstan
c3abd4e533
Remove white lines 2020-08-18 10:38:26 -03:00
ghubstan
8b081ad5f2
Update README 2020-08-17 16:18:08 -03:00
ghubstan
af7252ec47
Fix typo 2020-08-17 16:14:37 -03:00
ghubstan
f85ae2bb4d
Explain how to run test cases from Intellij 2020-08-17 16:11:31 -03:00
ghubstan
fc541257ae
Add build / run / test categories docs 2020-08-17 15:57:54 -03:00
ghubstan
12d52e869c
Fix port number typo 2020-08-15 13:22:32 -03:00
ghubstan
e88bdb9f8a
Add regtest-port-conflicts.md doc 2020-08-15 12:46:38 -03:00
ghubstan
72ff4dca2b
Use non-default regtest bitcoind -rpcport
The default bitcoind / bitcoin-cli rpcport option has been changed
from 18443 to 19443, to help avoid rpcport conflicts between apitest's
bitcoind instances and other bitcoind and/or bitcion-qt instances
which are probably using the bitcoin-core default (regtest) rpcport
18443.

However, this commit cannot include other changes for avoiding bind
address:port conflicts between apitest bitcoind instances and other
regtest bitcoin-core instances because bitcoinj's bind port is hardcoded
in RegTestParams.java as 18444.

In order to avoid bitcoin-core regtest mode bind address conflicts,
you must start or restart your bitcoind or bitcoin-qt instance with a
non-default bind port argument, e.g.

	bitcoin-qt -regtest -port=20444
2020-08-15 12:20:25 -03:00
ghubstan
9637cc0943
Fix test fail() msg 2020-08-13 14:19:02 -03:00
ghubstan
176f0b2ad8
Fix BitcoinCli wrapper error handling
This change checks the system call exit status of bitcoin-cli
commands, and populates a new error message accessor if the
system exist status != 0.
2020-08-13 13:32:58 -03:00
ghubstan
685839d348
Add fallbackfee param to bitcoind start cmd
This commit adds a -fallbackfee=0.0002 parameter to the start 'bitcoind'
command to keep bitcoin-core v0.20.1 working as v0.19.1 does -- with the
'fallbackfee' enabled.

Bitcoin v0.20.0 contains a fix for inconsistent behaviour related
to this fallbackfee configuration.  Prior to v0.20, fallbackfee
was disabled (0) by default for the mainnet chain, but enabled
(0.0002) for the testnet and regtest chains.

A test case with bitcoin-core v0.20.1 was breaking on
the bitcoin-cli 'sendtoaddress' command, which was returning an
error message instead of a tx-id:

    error code: -4
    error message:
    Fee estimation failed. Fallbackfee is disabled. \
    Wait a few blocks or enable -fallbackfee.

Bitcoin-core v0.20.0 release notes contain info about this change:
    https://bitcoin.org/en/release/v0.20.0#updated-rpcs-1

The Bitcoin-core PR is https://github.com/bitcoin/bitcoin/pull/16524
2020-08-12 16:47:12 -03:00
ghubstan
8bb7e12f31
Clarify scaffold tear down error handling
The Scaffold#tearDown() method was split into two methods.  The
original tearDown() now passes the background process/task array
to a new shutDownAll() method.  This new method loops through the
tasks in a more readable way, plainly expressing the intent to log
all shutdown exceptions for each process being shut down, but not
throwing an exception while processes are being shut down.
The new shutDownAll() method returns the first shutdown exception
encountered, which in turn is passed up to the test case's @AfterAll
method.
2020-07-28 12:33:25 -03:00
ghubstan
e2f00b7417
Remove extra whiteline 2020-07-27 16:43:43 -03:00
ghubstan
27ee4b8974
Do not leave orphaned processes after failed teardown
The test harness should not fail a test case's @AfterAll (teardown)
method on the first background instance shutdown exception.  This
change makes the shutdown logic similar to the startup's:  it caches
any exceptions that may have occurred during an instance shutdown,
logs them, then proceeds to shut down the next background instance.
An IllegalStateException (the 1st one) is passed up to @AfterAll method
only after the scaffolding teardown process is complete, to avoid leaving
any orphaned java or bitcoind processes running after a java system
exit.
2020-07-27 16:35:46 -03:00
ghubstan
cf031e6883
Change 'missing bitcoind path' error msg
Since JUnit tests cannot take program arguments, change the
wording to instruct the user to configure the bitcoind path
in apitest.properties
2020-07-22 10:58:20 -03:00
ghubstan
13a8396b45
Remove unnecessary curly braces 2020-07-20 15:05:10 -03:00
ghubstan
999e9ec93b
Fix @BeforeClass error handling and use jupiter api
The Scaffold set up was calling System.exit(1) when it encountered a
configuration error, or a problem starting bitcoind & bisq instances.
This incorrect error handling was hiding errors from gradle, and
preventing tests that would otherwise successfully complete.

This change fixes the problem by throwing an IllegalStateException up
to the test case's @BeforeClass method -- to be caught and used in a
JUnit fail(ex) call.  An 'initializationError' triggered in @BeforeClass
correctly bubbles up to gradle, and will not block execution of remaining
tests.  A gradle Test Summary containing any initialization errors is also
produced in <project-dir>/apitest/build/reports/tests/test/index.html

This change also fixes many import statements and asserts to ensure
'org.junit.jupiter.api.*' is used in place of 'org.junit.*', for
proper gradle integration.
2020-07-20 14:53:00 -03:00
ghubstan
b4d3ea7e02
Add comment about Bisq DAO dev environment
Some explanation is needed about why Bob & Alice have non-zero
initial BTC and BSQ balances when tests run.  The comments
also include links to more detailed information about the DAO/
regtest testing environment.
2020-07-20 12:37:35 -03:00
ghubstan
bf584c218f
Move test cases into subproject test sources
This change reorganizes the ':apitest' subproject to conform to a
typical gradle project, where all JUnit test cases are located in
the subproject's test sources folder.  This makes running tests
from an IDE or gradle command line interface work as expected.
It will also help keep Travis CI configuration simple.

To avoid interfering in normal builds, the gradle ':apitest test' task
is disable by default;  API tests will only run when a '-Dforce-true'
system property is passed to gradle.

To run API tests, run a normal build and install dao-setup files:

    ./gradlew clean build :apitest:installDaoSetup

Then run the tests:

    ./gradlew :apitest:test -Dforce=true

Try to avoid adding the '-Dforce=true' property to any other gradle
tasks, because this enables the ':apitest test' task, and would kick
off API tests before a normal build completed.

The build.gradle file was modified to support this code reorg, and
the 'org.junit.jupiter' dependendency was upgraded to v5.6.2 -- only
in the ':apitest:test' dependency definiitions, not anywhere else in
the bisq dependency definitions.  The upgrade is necessary for
running ordered tests.

Since the scaffolding may be set up from either test cases (under the
test src folder), or a class under the main src folder, some changes
were made to ensure configuration paths are correct for either use
case.  For example, when the 'bisq-apitest' script is run from the root
project directory, the current working directory is the root project
directory.  When gradle or an IDE is used to run @Test cases, the
current working directory is :apitest subproject directory.

The main source's ApiTestMain class has been stripped down, and exists
only to keep the gradle build happy -- it needs a 'mainClassName'
property.  But this main driver does have uses.  See the class comments.

The other changes in this commit were made to fix style and syntax
problems.
2020-07-19 16:31:46 -03:00
ghubstan
7c974b22ac
Moving GrpcStubs to test sources 2020-07-19 14:18:34 -03:00
ghubstan
19346bbe78
Delete all JUnit related class from main sources
JUnit tests are being moved to the subproject's test sources
directory for the sake of convention -- for developers using
this test harness, and for IDE and gradle JUnit integration.
2020-07-19 13:43:25 -03:00
ghubstan
1847da0110
Delete unused bitcoin.conf from resources dir 2020-07-17 17:29:28 -03:00
ghubstan
f7d8c0e5c3
Do not use bitcoin.conf files
This change removes code for installing a regtest bitcoin.conf file.
It also removes an unused  bitcoin.conf file from the main resources
directory.

Now, the bitcoind startup command passes all configurations on the
command line.  (See bisq.apitest.linux.BitcoinDaemon.java)
2020-07-17 17:20:53 -03:00
ghubstan
5d7133a9b4
Do not subtract fee from 'bitcoin-cli sendtoaddress'
Test cases need to be as simple as possible for now.
2020-07-17 12:31:03 -03:00
ghubstan
2852e3da8b
Add JUnitHelper to run tests from JUnitCore 2020-07-16 20:54:20 -03:00
ghubstan
687bcf1d8f
Add FundWalletScenarioTest
Some refactoring was done to reduce some of the boilerplate.
2020-07-16 20:53:11 -03:00
ghubstan
6edab1a2cd
Create convenient way to call bitcoin-cli from tests
A BitcoinCliHelper class was added.  GetBalanceTest's @BeforeClass
was simplified, and it no longer starts up the arbitration node.
2020-07-16 19:22:51 -03:00
ghubstan
7d664d9cfd
Do not "killall bitcoind" processes
Just kill the one we started.
2020-07-16 17:05:32 -03:00
ghubstan
4296d96d40
Remove all sudo related logic from the linux pkg
The BashCommand wrapper should never be used run run sudo commands,
and if the word "sudo" is found in a bash command, System.exit(1)
will be called.
2020-07-16 16:11:10 -03:00
ghubstan
431cbe727f
Bump bisqAppInitTime default back up to 5s 2020-07-15 20:46:46 -03:00
ghubstan
e0ea9db32e
Fix bitcoind startup error handling
Like Bisq instance startup, bitcoind startup should save any error msg
from bash, print the error msg, and System.exit(1).
2020-07-15 20:03:47 -03:00
ghubstan
b2417d3e5f
Delete throws clause from method signature 2020-07-15 20:01:30 -03:00
ghubstan
c19afebc04
Fix 'bitcoind not found' error message 2020-07-15 19:26:16 -03:00
ghubstan
d108d89bb2
Fix comment and code styling 2020-07-15 11:13:00 -03:00
ghubstan
cf3b545173
Fix hardcoded bitcoin.conf property values 2020-07-15 10:56:35 -03:00
ghubstan
a00bc4b414
Add --bisqAppInitTime=<Long> config option
This change makes configurable the amount of time (ms) each Bisq
instance is given to initialize before starting (a) another Bisq
instance, or (b) tests.
2020-07-15 10:45:05 -03:00
ghubstan
28aefc5cb1
Add tests for resetting a wallet password 2020-07-14 16:17:10 -03:00
ghubstan
2cf7915f25
Add wallet protect method tests
Some of these 'method' tests make more than one gRPC call, but
they are for checking correctness of a single gRPC method,
and don't quite fall into the 'scenario' test category.
2020-07-14 15:04:42 -03:00
ghubstan
5df0b1ec4b
Refactor ApiTestCase class hierarchy
Also added a new base ScenarioTest class, which extends
MethodTest;  Method and Scenario tests cases have access to gRPC
service stubs, but end to end test cases should never use them.
2020-07-14 14:20:26 -03:00
ghubstan
498939a9ff
Allow more time for background app shutdown 2020-07-14 12:41:41 -03:00
ghubstan
6b738f7443
Replace config 'numSetupTasks' with 'supportingApps'
This change replaces the non-intuitive numSetupTasks=<Integer>
configuration option with a supportingApps=<String> option.  It
accepts a comma delimited list of app names, and determines
which background apps will be started in @BeforeClass.

None of the current method tests need all supporting apps, and
this change will reduce scaffolding setup and teardown time.

The current method test cases were changed to use this option.
WalletProtectionTest and GetVersionTest only need to start "alicedaemon".
GetBalanceTest needs "bitcoind,seednode,arbdaemon,alicedaemon".
2020-07-14 12:37:13 -03:00
ghubstan
45c1a97938
Fix codacy problem in bash script
Double quote to prevent globbing and word splitting.
2020-07-14 12:21:13 -03:00
ghubstan
8ed44b8cee
Remove @Skip annotaion
We are using JUnit now and can use @Ignore
2020-07-14 10:37:32 -03:00
ghubstan
1acf340f79
Get rid of references to removed @Skip annotation 2020-07-14 10:35:14 -03:00
ghubstan
84af092401
Add driver for running method tests
API test cases are not in a maven/gradle project test folder.
IDEs may not automatically configure JUnit test launchers,
and a gradle build command will not automatically run tests.
This class is provided as a convenience until gradle tasks
for running test cases are implemented.
2020-07-13 22:17:05 -03:00
ghubstan
4f08ec3edc
Add first JUnit 'method' tests
These @Order-ed test cases should be run with OrderedRunner.

They are called 'method' tests because they are the closest
thing to an API 'unit' test.  Method tests are not end to end
tests;  they have access to gRPC service stubs and do asserts
on Java values.  We can write 'method' tests for the new
gRPC methods we need to implement (test driven development).

Some notes about the three API test categories...

The plan is to categorize some of the narrower functional tests
as 'scenario' tests.  Like 'method' tests, 'scenario' tests will
have  access to gRPC service stubs and do asserts on Java values,
but they will cover use cases requiring several gRPC and bitcoin-cli
method calls.  One example is funding a wallet:  using bitcoin-cli
and bisq-cli to generate new addresses, send BTC from bitcoin-core
to a Bisq wallet, generate a bitcoin block, and check the Bisq
wallet's balance.  Another example is wallet unlocking/locking
scenarios that are a bit more complex than 'unit' or 'method' tests.

The third category of tests will be end to end, and live in an
'e2e' package.  They will cover more complex use cases and
do asserts on the Bisq CLI's console output (stdout/stderr),
not return values from gRPC service stubs.

There may sometimes be a fine line between what is a 'scenario'
test and an 'e2e' test.  But what starts out as a 'scenario' test
during test driven development can migrate to an 'e2e' test after
thorough testing in the quicker 'scenario' dev/test cycle.
2020-07-13 20:34:25 -03:00
ghubstan
080952b1d7
Support @Order-ing of JUnit tests 2020-07-13 20:30:48 -03:00
ghubstan
e17480ad8f
Remove hacked method tests
Although JUnit is geared towards running randomly ordered unit
tests, we can use it to write API tests to be run in a pre-defined
order.  This is necessary because API tests will be functional
(narrow to broad) and end-to-end;  we want to be able to write
@Test methods that run in @Order.

The next commit will add a JUnit OrderedRunner class, and an @Order
annotation.
2020-07-13 20:13:30 -03:00
ghubstan
486f06beef
Refresh dao-setup files in Scaffold setup
Many test cases will need to run on a clean, initialized dao-setup;
we do not want call dao-setup.gradle tasks from Java.

For now, every JUnit test case will refresh the dao-setup data in
@BeforeClass, but @AfterClass will not clean out the dao-setup files.
We want to be able to look at bitcoin-core and bisq app data & log
files after a test.

Given the difficulty of refreshing dao-setup files using Java,
I took a short cut and used the apitest.linux pkg's BashCommand
to replace dao-setup files.

Some bitcoin.conf and blocknotify configuratation logic was
also moved from ApiTestConfig to Scaffold in this commit.
2020-07-13 19:54:39 -03:00
ghubstan
2678b31a18
Remove test scaffolding logic from ApiTestConfig 2020-07-13 19:52:21 -03:00
ghubstan
84976fef35
Fix varible names 2020-07-13 19:51:27 -03:00
ghubstan
d782e8d8ec
Do not run dummy test from driver 2020-07-13 19:50:33 -03:00
ghubstan
35ff4e5d79
Delete commented statement 2020-07-13 19:48:59 -03:00
ghubstan
4d5c767902
Fix codacy problem
Add comment inside empty method.
2020-07-13 10:28:31 -03:00
ghubstan
458d2f3f4f
Add license note 2020-07-12 22:15:16 -03:00
ghubstan
fae661c912
Run MethodTestSuite 2020-07-12 22:05:36 -03:00
ghubstan
65e3370d51
Add license note, format tearDown(), fix comment 2020-07-12 22:03:46 -03:00
ghubstan
db5a685468
Make init() method public 2020-07-12 21:56:51 -03:00
ghubstan
81aeeddc4a
Add MethodTestSuite 2020-07-12 21:52:23 -03:00
ghubstan
0edcc3baa8
Add first method test cases
These are method test cases for gRPC methods that have already been
well tested by :cli/test.sh
2020-07-12 21:48:22 -03:00
ghubstan
96cabfb177
Support @Skip on test classes and methods
Add super class for all test types (method, scenario, end-to-end),
and an class & method level annotation for skipping tests.
2020-07-12 21:44:21 -03:00
ghubstan
390cba1b75
Fix codacy problem
Codacy wants comments inside an empty method.
2020-07-12 14:53:32 -03:00
ghubstan
ffe376e8dc
Fix codacy problems
Avoid throwing raw exception types.

Document empty method body.
2020-07-12 14:39:20 -03:00
ghubstan
2c10836a69
Expose grpc service stubs
Added :proto to the :apitest classpath for access to grpc
service stubs (to be) used in method (unit) tests.  Added new
GrpcStubs class to expose the grpc service stubs to method and
scenario tests.

The larger goal of :apitest is end to end testing, where :cli's
console output is checked for correctness.

This change partially addresses two other important use cases:

 * "method" testing -- an analog to unit testing
 * "scenario" testing -- an analog to narrow functional testing

For example, tests in the apitest.method package will directly
call grpc services, and asserts will be made on the return values
instead of console output.

Tests in the apitest.scenario package will check correctness
for broader use cases, such as funding a wallet, encrypting then
unlocking a wallet  for a specific time frame, or checking error
messages from the server when a "getbalance" call is made after
an "unlockwallet" timeout has expired.

The broader end to end tests will not use grpc stubs.
2020-07-12 13:55:08 -03:00
ghubstan
87525ca85d
Move test setup scaffolding into new Scaffold class
ApiTestMain will run all defined tests, but we also want to run
individual test suites and test cases, and they will need to
run the setup tasks as well.
2020-07-12 13:36:10 -03:00
ghubstan
851902117d
Add line break in front of port config 2020-07-12 13:23:53 -03:00
ghubstan
a1e2536ed5
Fix hanging background process problem
SetupTask submissions for Bisq background apps seednode, arbnode,
etc., would not always complete due to a blocking stderr stream
handler thread.join() call.  This change makes waiting on a bash
process err stream optional.
2020-07-11 18:15:17 -03:00
ghubstan
898219aba5
Assume bitcoin-core is statically linked to berkeley-db
The `berkeleyDbLibPath` option now defaults to an empty string.
If not set to a berkeley lib path on the command line or the
apitest.properties file, this option is ignored, and 'bitcoind'
will be started without first exporting the berkeley db library
path.

In other words:  If the bitcoind binary is dynamically linked to
berkeley db libs, export the configured berkeley-db lib path before
starting 'bitcoind'.  If statically linked,  the berkeley db lib
path will not be exported.

Also fixed exception msgs to show missing config file's absolute path.
2020-07-11 10:26:26 -03:00
ghubstan
798fde847b
Fix error msgs 2020-07-10 14:27:25 -03:00
ghubstan
ca378cdd13
Fix error msg spacing 2020-07-10 14:24:35 -03:00
ghubstan
05d0ce0ef8
Fix codacy problem
Avoid throwing null pointer exceptions.
2020-07-09 16:56:09 -03:00
ghubstan
efbaa5be73
Fix codacy problems
Avoid throwing raw exception types.

Combine nested if statements.
2020-07-09 16:54:03 -03:00
ghubstan
09929c833f
Fix codacy problems
Unnecessary use of fully qualified name 'System.exit' due to existing
static import 'java.lang.System.exit'.  (line 100)

Avoid throwing raw exception types.  (lines 295, 302)
2020-07-09 16:49:16 -03:00
ghubstan
e9baebc443
Add build tasks for installing dao-setup files
This gradle file is 'applied' by the main build file.

Usage:

  Run a full clean, build, download dao-setup.zip,
  and install the zip files contents in directory
  apitest/build/resources/main:

    ./gradlew clean build :apitest:installDaoSetup

  Download (if necessary) the dao-setup.zip file
  and install its contents in directory
  apitest/build/resources/main  (no build).

    ./gradlew :apitest:installDaoSetup
2020-07-09 16:03:46 -03:00
ghubstan
ae3b263cac
Add :apitest main driver, setup task & dummy tests
The driver class uses an ExecutorService to submit Callable
tasks for starting bitcoind and Bisq nodes as Linux background
processes.

By default, ApiTestMain starts background processes to support
regtest/dao testing, runs a few bitcoin-cli commands, then
shuts down all background processes before exiting.
(Actual API test suites have not been implemented yet.)

ApiTestConfig options can be used to skip tests and/or leave
background processes running indefinitely.
2020-07-09 15:49:12 -03:00
ghubstan
c0c75e2471
Support starting bitcoin & bisq apps on Linux
The apitest.linux package is for running random bash commands,
running 'bitcoind -regtest', running random 'bitcoin-cli -regtest'
commands, and spinning up Bisq apps such as seednode, arbnode,
and bob & alice nodes.

All but random bash and bitcoin-cli commands are run in the background.

The bitcoin-cli response processing is crude;  a more sophiticated
bitcoin-core rpc interface is not in the scope of this PR.
2020-07-09 15:35:45 -03:00
ghubstan
77b6878ec6
Add script to get Bisq app pid
Finding the pid of background linux/java processes has been
difficult to do from java, so a bash script is provided to
simplify the task.
2020-07-09 15:30:22 -03:00
ghubstan
e0c27eedcf
Add main resource files
* apitest.properties - config file for customizing ApiTestConfig
  options

* logback.xml - logging config file, will override logback files
  found in classpath

* bitcoin.conf - bitcoin-core regtest config file, overwritten
  during startup with correct path to blocknofity

* blocknotify - bitcoin-core blocknotify config file
2020-07-09 15:27:01 -03:00
ghubstan
88b5e9dbad
Add configuration support
ApiTestConfig works like :common Config, but specific to this subproject.

BisqAppConfig is an enumeration specifying Bisq desktop and daemon
options for running seednode, arbnode, bob & alices nodes in regtest /
full-dao mode.
2020-07-09 15:11:42 -03:00