Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public ObjectNode getConfig() {

@Override
public Stream<GenesisAccount> streamAllocations() {
return Streams.stream(allocations.fields())
return allocations
.propertyStream()
.map(
entry -> {
final var on = normalizeKeys((ObjectNode) entry.getValue());
Expand Down Expand Up @@ -233,7 +234,8 @@ static Map<UInt256, UInt256> getStorageMap(final ObjectNode json, final String k
return JsonUtil.getObjectNode(json, key)
.map(
storageMap ->
Streams.stream(storageMap.fields())
storageMap
.propertyStream()
.collect(
Collectors.toMap(
e -> UInt256.fromHexString(e.getKey()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public static ObjectNode normalizeKeys(
final ObjectNode objectNode, final Predicate<Map.Entry<String, JsonNode>> fieldPredicate) {
final ObjectNode normalized = JsonUtil.createEmptyObjectNode();
objectNode
.fields()
.forEachRemaining(
.propertyStream()
.forEach(
entry -> {
if (!fieldPredicate.test(entry)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,24 @@ public void testDifficultyCalculation(final String testFile, final ProtocolSched
DifficultyCalculatorTests.class.getResource(testFile), StandardCharsets.UTF_8));

if (testObject.size() == 1) {
final var topObjectIterator = testObject.fields();
while (topObjectIterator.hasNext()) {
final Map.Entry<String, JsonNode> testNameIterator = topObjectIterator.next();
final var testHolderIter = testNameIterator.getValue().fields();
while (testHolderIter.hasNext()) {
final var testList = testHolderIter.next();
if (!testList.getKey().equals("_info")) {
testDifficulty(testFile, protocolSchedule, blockHeaderFunctions, (ObjectNode) testList.getValue());
}
}
}
testObject.propertyStream()
.forEach(testNameIterator -> {
((ObjectNode) testNameIterator.getValue()).propertyStream()
.forEach(testList -> {
if (!testList.getKey().equals("_info")) {
testDifficulty(testFile, protocolSchedule, blockHeaderFunctions, (ObjectNode) testList.getValue());
}
});
});
} else {
testDifficulty(testFile, protocolSchedule, blockHeaderFunctions, testObject);
}
}

private void testDifficulty(
final String testFile, final ProtocolSchedule protocolSchedule, final MainnetBlockHeaderFunctions blockHeaderFunctions, final ObjectNode testObject) {
final var fields = testObject.fields();
while (fields.hasNext()) {
final var entry = fields.next();
testObject.propertyStream()
.forEach(entry -> {
final JsonNode value = entry.getValue();
final long currentBlockNumber = extractLong(value, "currentBlockNumber");
String parentUncles = value.get("parentUncles").asText();
Expand Down Expand Up @@ -188,7 +185,7 @@ private void testDifficulty(
assertThat(UInt256.valueOf(calculator.nextDifficulty(currentTime, testHeader)))
.describedAs("File %s Test %s", testFile, entry.getKey())
.isEqualTo(currentDifficulty);
}
});
}

private long extractLong(final JsonNode node, final String name) {
Expand Down