Skip to content
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

Validate that blockperiodseconds is set to a positive integer #3186

Merged
merged 36 commits into from
Jan 5, 2022
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a1599f1
Created function to validate blockperiodseconds as positive int
georgep9 Dec 16, 2021
d1a642e
unit tests for nonpositive or demical BlockPeriodSeconds
georgep9 Dec 17, 2021
07d6bb7
updated getBlockPeriodSeconds() to throw on nonpositive or demical va…
georgep9 Dec 17, 2021
e0f08fc
updated getBlockPeriodSeconds() to handle nonexistent blockperiodseco…
georgep9 Dec 17, 2021
fabc34b
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 17, 2021
aaa0e77
spotlessApply
georgep9 Dec 17, 2021
5b3e5fc
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 18, 2021
05644aa
removed validate function from operator subcommand
georgep9 Dec 20, 2021
7f057b7
refactored getBlockPeriodSeconds to use preexisting util function
georgep9 Dec 20, 2021
65cfb5b
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 20, 2021
69ed209
spotlessApply
georgep9 Dec 20, 2021
8516f1b
minor changes to error message
georgep9 Dec 20, 2021
4fa187d
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 21, 2021
b8d4002
re-added NonPositive blockperiod test
georgep9 Dec 21, 2021
129f006
added same validation + unit test for CliqueConfigOptions
georgep9 Dec 21, 2021
176392c
reverted GenerateBlockchainConfig changes
georgep9 Dec 21, 2021
324237a
removed duplicate line from GenerateBlockchainConfig
georgep9 Dec 21, 2021
f18393b
refactored validation logic into a generic getPostiveNumber function …
georgep9 Dec 21, 2021
101b3c6
renamed to getPositiveInt
georgep9 Dec 21, 2021
3ff9259
unit tests for getPostiveInt
georgep9 Dec 21, 2021
aeaee24
apply validation in IbftLegacyConfigOptions
georgep9 Dec 21, 2021
bcaff86
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 21, 2021
65e3e43
reformatted getPositiveInt error message
georgep9 Dec 21, 2021
94812b7
added unit tests for PositiveNumber
georgep9 Dec 21, 2021
ae62318
removed redundant tests from ConfigOptions classes
georgep9 Dec 21, 2021
75296f0
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Dec 21, 2021
b1dba93
prepended copyright header to PositiveNumberTest
georgep9 Dec 22, 2021
20bb802
minor changes as per review
georgep9 Dec 22, 2021
f4481f2
apply changes for BftFork
georgep9 Dec 22, 2021
b71dffe
minor change
georgep9 Dec 22, 2021
2db9939
minor fix
georgep9 Dec 22, 2021
57b33ba
reverted copyright header changes
georgep9 Dec 22, 2021
8a307bb
Refactored getPositiveInt to handle optional default value + unit tes…
georgep9 Dec 22, 2021
b3f207c
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Jan 3, 2022
cd3cd85
Merge branch 'main' of github.com:hyperledger/besu into validate_bloc…
georgep9 Jan 5, 2022
d0ca8fc
Updated changelog
georgep9 Jan 5, 2022
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
Prev Previous commit
Next Next commit
updated getBlockPeriodSeconds() to throw on nonpositive or demical va…
…lues

Signed-off-by: George Patterson <g-patt@outlook.com>
  • Loading branch information
georgep9 committed Dec 17, 2021
commit 07d6bb7c1c99d5d24a5e44e171fb5902dbcb75d9
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ public long getEpochLength() {

@Override
public int getBlockPeriodSeconds() {
return JsonUtil.getInt(bftConfigRoot, "blockperiodseconds", DEFAULT_BLOCK_PERIOD_SECONDS);
final String blockPeriodSecondsRaw =
bftConfigRoot.get("blockperiodseconds").asText(String.valueOf(DEFAULT_BLOCK_PERIOD_SECONDS));
try {
final int blockPeriodSeconds = Integer.parseInt(blockPeriodSecondsRaw);
if (blockPeriodSeconds < 1) throw new NumberFormatException(String.valueOf(blockPeriodSeconds));
return blockPeriodSeconds;
} catch (NumberFormatException e) {
throw new NumberFormatException(
new StringBuilder()
.append("Invalid genesis config property value, blockperiodseconds, should be a positive integer: ")
.append(blockPeriodSecondsRaw)
.toString());
}
}

@Override
Expand Down