<p><b>@blabno</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2251#discussion_r247435944">core/src/main/java/bisq/core/btc/TxFeeEstimationService.java</a>:</p>
<pre style='color:#555'>> +        // We start with min taker fee size of 260
+        int estimatedTxSize = 260;
+        try {
+            estimatedTxSize = getEstimatedTxSize(List.of(tradeFee, amount), estimatedTxSize, txFeePerByte, btcWalletService);
+        } catch (InsufficientMoneyException e) {
+            if (isTaker) {
+                // if we cannot do the estimation we use the payout tx size
+                estimatedTxSize = 380;
+            }
+            log.info("We cannot do the fee estimation because there are not enough funds in the wallet. This is expected " +
+                    "if the user pays from an external wallet. In that case we use an estimated tx size of {} bytes.", estimatedTxSize);
+        }
+
+        if (!preferences.isPayFeeInBtc()) {
+            // If we pay the fee in BSQ we have one input more which adds about 150 bytes
+            estimatedTxSize += 150;
</pre>
<p>Can we avoid magic numbers? <a href="https://en.wikipedia.org/wiki/Magic_number_(programming)" rel="nofollow">https://en.wikipedia.org/wiki/Magic_number_(programming)</a></p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2251#discussion_r247440460">core/src/test/java/bisq/core/btc/TxFeeEstimationServiceTest.java</a>:</p>
<pre style='color:#555'>> +import java.util.List;
+
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
</pre>
<p>There is no need for PowerMock in this test class.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2251#discussion_r247441332">core/src/test/java/bisq/core/btc/TxFeeEstimationServiceTest.java</a>:</p>
<pre style='color:#555'>> +        BtcWalletService btcWalletService = mock(BtcWalletService.class);
+        int result;
+        int realTxSize;
+        Coin txFee;
+
+        initialEstimatedTxSize = 260;
+        txFeePerByte = Coin.valueOf(10);
+        realTxSize = 260;
+
+        txFee = txFeePerByte.multiply(initialEstimatedTxSize);
+        when(btcWalletService.getEstimatedFeeTxSize(outputValues, txFee)).thenReturn(realTxSize);
+        result = TxFeeEstimationService.getEstimatedTxSize(outputValues, initialEstimatedTxSize, txFeePerByte, btcWalletService);
+        assertEquals(260, result);
+
+
+        // TODO check how to use the mocking framework for repeated calls
</pre>
<p>This is separate test scenario and should be placed in separate method.<br>
Good naming convention for test methods is <code>testMethodName_scenario_expectedCondition</code><br>
i.e. <code>getEstimatedTxSize_nullOutputs_throwsException</code></p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/2251#discussion_r247442276">core/src/main/java/bisq/core/btc/TxFeeEstimationService.java</a>:</p>
<pre style='color:#555'>> +            size = Math.max(380, averageSize);
+            txFee = txFeePerByte.multiply(size);
+            log.info("Fee estimation resulted in a tx size of {} bytes.\n" +
+                    "We use an average between the taker fee tx and the deposit tx (320 bytes) which results in {} bytes.\n" +
+                    "The payout tx has 380 bytes, we use that as our min value. Size for fee calculation is {} bytes.\n" +
+                    "The tx fee of {} Sat", estimatedTxSize, averageSize, size, txFee.value);
+        } else {
+            size = estimatedTxSize;
+            txFee = txFeePerByte.multiply(size);
+            log.info("Fee estimation resulted in a tx size of {} bytes and a tx fee of {} Sat.", size, txFee.value);
+        }
+
+        return new Tuple2<>(txFee, size);
+    }
+
+    @VisibleForTesting
</pre>
<p>I've been always told that this is a bad idea, as it's an attempt to test implementation details.<br>
Either extract it to an utility class that could be tested separately or do not test it individually.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/2251#pullrequestreview-192080424">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AkpZtpyJRT8ZtgNL34POQBW0Jwl5p1EKks5vDFz5gaJpZM4Z8Rm0">mute the thread</a>.<img src="https://github.com/notifications/beacon/AkpZtqvscahv6x_MSsLcieOnPd2HFY7Tks5vDFz5gaJpZM4Z8Rm0.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bisq-network/bisq","title":"bisq-network/bisq","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/bisq-network/bisq"}},"updates":{"snippets":[{"icon":"PERSON","message":"@blabno commented on #2251"}],"action":{"name":"View Pull Request","url":"https://github.com/bisq-network/bisq/pull/2251#pullrequestreview-192080424"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/2251#pullrequestreview-192080424",
"url": "https://github.com/bisq-network/bisq/pull/2251#pullrequestreview-192080424",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>