Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2265] Expose fast-sync options on command line #1218

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public interface DefaultCommandValues {
// Default should be FAST for the next release
// but we use FULL for the moment as Fast is still in progress
SyncMode DEFAULT_SYNC_MODE = SyncMode.FULL;
int DEFAULT_FAST_SYNC_MAX_WAIT_TIME = 0;
int DEFAULT_FAST_SYNC_MIN_PEER_COUNT = 5;
int FAST_SYNC_MAX_WAIT_TIME = 0;
int FAST_SYNC_MIN_PEER_COUNT = 5;
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
int DEFAULT_MAX_PEERS = 25;

static Path getDefaultPantheonDataPath(final Object command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ void setBootnodes(final List<String> values) {
names = {"--fast-sync-min-peers"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Minimum number of peers before starting fast sync, possible values are ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE})")
private final Integer fastSyncMinPeerCount = DEFAULT_FAST_SYNC_MIN_PEER_COUNT;
"Minimum number of peers before starting fast sync. (default: ${DEFAULT-VALUE})")
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
private final Integer fastSyncMinPeerCount = FAST_SYNC_MIN_PEER_COUNT;

@Option(
hidden = true,
names = {"--fast-sync-max-wait-time"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Maximum time to wait the required number of peers before starting fast sync, expressed in seconds, 0 means no timeout, possible values are ${COMPLETION-CANDIDATES} (default: ${DEFAULT-VALUE})")
private final Integer fastSyncMaxWaitTime = DEFAULT_FAST_SYNC_MAX_WAIT_TIME;
"Maximum time to wait the required number of peers before starting fast sync, expressed in seconds, 0 means no timeout(default: ${DEFAULT-VALUE})")
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
private final Integer fastSyncMaxWaitTime = FAST_SYNC_MAX_WAIT_TIME;

@Option(
names = {"--network"},
Expand Down Expand Up @@ -687,7 +687,7 @@ private void checkFastSyncOptions() throws ParameterException {
logger,
commandLine,
"--sync-mode",
syncMode.equals(SyncMode.FAST),
SyncMode.FAST.equals(syncMode),
asList("--fast-sync-num-peers", "--fast-sync-timeout"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -1047,6 +1048,27 @@ public void syncModeOptionMustBeUsed() {
assertThat(commandErrorOutput.toString()).isEmpty();
}


@Test
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
public void fastSyncTimeoutOptionMustBeUsed() {
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved

parseCommand("--sync-mode", "FAST", "--fast-sync-max-wait-time", "30");
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FAST));
verify(mockSyncConfBuilder).fastSyncMaximumPeerWaitTime(ArgumentMatchers.eq(Duration.ofSeconds(30)));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void fastSyncMinPeersOptionMustBeUsed() {

parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "5");
AbdelStark marked this conversation as resolved.
Show resolved Hide resolved
verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FAST));
verify(mockSyncConfBuilder).fastSyncMinimumPeerCount(ArgumentMatchers.eq(5));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}

@Test
public void rpcHttpEnabledPropertyDefaultIsFalse() {
parseCommand();
Expand Down