mirror of
https://github.com/Qortal/qortal.git
synced 2025-05-08 18:57:52 +00:00
Fix BTC.getMedianBlockTime() and update tests
This commit is contained in:
parent
3d4fc38fcb
commit
274002c473
@ -95,7 +95,7 @@ public class BTC {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Grab latest 11 blocks
|
// 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)
|
if (blockHeaders == null || blockHeaders.size() < 11)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -4,10 +4,6 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.bitcoinj.store.BlockStoreException;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -30,36 +26,6 @@ public class BtcTests extends Common {
|
|||||||
BTC.resetForTesting();
|
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
|
@Test
|
||||||
public void testGetMedianBlockTime() throws BlockStoreException {
|
public void testGetMedianBlockTime() throws BlockStoreException {
|
||||||
System.out.println(String.format("Starting BTC instance..."));
|
System.out.println(String.format("Starting BTC instance..."));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user