Skip to content

Commit

Permalink
add test code for pruning enable
Browse files Browse the repository at this point in the history
Signed-off-by: philosup <philosup@gmail.com>
  • Loading branch information
ilsup-yun authored and philosup committed Jan 20, 2025
1 parent bbf2065 commit 86764b9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2705,4 +2705,43 @@ void helpOutputShouldDisplayCorrectDefaultValues() {

assertThat(errorOutputString).isEmpty();
}

@Test
void chainPruningEnabledWithQBFTShouldFailWhenChainPruningBlocksRetainedValueLessThanEpochLength()
throws IOException {

JsonObject genesis = GENESIS_VALID_JSON;
genesis.getJsonObject("config").put("qbft", new JsonObject().put("epochlength", 30000));

final Path genesisFile = createFakeGenesisFile(genesis);

parseCommand(
"--genesis-file",
genesisFile.toString(),
"--Xchain-pruning-enabled=true",
"--Xchain-pruning-blocks-retained=7200",
"--version-compatibility-protection=false");

assertThat(commandErrorOutput.toString(UTF_8))
.contains(
"--Xchain-pruning-blocks-retained must be >= epochlength(30000) for QBFT networks");
}

@Test
void chainPruningEnabledWithQBFT() throws IOException {

JsonObject genesis = GENESIS_VALID_JSON;
genesis.getJsonObject("config").put("qbft", new JsonObject().put("epochlength", 30000));

final Path genesisFile = createFakeGenesisFile(genesis);

parseCommand(
"--genesis-file",
genesisFile.toString(),
"--Xchain-pruning-enabled=true",
"--Xchain-pruning-blocks-retained=30000",
"--version-compatibility-protection=false");

assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
}

0 comments on commit 86764b9

Please sign in to comment.