[bisq-network/bisq] Add API test harness for Linux (#4366)
dmos62
notifications at github.com
Fri Jul 17 17:03:12 UTC 2020
@dmos62 commented on this pull request.
> + // Have to generate 1 regtest block for alice's wallet to show 10 BTC balance.
+ bitcoinCli.generateBlocks(1);
+
+ // Give the alicedaemon time to parse the new block.
+ MILLISECONDS.sleep(1500);
+ } catch (InterruptedException ex) {
+ fail(ex.getMessage());
+ }
+ }
+
+ @Test
+ @Order(1)
+ public void testGetBalance() {
+ var balance = grpcStubs.walletsService.getBalance(GetBalanceRequest.newBuilder().build()).getBalance();
+ assertEquals(1000000000, balance);
+ }
The wallet being funded with 10 BTC is an implicit step in the setup, which feels wrong. Preferably it would be explicit. I couldn't track down where it happens. Comment?
> + @Order(1)
+ public void testFundWallet() {
+ long balance = getBalance(); // bisq wallet was initialized with 10 btc
+ assertEquals(1000000000, balance);
+
+ String unusedAddress = getUnusedBtcAddress();
+
+ // Given the default tx fee rate, we want to send 2.5 + the fee,
+ // so the new wallet balance will be exactly 12.5 btc.
+ // We should calculate the fee based on the fee rate and tx size
+ // instead of hard coding the fee amount.
+ double btc = parseDouble("2.5") + parseDouble("0.0000336");
+ bitcoinCli.sendToAddress(unusedAddress, btc);
+
+ bitcoinCli.generateBlocks(1);
+ sleep(1500);
Oh right, we're waiting for `:daemon`, not `bitcoind`. `:daemon` will probably have a gRPC endpoint for getting notifications about funding events.
> + }
+ }
+
+ @Test
+ @Order(1)
+ public void testFundWallet() {
+ long balance = getBalance(); // bisq wallet was initialized with 10 btc
+ assertEquals(1000000000, balance);
+
+ String unusedAddress = getUnusedBtcAddress();
+
+ // Given the default tx fee rate, we want to send 2.5 + the fee,
+ // so the new wallet balance will be exactly 12.5 btc.
+ // We should calculate the fee based on the fee rate and tx size
+ // instead of hard coding the fee amount.
+ double btc = parseDouble("2.5") + parseDouble("0.0000336");
We could use the `subtractfeefromamount` parameter set to false to not have to calculate a fee.
> +# This file is overwritten by ApiTestConfig.java at startup, to set the correct blocknotify script path.
+regtest=1
+
+[regtest]
+peerbloomfilters=1
+rpcport=18443
+
+server=1
+txindex=1
+
+# TODO migrate to rpcauth
+rpcuser=apitest
+rpcpassword=apitest
+
+# The blocknotify path will be defined and at runtime.
+# blocknotify=bash ~/.bitcoin/blocknotify %
It might be worth it to not use a bitcoin.conf at all and pass all parameters inline, like this: https://gist.github.com/dmos62/20981dae799e2fc31b62dd443c44c7ae#file-tests-bats-L139
Since your setup already works, this is low priority.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4366#pullrequestreview-450708492
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200717/efb5a30a/attachment.html>
More information about the bisq-github
mailing list