Change test to tease NPEs during DefaultBlockchain.<init>() caused by initilization order#7607
Conversation
ddd5b0e to
4d53a01
Compare
4d53a01 to
3e6da91
Compare
garyschulte
left a comment
There was a problem hiding this comment.
Non-blocking style comment. Otherwise LGTM
| gasUsedCounter = | ||
| metricsSystem.createCounter( | ||
| BesuMetricCategory.BLOCKCHAIN, "chain_head_gas_used_counter", "Counter for Gas used"); | ||
|
|
||
| numberOfTransactionsCounter = | ||
| metricsSystem.createCounter( | ||
| BesuMetricCategory.BLOCKCHAIN, | ||
| "chain_head_transaction_count_counter", | ||
| "Counter for the number of transactions"); |
There was a problem hiding this comment.
Seem to me it would be tidier to have these in the createGauges() (perhaps rename createMetrics()) method or similar, and declutter the constructor.
There was a problem hiding this comment.
Or have another method, createCounters if we want to separate Counters from Gauges ;)
There was a problem hiding this comment.
sure, I think I didn't put those in a method because I would have to drop the final qualifier from the fields.
But I'll go with @ahamlat's suggestion and create another method for counters
ahamlat
left a comment
There was a problem hiding this comment.
A small comment related to using the ArrayDeque instead of ArrayList, but it is not blocking.
ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/DefaultBlockchainTest.java
Show resolved
Hide resolved
| gasUsedCounter = | ||
| metricsSystem.createCounter( | ||
| BesuMetricCategory.BLOCKCHAIN, "chain_head_gas_used_counter", "Counter for Gas used"); | ||
|
|
||
| numberOfTransactionsCounter = | ||
| metricsSystem.createCounter( | ||
| BesuMetricCategory.BLOCKCHAIN, | ||
| "chain_head_transaction_count_counter", | ||
| "Counter for the number of transactions"); |
There was a problem hiding this comment.
Or have another method, createCounters if we want to separate Counters from Gauges ;)
… initilization order Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
…used by initilization order move counters into their own method Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
12c254d to
ab90a1b
Compare
PR description
This complements PR #7601 to make sure possible NPEs are checked during unit tests around
DefaultBlockchainwhen the right order of initialization is not followed.Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests