Fix BTC.getMedianBlockTime() and update tests

This commit is contained in:
catbref 2020-05-27 09:29:11 +01:00
parent 3d4fc38fcb
commit 274002c473
2 changed files with 1 additions and 35 deletions

View File

@ -95,7 +95,7 @@ public class BTC {
return null;
// Grab latest 11 blocks
List<byte[]> blockHeaders = this.electrumX.getBlockHeaders(height, 11);
List<byte[]> blockHeaders = this.electrumX.getBlockHeaders(height - 11, 11);
if (blockHeaders == null || blockHeaders.size() < 11)
return null;

View File

@ -4,10 +4,6 @@ import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.bitcoinj.store.BlockStoreException;
import org.junit.After;
@ -30,36 +26,6 @@ public class BtcTests extends Common {
BTC.resetForTesting();
}
@Test
public void testStartupShutdownTestNet3() {
BTC btc = BTC.getInstance();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Integer> future = executor.submit(() -> btc.getMedianBlockTime());
try {
Integer medianBlockTime = future.get();
assertNull("Shutdown should occur before we get a result", medianBlockTime);
} catch (InterruptedException | ExecutionException e) {
}
}
@Test
public void testStartupShutdownRegTest() throws DataException {
Common.useSettings("test-settings-v2-bitcoin-regtest.json");
BTC btc = BTC.getInstance();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Integer> future = executor.submit(() -> btc.getMedianBlockTime());
try {
Integer medianBlockTime = future.get();
assertNull("Shutdown should occur before we get a result", medianBlockTime);
} catch (InterruptedException | ExecutionException e) {
}
}
@Test
public void testGetMedianBlockTime() throws BlockStoreException {
System.out.println(String.format("Starting BTC instance..."));