Commit Graph

97 Commits

Author SHA1 Message Date
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