Commit Graph

203 Commits

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