Skip to content

Commit

Permalink
Break up test method
Browse files Browse the repository at this point in the history
Set ignore to failing tests

@bernard could you have a look and try to get those working?
Reason for problem is that repeated calls to getEstimatedFeeTxSize
do not work (returns 0 at second call in loop which cause test to fail)
  • Loading branch information
ManfredKarrer committed Jan 14, 2019
1 parent 461dd1d commit 877d0ae
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions core/src/test/java/bisq/core/btc/TxFeeEstimationServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -40,7 +41,7 @@
public class TxFeeEstimationServiceTest {

@Test
public void testGetEstimatedTxSize() throws InsufficientMoneyException {
public void testGetEstimatedTxSize_withDefaultTxSize() throws InsufficientMoneyException {
List<Coin> outputValues = List.of(Coin.valueOf(2000), Coin.valueOf(3000));
int initialEstimatedTxSize;
Coin txFeePerByte;
Expand All @@ -57,18 +58,43 @@ public void testGetEstimatedTxSize() throws InsufficientMoneyException {
when(btcWalletService.getEstimatedFeeTxSize(outputValues, txFee)).thenReturn(realTxSize);
result = TxFeeEstimationService.getEstimatedTxSize(outputValues, initialEstimatedTxSize, txFeePerByte, btcWalletService);
assertEquals(260, result);
}

// FIXME @Bernard could you have a look?
@Test
@Ignore
public void testGetEstimatedTxSize_withLargeTx() throws InsufficientMoneyException {
List<Coin> outputValues = List.of(Coin.valueOf(2000), Coin.valueOf(3000));
int initialEstimatedTxSize;
Coin txFeePerByte;
BtcWalletService btcWalletService = mock(BtcWalletService.class);
int result;
int realTxSize;
Coin txFee;

// TODO check how to use the mocking framework for repeated calls
// The btcWalletService.getEstimatedFeeTxSize returns 0 at repeated calls in the while loop....
/* initialEstimatedTxSize = 260;
initialEstimatedTxSize = 260;
txFeePerByte = Coin.valueOf(10);
realTxSize = 2600;

txFee = txFeePerByte.multiply(initialEstimatedTxSize);
when(btcWalletService.getEstimatedFeeTxSize(outputValues, txFee)).thenReturn(realTxSize);

// repeated calls to getEstimatedFeeTxSize do not work (returns 0 at second call in loop which cause test to fail)
result = TxFeeEstimationService.getEstimatedTxSize(outputValues, initialEstimatedTxSize, txFeePerByte, btcWalletService);
assertEquals(2600, result);
}

// FIXME @Bernard could you have a look?
@Test
@Ignore
public void testGetEstimatedTxSize_withSmallTx() throws InsufficientMoneyException {
List<Coin> outputValues = List.of(Coin.valueOf(2000), Coin.valueOf(3000));
int initialEstimatedTxSize;
Coin txFeePerByte;
BtcWalletService btcWalletService = mock(BtcWalletService.class);
int result;
int realTxSize;
Coin txFee;

initialEstimatedTxSize = 2600;
txFeePerByte = Coin.valueOf(10);
Expand All @@ -77,7 +103,7 @@ public void testGetEstimatedTxSize() throws InsufficientMoneyException {
txFee = txFeePerByte.multiply(initialEstimatedTxSize);
when(btcWalletService.getEstimatedFeeTxSize(outputValues, txFee)).thenReturn(realTxSize);
result = TxFeeEstimationService.getEstimatedTxSize(outputValues, initialEstimatedTxSize, txFeePerByte, btcWalletService);
assertEquals(260, result);*/
assertEquals(260, result);
}

@Test
Expand Down

0 comments on commit 877d0ae

Please sign in to comment.