-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add genesis configuration isPoa() convenience function, and use it in validation of --miner-enabled
option
#5669
Changes from all commits
6af875f
12e38d2
4b88158
7d9b89a
f2533a8
8c7a8ef
5add7ee
53e6552
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,20 @@ public class BesuCommandTest extends CommandTestAbstract { | |
(new JsonObject()).put("config", new JsonObject().put("ecCurve", "secp256k1")); | ||
private static final String ENCLAVE_PUBLIC_KEY_PATH = | ||
BesuCommand.class.getResource("/orion_publickey.pub").getPath(); | ||
private static final JsonObject VALID_GENESIS_QBFT_POST_LONDON = | ||
(new JsonObject()) | ||
.put( | ||
"config", | ||
new JsonObject() | ||
.put("londonBlock", 0) | ||
.put("qbft", new JsonObject().put("blockperiodseconds", 5))); | ||
private static final JsonObject VALID_GENESIS_IBFT2_POST_LONDON = | ||
(new JsonObject()) | ||
.put( | ||
"config", | ||
new JsonObject() | ||
.put("londonBlock", 0) | ||
.put("ibft2", new JsonObject().put("blockperiodseconds", 5))); | ||
|
||
private static final String[] VALID_ENODE_STRINGS = { | ||
"enode://" + VALID_NODE_ID + "@192.168.0.1:4567", | ||
|
@@ -3684,7 +3698,7 @@ public void stratumMiningIsEnabledWhenSpecified() throws Exception { | |
@Test | ||
public void stratumMiningOptionsRequiresServiceToBeEnabled() { | ||
|
||
parseCommand("--miner-stratum-enabled"); | ||
parseCommand("--network", "dev", "--miner-stratum-enabled"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I needed to modify the test in a way that would ensure it was being run with a) |
||
|
||
verifyOptionsConstraintLoggerCall("--miner-enabled", "--miner-stratum-enabled"); | ||
|
||
|
@@ -3698,7 +3712,7 @@ public void stratumMiningOptionsRequiresServiceToBeEnabled() { | |
public void stratumMiningOptionsRequiresServiceToBeEnabledToml() throws IOException { | ||
final Path toml = createTempFile("toml", "miner-stratum-enabled=true\n"); | ||
|
||
parseCommand("--config-file", toml.toString()); | ||
parseCommand("--network", "dev", "--config-file", toml.toString()); | ||
|
||
verifyOptionsConstraintLoggerCall("--miner-enabled", "--miner-stratum-enabled"); | ||
|
||
|
@@ -3753,6 +3767,46 @@ public void blockProducingOptionsWarnsMinerShouldBeEnabledToml() throws IOExcept | |
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void blockProducingOptionsDoNotWarnWhenPoA() throws IOException { | ||
|
||
final Path genesisFileQBFT = createFakeGenesisFile(VALID_GENESIS_QBFT_POST_LONDON); | ||
parseCommand( | ||
"--genesis-file", | ||
genesisFileQBFT.toString(), | ||
"--min-gas-price", | ||
"42", | ||
"--miner-extra-data", | ||
"0x1122334455667788990011223344556677889900112233445566778899001122"); | ||
|
||
verify(mockLogger, atMost(0)) | ||
.warn( | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture()); | ||
|
||
assertThat(commandOutput.toString(UTF_8)).isEmpty(); | ||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
|
||
final Path genesisFileIBFT2 = createFakeGenesisFile(VALID_GENESIS_IBFT2_POST_LONDON); | ||
parseCommand( | ||
"--genesis-file", | ||
genesisFileIBFT2.toString(), | ||
"--min-gas-price", | ||
"42", | ||
"--miner-extra-data", | ||
"0x1122334455667788990011223344556677889900112233445566778899001122"); | ||
|
||
verify(mockLogger, atMost(0)) | ||
.warn( | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture()); | ||
|
||
assertThat(commandOutput.toString(UTF_8)).isEmpty(); | ||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void blockProducingOptionsDoNotWarnWhenMergeEnabled() { | ||
|
||
|
@@ -3801,6 +3855,33 @@ public void minGasPriceRequiresMainOptionToml() throws IOException { | |
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void minGasPriceDoesNotRequireMainOptionWhenPoA() throws IOException { | ||
final Path genesisFileQBFT = createFakeGenesisFile(VALID_GENESIS_QBFT_POST_LONDON); | ||
parseCommand("--genesis-file", genesisFileQBFT.toString(), "--min-gas-price", "0"); | ||
|
||
verify(mockLogger, atMost(0)) | ||
.warn( | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture()); | ||
|
||
assertThat(commandOutput.toString(UTF_8)).isEmpty(); | ||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
|
||
final Path genesisFileIBFT2 = createFakeGenesisFile(VALID_GENESIS_IBFT2_POST_LONDON); | ||
parseCommand("--genesis-file", genesisFileIBFT2.toString(), "--min-gas-price", "0"); | ||
|
||
verify(mockLogger, atMost(0)) | ||
.warn( | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture(), | ||
stringArgumentCaptor.capture()); | ||
|
||
assertThat(commandOutput.toString(UTF_8)).isEmpty(); | ||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); | ||
} | ||
|
||
@Test | ||
public void miningParametersAreCaptured() { | ||
final Address requestedCoinbase = Address.fromHexString("0000011111222223333344444"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Didn't know about this one.