Commit Graph

388 Commits

Author SHA1 Message Date
ghubstan
7880a84a00
Add BSQ offer editing tests to EditOfferTest
And log CLI's getoffer output to see getoffer formatting -- after adding
new ENABLED and TRIGGER-PRICE columns.
2021-06-18 17:52:03 -03:00
ghubstan
a3ea4ecbf6
Avoid duplicate test run 2021-06-15 13:22:07 -03:00
ghubstan
bc1576efbc
Throw exception is edit altcoin offer is attempted
Support for editing BSQ offers is in place, but will be added
in another PR.
2021-06-15 13:13:52 -03:00
ghubstan
063b52eb70
Add editoffer test case, suppress annoying warnings 2021-06-15 11:39:06 -03:00
ghubstan
54efad097d
Fix codacy issue 2021-06-13 14:05:00 -03:00
ghubstan
05f3985447
Fix problems found in codacy check 2021-06-13 13:54:16 -03:00
ghubstan
9a5e2d0df1
Remove unused import 2021-06-13 13:12:45 -03:00
ghubstan
571568a5e5
Remove chase quickpay acct test 2021-06-13 13:10:41 -03:00
ghubstan
929b28cb8c
Add editoffer api tests & minor apitest refactoring 2021-06-13 13:00:27 -03:00
ghubstan
2b1a7aac82
Remove unsupported create CHASE_QUICK_PAY apitest case 2021-06-12 17:46:55 -03:00
ghubstan
984aac713d
Fix NetworkParameters.fromID( incorrect-arg -> correct-arg ) 2021-04-28 12:22:26 -03:00
ghubstan
38eee59375
Fix flaky tx fee rate validation test (api)
Min tx fee rates move fast, sometimes so low the validation test fails.
Try to consistently force validation error by setting fee rate=1.
2021-04-28 12:01:25 -03:00
ghubstan
81f345b9ea
Fix bsq wallet testcase setup (api)
Regtest btc block was not being generated, and chain download not triggered.
Also ajusted testGetUnusedBsqAddress() for upcoming segwit bsq changes.
2021-04-28 12:00:54 -03:00
ghubstan
cff5e8163e
Update apitest docs for bitcoin-core v0.21 compat
The test harness is compatible with bitcoin-core 0.19, 0.20, 0.21.

Also removed some unnecessary comments about registering dispute
agents in the test harness because it now happens by default.
2021-04-19 12:35:13 -03:00
ghubstan
2308afb41b
Adjust to changing minimum tx fee rates
- Append minFeeServiceRate to TxFeeRateInfo proto.
- Display min rate in CLI console.
- Fix broken test due to changing min fee rate.
2021-04-19 12:08:52 -03:00
ghubstan
126885d570
Test BSQ/BTC trade pair
- Added CreateBSQOffersTest, TakeBuyBSQOfferTest, TakeSellBSQOfferTest.
  The first tests bsq offer creation, the second & third test bsq trade
  protocol, and includes bsq payment verification checks.

- Made test dispute agent registration a test harness opt.
  It was a test case option, now it happens by default.

- Moved some global test constants into ApiTestConfig.
  Adjusted affected test cases.
2021-04-15 14:23:32 -03:00
ghubstan
6299dc33d9
Merge branch '01-api-add-createcryptopaymentacct' into 02-api-trade-contract-details 2021-04-01 15:58:59 -03:00
ghubstan
152f4591eb
Remove unused parameter 2021-03-26 11:04:51 -03:00
ghubstan
780be1a93c
Adjust maker gettrade output checks to new column
The number of gettrade output columns are the same for makers and takers.
2021-03-26 10:58:47 -03:00
Steven Barclay
f21379160b
Merge branch 'release/v1.6.0' into implement-segwit-for-bsq 2021-03-20 23:18:49 +00:00
ghubstan
e963391a87
Print trade info to console after successful trade 2021-03-19 21:21:09 +01:00
ghubstan
39cda43208
Add LongRunningTradesTest
This new api testcase can run long series' of regtest trades by looping
over modified TakeBuyBTCOfferTest and TakeSellBTCOfferTest cases.  The
purpose is to help reproduce problems and isolate bugs Bisq's core and
api layers.

LongRunningTradesTest is not enabled by default;  it will not run in a
default test environment (such a Travis CI).  Enviornment variable
LONG_RUNNING_TRADES_TEST_ENABLED must exist for the test to run.
The env variable can be set in a bash shell before running the test
case in a shell (using a gradle command), or the environment variable can
be set in an Intellij test launcher's Evironment variables field.

The modifed (short running) TakeBuyBTCOfferTest and TakeSellBTCOfferTest
cases run as before.

Changes include:

- Add static boolean isLongRunningTest to AbstractOfferTest.

- Add looping control Supplier maxTradeStateAndPhaseChecks to AbstractTradeTest.
  It uses the isLongRunningTest flag in the superclass to help define the
  wait times for trade state/phase changes during short and long running tests.

- Made AbstractTradeTest assert(true, trade.isDepositPublished) conditional upon
  isLongRunningTest value.  Long running trade test asserts have to be looser due
  to increasing latency of wallet, offer and trade operations in the server as the
  trade counts increase.

- Overload ApiTestCase#startSupportingApps with additional flag:
  startSupportingAppsInDebugMode. Default is false.  This makes
  starting background apps in debug mode a bit more convenient
  and self explanatory.
2021-03-19 21:21:02 +01:00
ghubstan
56345a2256
Add missing grpc exception catch blocks 2021-03-19 19:37:31 +01:00
sqrrm
53f42c4885
Merge pull request #5303 from ghubstan/03-add-long-running-trade-test
Add LongRunningTradesTest to apitest
2021-03-19 12:20:00 +01:00
sqrrm
1c3fc41c33
Merge pull request #5294 from ghubstan/01-fix-takeoffer-err-handling
Improve takeoffer error handing
2021-03-19 11:55:18 +01:00
ghubstan
0b22c98802
Disambiguate payment acct json form's "country" field
Make it clear the user needs to enter a two letter country code
in json form's "country" field, not a country name.

The json form's field name was not changed to "countryCode" in
this change for the following reason:

The API's payment account forms are dynamically generated using
reflection, and PaymentAccount class hierarchy @Setter methods
determine which form fields are included or excluded.  Reflection
and @Setter methods are also used when reading completed json
forms, to set the field values on a new PaymentAccount instance
before it is persisted.

CountryBasedPaymentAccount subclasses have a country field and a
@Setter, not a countryCode field, hence this shortcut to informing
the user the country field value is a country-code.
2021-03-18 20:34:10 +01:00
ghubstan
67252642c7
Disambiguate payment acct json form's "country" field
Make it clear the user needs to enter a two letter country code
in json form's "country" field, not a country name.

The json form's field name was not changed to "countryCode" in
this change for the following reason:

The API's payment account forms are dynamically generated using
reflection, and PaymentAccount class hierarchy @Setter methods
determine which form fields are included or excluded.  Reflection
and @Setter methods are also used when reading completed json
forms, to set the field values on a new PaymentAccount instance
before it is persisted.

CountryBasedPaymentAccount subclasses have a country field and a
@Setter, not a countryCode field, hence this shortcut to informing
the user the country field value is a country-code.
2021-03-18 16:14:28 -03:00
ghubstan
14b2bc2544
Make codacy happy (I hope) 2021-03-18 14:49:57 -03:00
ghubstan
f732983d6c
Make multi-line bash command copy/pastable from rendered md 2021-03-18 14:20:47 -03:00
ghubstan
514e7b74ce
Refactor, include section about running on mainnet 2021-03-18 13:22:31 -03:00
ghubstan
ec65c010f7
Don't be polite 2021-03-18 13:12:32 -03:00
ghubstan
d07a26d560
Add missing withdrawfunds options 2021-03-18 12:58:26 -03:00
ghubstan
d3b5e1ee4b
Alternate ports to improve api/protocol guide 2021-03-18 12:56:18 -03:00
ghubstan
bc6c1769ec
Print trade info to console after successful trade 2021-03-14 13:40:34 -03:00
ghubstan
1f28fc6836
Add LongRunningTradesTest
This new api testcase can run long series' of regtest trades by looping
over modified TakeBuyBTCOfferTest and TakeSellBTCOfferTest cases.  The
purpose is to help reproduce problems and isolate bugs Bisq's core and
api layers.

LongRunningTradesTest is not enabled by default;  it will not run in a
default test environment (such a Travis CI).  Enviornment variable
LONG_RUNNING_TRADES_TEST_ENABLED must exist for the test to run.
The env variable can be set in a bash shell before running the test
case in a shell (using a gradle command), or the environment variable can
be set in an Intellij test launcher's Evironment variables field.

The modifed (short running) TakeBuyBTCOfferTest and TakeSellBTCOfferTest
cases run as before.

Changes include:

- Add static boolean isLongRunningTest to AbstractOfferTest.

- Add looping control Supplier maxTradeStateAndPhaseChecks to AbstractTradeTest.
  It uses the isLongRunningTest flag in the superclass to help define the
  wait times for trade state/phase changes during short and long running tests.

- Made AbstractTradeTest assert(true, trade.isDepositPublished) conditional upon
  isLongRunningTest value.  Long running trade test asserts have to be looser due
  to increasing latency of wallet, offer and trade operations in the server as the
  trade counts increase.

- Overload ApiTestCase#startSupportingApps with additional flag:
  startSupportingAppsInDebugMode. Default is false.  This makes
  starting background apps in debug mode a bit more convenient
  and self explanatory.
2021-03-14 13:08:53 -03:00
ghubstan
d4d989d680
Add missing grpc exception catch blocks 2021-03-10 14:17:05 -03:00
ghubstan
04b52f873e
Fix setSelectedCurrency bug, and replace unnecessary reflection usage
Commit de59c0a5f9 did not persist the
assigned selected currency, this fixes the bug.
2021-03-08 16:02:18 -03:00
ghubstan
75d81d9095
Avoid test run repetition, add warning supressions 2021-03-08 15:26:15 -03:00
ghubstan
de59c0a5f9
Assign selected trading currency on new payment accts (api only)
If a new account has a trading currency, assign it as the selected trading currency.

Also fixed a payment acct console formatting issue (left justify the ccy code).
2021-03-08 15:22:28 -03:00
ghubstan
b4f4d90e05
Add tradeCurrencies field to Transferwise acct form
These changes make tradeCurrencies a required twise acct form field.

Addresses issue https://github.com/bisq-network/bisq/issues/5281

- Added comment to PaymentAccountForm about special 'tradeCurrencies' field handling.
- Added support for Transferwise 'tradeCurrencies' to PaymentAccountTypeAdapter.
- Added instance of isTransferwiseAccount check to PaymentAccount.
- Added methods to CurrencyUtil to convert comma delimited code list to TradeCurrency list.
- Added methods to ReflectionUtil for getting fields and methods on class.
- Added required field check to CorePaymentAccountsService.
- Added CreatePaymentAccount test cases.
2021-03-08 14:47:30 -03:00
ghubstan
99fea74e09
Validate offer <-> payment-acct in createoffer
This change prohibits creation of new offers with incompatible payment
accounts with the api.

- PaymentAccountUtil
  Renamed isAnyTakerPaymentAccountValidForOffer -> isAnyPaymentAccountValidForOffer.
  Renmaed isTakerPaymentAccountValidForOffer -> isPaymentAccountValidForOffer.
  Deleted commented code.

- PaymentAccounts: Adjusted to PaymentAccountUtil method name changes.

- OfferFilter: Adjusted to PaymentAccountUtil method name changes.

- OfferBookViewModelTest: Adjusted to PaymentAccountUtil method name changes.

- Add CoreOffersService#verifyPaymentAccountIsValidForOffer

- ValidateCreateOfferTest, OfferTest: Added test cases.
2021-03-07 19:51:29 -03:00
ghubstan
a2000bdc33
Explain how to manually register test dispute agents 2021-03-03 12:44:29 -03:00
ghubstan
e0bf773564
Add link to api-beta-test-guide.md 2021-03-03 12:43:21 -03:00
ghubstan
3f84246f59
Improve interceptor's rate metering key definition and lookup
This change replaces the hard coded strings used as keys in
interceptor rate-metering lookup maps.

Now, the fullMethodName defined in each bisq.proto.grpc.* class'
io.grpc.MethodDescriptor is used, not a hard coded String.

For example, the rate metering lookup key for 'GetBalances',
in 'GrpcWalletsService', is the

   fullMethodName = SERVICE_NAME + '/' + "GetBalances",

   where SERVICE_NAME = "io.bisq.protobuffer.Wallets".

Also adjusted affected tests, and tidy'd up interceptor logging.
2021-02-28 17:10:51 -03:00
ghubstan
19aed84910
Fix getunusedbsqaddress test 2021-02-27 22:58:22 -03:00
ghubstan
b618776b1b
Wait 3 secs after removing password (for wallet save) 2021-02-27 22:50:14 -03:00
ghubstan
3bbefffb9c
Adjust mainnet bats test to default rate meter interceptors 2021-02-27 22:38:38 -03:00
ghubstan
3feacf4580
Remove unused import 2021-02-27 22:25:49 -03:00
ghubstan
724950926c
No need to wait, default+test call rate > 2x / second 2021-02-27 21:57:53 -03:00
ghubstan
675ce9813e
Make test call rate = default call rate 2021-02-27 21:56:19 -03:00
ghubstan
6b2c386a7c
Fix call rate metering interceptor bug
The gRPC interceptor was not using the correct method/ratemeter
map key, and failing to find a rate meter for the server call.

- Fix the rate meter key lookup bug.

- Disable most strict, default call rate meters in tests.
  Made an adjustment to the test harness' scaffold setup so an interceptor
  testing or disabling config file is always picked up by bob and alice
  daemons.

- Set arbitration daemon's registerDisputeAgent rate @ 10/second, so
  it does not interfere with the test harness.  (There is no pre-existing
  arb node appDataDir before that daemon starts.)

Note:  The test harness cannot install the custom rate metering file in
an arb daemon's appDataDir before it starts because there is no dao-setup
file for that node type.

TODO:  Adjust api simulation scripts to interceptor bug fix.
2021-02-27 21:47:52 -03:00
ghubstan
e8d1f03792
Clean up call rate meter config file in test teardown 2021-02-27 18:10:06 -03:00
ghubstan
98ff6cf9ef
Fix test bug 2021-02-27 18:01:45 -03:00
ghubstan
d60c0dd3ca
Display buyer's cost in api's gettrade output
The offer volume is shown so traders know how much fiat
they are sending or receiving without having to call getoffer.

Changed the 'Fiat Sent' and 'Fiat Received' column headers
to show which fiat is being transfered, e.g., 'EUR Sent',
'EUR Received'.

Adjusted apitest's trade-simulation-utils.sh to the modified
gettrade output.
2021-02-26 15:25:31 -03:00
ghubstan
6c0eac8942
Fix param order 2021-02-26 08:24:16 -03:00
ghubstan
3bc5d05bb6
Refactor apitest cases to use GrpcClient
This is a follow up to PR https://github.com/bisq-network/bisq/pull/5240,
which moved client side gRPC boilerplate to a new, reusable GrpcClient class.

From this change forward, all (including test) client side gRPC request/response
boilerplate should now live in GrpcClient.
2021-02-25 22:05:21 -03:00
ghubstan
b725f06514
Adjust api to new minimum fee per vbyte
The BaseCurrencyNetwork#getDefaultMinFeePerVbyte now returns
15 (sats/byte) since commit b341bb6e89.

This change adjusts the api to the new min tx fee rate by validating
the api's setTxFeeRatePreference param, and throwing an appropirate
exception if the param value is below the minimum.  Also adjusted a broken
test, and added a new test to check the appropriate exception is received
from the server.
2021-02-25 11:31:13 -03:00
ghubstan
4ac9fa5b8d
Add --help option to bot-script.json generator 2021-02-20 16:37:06 -03:00
ghubstan
9e48c32d40
Fix manual shutdown exception handling
Codacy is right.  Don't use instance of ex, add a catch clause.
Also removed an unnecessary fully qualified name 'String.format'.
2021-02-18 13:58:58 -03:00
ghubstan
f0e5e9b5d9
Merge branch 'master' into 02-scripted-bot-test 2021-02-18 13:06:18 -03:00
ghubstan
a7eb265ded
Add CLI testing bot to :apitest
RobotBob reads a json file instructing it to make and take offers
as per an 'actions' json array, e.g. ["make","take","take","make],
and the tester will manually run CLI commands provided by the bot
during each step in a trade.

The test case (ScriptedBotTest) can be run with the test harness,
which will start and shutdown all the regtest/dao app: bitcoind,
seednode, arbnode, bob & alice nodes.  The test case can also be
run without the test harness, and the user manages his own daemons.

Usage will be described in the PR before it leaves draft stage.
2021-02-18 12:52:16 -03:00
sqrrm
cd8c479276
Merge pull request #5159 from ghubstan/api-beta-test-guide
Api v1 Beta Test Guide
2021-02-18 16:47:33 +01:00
ghubstan
0efc9ff188
Add missing punctuation (.) 2021-02-16 09:36:24 -03:00
ghubstan
cdf15676db
Edit guide as per suggested changes
This commit contains changes suggested in review:
https://github.com/bisq-network/bisq/pull/5159#pullrequestreview-588900434
2021-02-11 17:51:33 -03:00
Christoph Atteneder
840b3dcae3
Merge pull request #5155 from ghubstan/01-fix-find-pid-on-osx
Fix find pid on OSX
2021-02-10 10:12:45 +01:00
ghubstan
2f6838e507
Rename apitest BisqApp -> BisqProcess
The old class name conflicted with destop's BisqApp.
2021-02-07 14:00:29 -03:00
ghubstan
711785631d
Fix typo 2021-02-06 16:44:19 -03:00
ghubstan
3107d99fb4
Provide Api v1 Beta Test Guide 2021-02-06 16:09:24 -03:00
ghubstan
bcf1b3b836
Fix find pid on OSX
The trade simulation scripts check that bitcoind, seed node,
arbitration node, and bob & alice nodes are running at startup,
but the bash pgrep command used to find the PIDs does not work on
OSX (my darwin20), so an adjustment was made to the env script to
find java PIDs with ps and awk if running on OSX.

Two additonal startup checks were added: make sure the script is
running on supported OS (Linux or OSX), and bitcoin-cli is in
the PATH.

Also removed usage error text about registering dispute agents.
The scripts do that now.
2021-02-04 19:16:19 -03:00
ghubstan
072364b490
Explain 'payment sent' implies 'funds deposited'
There is no need to simulate the time it takes between
receiving a 'payment sent' msg and having funds (fiat) deposited
in the seller's bank account.  But there is need to explain
that in the script.
2021-02-03 12:11:33 -03:00
ghubstan
99af81d51d
Remove DONE flag
There should not be a check on that flag in the rolling offers script.
Terminate the script with ^C.
2021-01-29 18:13:34 -03:00
ghubstan
e3f707fea6
Make executetrade simulation more realistic
Demonstrate how traders poll trade status as they go through
the protocol.
2021-01-29 18:04:02 -03:00
ghubstan
da5e1e5ade
Add functions for checking trade status 2021-01-29 13:53:23 -03:00
ghubstan
d580e77bf8
Try alternative syntax to make codacy happy
The codacy issue "$/${} is unnecessary on arithmetic variables"
seems to not apply to $(echo $((1 + $RANDOM % 10))), but we
try another syntax to make her happy.
2021-01-29 11:47:37 -03:00
ghubstan
27a4a31dcc
Add apitest rolling offer simulation script
The script demonstrats a way to always keep one offer in the market.
As soon as the offer is taken and the trade is completed, another
offer is placed.
2021-01-28 20:11:09 -03:00
ghubstan
74008e9385
Move createoffer command generation to its own function 2021-01-28 19:56:15 -03:00
ghubstan
5a78d18103
Refactor createpaymentacct and trade protocol functions
Code duplication needs to be reduced as new scripts are added.

- Refactor the createpaymentacct functions.
  The steps required to create a payment account are still
  displayed, but only for Alice, not Bob.

- Treat the trade protocol simulation as an atomic function.
  This will reduce 'main' simulation script size as new
  ones are added.
2021-01-28 19:33:21 -03:00
ghubstan
30a0f99861
Fix bash syntax inconsistencies
Many unnecesary braces around ${VARIABLE} references were removed.
2021-01-25 12:30:59 -03:00
Steven Barclay
8104301b52
Use new Bitcoind(Client|Daemon) & remove btcd-cli4j
Migrate RpcService over to the new block notification daemon and RPC
client based on jsonrpc4j. Drop in own DTO classes in place of the ones
defined by btcd-cli4j and rename requestBtcBlock & addNewBtcBlockHandler
to requestDtoBlock & addNewDtoBlockHandler respectively.

Also remove now redundant filtering from the logback config and update
grade-witness.
2021-01-21 10:10:28 +00:00
ghubstan
184ffd14db
Enclose $vars in double quotes 2021-01-20 15:26:36 -03:00
ghubstan
78d0024368
Re-add exports to make codacy happy 2021-01-20 15:25:22 -03:00
ghubstan
7fa61c9a32
Remove deprecated python script 2021-01-20 15:14:20 -03:00
ghubstan
20e16493aa
Get current mkt price from server, not directly from feed 2021-01-20 15:13:07 -03:00
ghubstan
3244db12c4
Print current market price just before offer is created
This may help confirm offer.price correctness in periods of BTC
price stability.
2021-01-20 13:08:52 -03:00
ghubstan
cb96f27f1c
Remove uneeded ${curlies}
For requested change
https://github.com/bisq-network/bisq/pull/5093#discussion_r560941709
2021-01-20 11:52:29 -03:00
ghubstan
8b4938a9eb
Do not export vars from lowest level child script
For requested change
https://github.com/bisq-network/bisq/pull/5093#discussion_r560932201
2021-01-20 11:36:01 -03:00
ghubstan
0c06abdc56
Replace shortform '. with longform 'source'
For requested change
https://github.com/bisq-network/bisq/pull/5093#discussion_r560958418
2021-01-20 11:28:42 -03:00
ghubstan
6c322d4aae
Put $N variable references in double quotes
For requested change
https://github.com/bisq-network/bisq/pull/5093#discussion_r560938698
2021-01-20 11:20:30 -03:00
ghubstan
73c6b3d96b
Fix typo, group mutually exclusive opts around '||' 2021-01-20 11:16:54 -03:00
ghubstan
4eabb9804e
Fix indentation
For suggested change
https://github.com/bisq-network/bisq/pull/5093#discussion_r560898873
2021-01-20 10:35:53 -03:00
ghubstan
cf419d2d58
Make price request frequency configurable
Added a -w option to  allow user to control the frequency of price requests.
The minimum value = 20s, default value = 120s.
2021-01-19 16:13:21 -03:00
ghubstan
48a326b990
Add env requirement and usage comments 2021-01-19 15:00:47 -03:00
ghubstan
93c3735f9c
Fix bash bugs & style problems for codacy 2021-01-19 14:38:22 -03:00
ghubstan
873c661218
Add api trade simulation scripts
Two regtest trading simulation scripts are contained in this change:

- trade-simulation.sh goes through the steps of creating F2F payment
  accounts for Bob & Alice, and each step of a trade from createoffer to
  completion.

- limit-order-simulation.sh shows one way to trigger creation of an offer
  when a limit price is reached.

Each script prints CLI commands just before they are run.

Both scripts depend on functions contained in supporting bash and python3
scripts.

Examples:

trade-simulation.sh

  Simulate the entire trade protocol between Bob (taker) & Alice (maker),
  where Alice buys 0.1 BTC from Bob, paying in Renminbi (CYN).

  Note the script takes a country code (CN) not a currency code, so the
  script can create the appropriate country based face to face payment accounts.

  $ apitest/scripts/trade-simulation.sh -d buy -c cn -m 0.0 -a 0.1

limit-order.sh

  Create a CAD/BUY 0.1 BTC order at mkt price margin of 0.0% if price falls to
  or below 47900 CAD.

  Note the script takes a country code (CA) not a currency code, so the script
  can create the appropriate country based face to face  payment accounts.

  $ apitest/scripts/limit-order-simulation.sh -l 47900 -d buy -c CA -m 0.0 -a 0.1

  Create a USD/SELL 0.1 BTC order at mkt price margin of 0.0% if price rises to
  or above 37200 USD.

  $ apitest/scripts/limit-order-simulation.sh -l 37200 -d sell -c US -m 0.0 -a 0.1
2021-01-19 13:46:55 -03:00
ghubstan
49a3b46960
Add CoreHelpService gRPC stubs and test case 2021-01-14 10:22:14 -03:00
ghubstan
03a814f491
Adjust trade apitest cases, anticipating offerFilter.canTakeOffer
Refering to PR https://github.com/bisq-network/bisq/pull/5053.

Test cases need to explicitly use a matching fiat payment account
type when calling 'getoffers'.
2021-01-05 12:00:03 -03:00
ghubstan
18de222d38
Add new api methods 'getmyoffers' and 'getmyoffer'
Similar to 'getoffers' and 'getoffer', but filters out offers not
created by the user.  The new methods are so similar some offer list
filtering and sorting was refactored in CoreOffersService.

Also fixed some createoffer apitest cases in anticipation of a new OfferFilter,
which will filter out offers not matching any user payment account.
2021-01-04 21:43:34 -03:00
ghubstan
206364de42
Reduce some trade test wait times
Commit 2070e76 fixed the repeating dao sync bug, so don't need to
wait as long after generating a btc block.
2020-12-29 14:12:55 -03:00
ghubstan
6594d147d3
Refactor wallet test fixtures into util 2020-12-29 13:54:27 -03:00
ghubstan
9250845a66
Explain why balance asserts are checking a range, not one value
And change log.info to log.debug.
2020-12-29 13:14:05 -03:00
ghubstan
2f7f14670c
Replace junit with jupiter asserts
Don't mix junit and jupter apis, apitest should only be using
jupiter.  Also moved a file.deleteOnExit statement within the
method that created the file.
2020-12-28 14:32:16 -03:00
ghubstan
1f99192a31
Make visible to subclasses 2020-12-28 13:12:34 -03:00
ghubstan
3bbf1e02dd
Add convenience method to convert enum[] to comma delimited string 2020-12-28 13:11:12 -03:00
ghubstan
32e9bd285f
Delete unused method 2020-12-28 12:52:29 -03:00
ghubstan
2070e7633b
Pass hash to bitcoind blocknotify script 2020-12-23 16:18:31 -03:00
ghubstan
b8c5a29659
Disable CallRateMeteringInterceptorTest and run it from test suite
This will reduce the entire apitest suite's exec time
2020-12-22 22:03:06 -03:00
ghubstan
01546ad11d
Use a simpler, time windowing call rate meter
Rewrote the GrpcCallRateMeter class and adjusted afected classes.

These changes were requested in PR review
https://github.com/bisq-network/bisq/pull/4966#pullrequestreview-557040093
2020-12-22 16:14:49 -03:00
ghubstan
27efc5f3c2
Merge branch '09-refactor-grpc-error-handling' into 10-callrate-interceptor
Adjust to reverting to reverting 6aa385e, and fix test file conflict.
2020-12-21 15:44:34 -03:00
ghubstan
1507a2c791
Resolve file conflict w/ master 2020-12-21 15:31:07 -03:00
ghubstan
4aa4270ed9
Adjust TradeTest to reverting 6aa385e494 2020-12-21 15:23:23 -03:00
ghubstan
3a770f4bc0
Adjust TakeSellBTCOfferTest to reverting 6aa385e494 2020-12-21 15:22:05 -03:00
ghubstan
abc39402b5
Test CallRateMeteringInterceptor 2020-12-19 17:31:02 -03:00
ghubstan
fabd7c8776
Refactor testcase superclasses to support rate metering configs 2020-12-19 17:08:53 -03:00
ghubstan
d5657e9760
Install call rate metering config file before startup
Copy the config file at --callRateMeteringConfigPath to each daemon's
appDataDir, where it will be detected at server startup.
2020-12-19 17:04:40 -03:00
ghubstan
56a5c7938d
Add ApiTestConfig option --callRateMeteringConfigPath
Points to a call rate metering interceptor configuration file.

Test cases can build a config file, and the test harness will
install it into a daemon's appDataDir before startup.
The installed config file will be used to configure gRPC
service rate metering interceptors.
2020-12-19 16:54:44 -03:00
ghubstan
4be87a6281
Disable method test to avoid repetition 2020-12-14 15:12:39 -03:00
ghubstan
0384642f32
Adjust create TransferwiseAccount test
As per commit 88f26f9324,
do not autofill all currencies by default but keep all unselected.
2020-12-14 15:03:35 -03:00
ghubstan
5522d0c53e
Add new api method gettransaction
This change was prompted by the recent changes in the main branch to
allow a tx memo field to be set from the UI and API.

This and the prior PR address the API's need to be able to fetch a
tx (with a memo).  The API can now get a completed trade's withdrawal
txid and pass it as a gettransaction parameter.

See previous PR "Append nullable withdrawalTxId field to Trade".

	https://github.com/bisq-network/bisq/pull/4937

A summary of changes by file:

grpc.proto

- Added withdrawalTxId field to existing TradeInfo proto & wrapper.
- Reordered fields in TradeInfo proto.
- Added new fields to be displayed by TxInfo proto in CLI.
- Fixed typo: unsetTxFeeRatePreference -> UnsetTxFeeRatePreference.
- Added new GetTransaction rpc.

GrpcWalletsService - Added new getTransaction gRPC boilerplate.

CoreWalletsService - Added new getTransaction implementation.

TxInfo - Added the new fields for displaying a tx summary from CLI.
This is not intended to be more than a brief summary;  a block explorer
or bitcoin-core client should be used to see the complete definition.

TradeInfo - Added the new withdrawalTxId field defined in grpc.proto.

CliMain - Added new 'case gettransaction'.

TransactionFormat - Formats a TxInfo sent from the server to CLI.

ColumnHeaderConstants - Added console headers used by TransactionFormat.

TradeFormat - Displays a completed trade's WithdrawalTxId if present.

Apitest - Adjusted affected tests: assert tx memo is persisted and
test gettransaction.
2020-12-14 15:01:03 -03:00
ghubstan
bd66008062
Support tx memo field for btc withdrawals from api
- Added optional memo parameter to the api's sendbtc and
  withdrawfunds commands.

- Removed the @Nullable annotation was removed because protobuf
  does not support null.

- Visibility in two wallet check methods were changed from private
  to pkg protected so the CoreTradeService could use them.

- Adjusted affected tests.  (Asserting the memo field was set on a
  transaction cannot be checked from apitest yet.)
2020-12-09 16:51:56 -03:00
ghubstan
6c9f0c252d
Add new api method 'sendbtc' and test
Takes an address, amount, and optional txfeerate param,
returns a lightweight TxInfo proto.

Also overloaded two BtcWalletService methods to allow sendbtc
to pass in the tx fee rate -- overriding the fee service and
custom fee rate setting.
2020-12-08 21:12:02 -03:00
ghubstan
159d4cc6f5
Add optional txFeeRate parameter to api sendbsq
If present in the sendbsq command, the parameter will override the fee
service and custom fee rate setting for the BSQ transaction.

Also changed the sendbsq grpc return type to a lightweight TX proto wrapper.

Besides some small refactoring in the CLI, all the changes are
adjustments for this new sendbsq parameter and its new grpc return value.
2020-12-04 17:17:37 -03:00
ghubstan
65df9e1503
Change sendbsq's amount parameter type to String 2020-12-02 14:52:05 -03:00
ghubstan
9b4bdfc5ad
Make salt an editable payment acct json form field
Users need to be able to preserve their acct age when moving a
payment account to a new client.

Also adjusted affected tests, and did some minor refactoring
of the custom gson type adaptor.
2020-12-02 13:52:39 -03:00
ghubstan
987d89319e
Use ListenableFuture and callback when requesting tx fee
This change fixes the blocking problem in the fee rate request api.
Also redefined the TxFeeRateInfo.

- Redefined grpc.proto message TxFeeRateInfo, added
  lastFeeServiceRequestTs field. (CLI user may want to know
  TS of last fee request.)

- Adjusted TxFeeRateInfo proto wrapper.

- Adjusted CurrencyFormat and BtcTxFeeRateTest to new TxFeeRateInfo.

- Added @Getter annotation to FeeService.  (CLI user may want to know
  TS of last fee request).

- Pass resultHandler from GrpcWalletsService through CoreApi, to
  CoreWalletsService's tx fee rate api methods.
2020-12-01 21:10:47 -03:00
ghubstan
faf030fbc5
Add useCustomTxFeeRate field to TxFeeRateInfo proto wrapper
This is set from the core preferences.isUseCustomWithdrawalTxFee(),
and simplifies fee changing logic in the API.
2020-12-01 17:14:08 -03:00
ghubstan
2989f1be3f
Loosen up the PaymentMethod count test assert
, so we don't have to change this test every time a new payment
method is added.
2020-12-01 16:10:00 -03:00
ghubstan
62a2aa8543
Don't be so polite 2020-12-01 15:55:53 -03:00
ghubstan
45cfb95245
Remove many log.isDebugEnabled() checks
These do not buy enough in the way of performance, at the cost of
so many additional lines.  Buy these checks should be done for
debug log statements that have expensive parameters.
2020-12-01 15:48:11 -03:00
ghubstan
06eb3786c0
Test new tx fee rate api methods 2020-11-26 18:36:58 -03:00
ghubstan
8fd578614d
Adjust test for a new payment method 2020-11-26 17:20:29 -03:00
ghubstan
daeb34b3d2
Add two new api method tests
Keeping the bats test simple.  More complex use cases are tested in
apitest, and we don't want to be trading on mainnet with a bats test.

- Add new getunusedbsqaddress test, assert success return status.
- Add new getpaymentmethods test, assert success return status.
2020-11-22 16:25:21 -03:00
ghubstan
424f9480ad
Fix broken tests
- Change the getbalance tests to just check a sucessful '0' status code.

  The api's getbalance method returns full balance info now, not just a
  formatted long.  We still assert the cmd did not fail, but don't check
  the value string.

- Remove obsolete createpaymentacct tests.

  This is well tested in apitest, and testing this cmd is unnecesarily
  complex to do in a bats script.
2020-11-22 16:12:34 -03:00
ghubstan
76097fc9dc
Enable CreateMoneyGramAccount test 2020-11-21 15:24:33 -03:00
ghubstan
bb6762a23e
Reverse argument order for assert(expected, actual) convention 2020-11-20 16:53:59 -03:00
ghubstan
459b2a9c49
Add create payment account (api) tests 2020-11-20 16:46:36 -03:00
ghubstan
138822edad
Avoid 'unnecessary use of fully qualified name' codacy issue 2020-11-18 20:05:15 -03:00
ghubstan
08228d07bc
Replace existing api method 'createpaymentacct' impl
In the CLI, this method now takes a single argument, the path to a json
file (a payment account form).  The json text is read from the file
and sent to the server, where it is serialized to a new PaymentAccount
instance, saved, and sent back to the CLI as a protobuf.PaymentAccount.

- Modified existing gRPC boilerplate in grpc.proto and GrpcPaymentAccountsService.

- Modified existing method signatures in CoreApi and CorePaymentAccountsService.

- Replaced existing method impl in CorePaymentAccountsService and
  removed dead code.

- Replaced the CLI's existing 'createpaymentacct' method impl.

- Modified existing tests.
2020-11-18 19:23:21 -03:00
ghubstan
35c1c4e944
Ensure EXPECTED_FORM.clear() is never skipped 2020-11-18 16:42:17 -03:00
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