Skip to content

Commit 86764b9

Browse files
ilsup-yunphilosup
authored andcommitted
add test code for pruning enable
Signed-off-by: philosup <[email protected]>
1 parent bbf2065 commit 86764b9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java

+39
Original file line numberDiff line numberDiff line change
@@ -2705,4 +2705,43 @@ void helpOutputShouldDisplayCorrectDefaultValues() {
27052705

27062706
assertThat(errorOutputString).isEmpty();
27072707
}
2708+
2709+
@Test
2710+
void chainPruningEnabledWithQBFTShouldFailWhenChainPruningBlocksRetainedValueLessThanEpochLength()
2711+
throws IOException {
2712+
2713+
JsonObject genesis = GENESIS_VALID_JSON;
2714+
genesis.getJsonObject("config").put("qbft", new JsonObject().put("epochlength", 30000));
2715+
2716+
final Path genesisFile = createFakeGenesisFile(genesis);
2717+
2718+
parseCommand(
2719+
"--genesis-file",
2720+
genesisFile.toString(),
2721+
"--Xchain-pruning-enabled=true",
2722+
"--Xchain-pruning-blocks-retained=7200",
2723+
"--version-compatibility-protection=false");
2724+
2725+
assertThat(commandErrorOutput.toString(UTF_8))
2726+
.contains(
2727+
"--Xchain-pruning-blocks-retained must be >= epochlength(30000) for QBFT networks");
2728+
}
2729+
2730+
@Test
2731+
void chainPruningEnabledWithQBFT() throws IOException {
2732+
2733+
JsonObject genesis = GENESIS_VALID_JSON;
2734+
genesis.getJsonObject("config").put("qbft", new JsonObject().put("epochlength", 30000));
2735+
2736+
final Path genesisFile = createFakeGenesisFile(genesis);
2737+
2738+
parseCommand(
2739+
"--genesis-file",
2740+
genesisFile.toString(),
2741+
"--Xchain-pruning-enabled=true",
2742+
"--Xchain-pruning-blocks-retained=30000",
2743+
"--version-compatibility-protection=false");
2744+
2745+
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
2746+
}
27082747
}

0 commit comments

Comments
 (0)