Skip to content

Commit

Permalink
Merge branch 'develop' into 15283-add-javadocs-consensus-service
Browse files Browse the repository at this point in the history
  • Loading branch information
petreze authored Sep 17, 2024
2 parents 6374467 + 165f463 commit c65d67f
Show file tree
Hide file tree
Showing 168 changed files with 17,971 additions and 22,716 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@
import com.swirlds.platform.recovery.internal.EventStreamSingleFileIterator;
import com.swirlds.platform.system.StaticSoftwareVersion;
import com.swirlds.platform.system.events.EventDescriptorWrapper;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

public class EventMigrationTest {

Expand All @@ -44,6 +48,12 @@ public static void setUp() throws ConstructableRegistryException {
StaticSoftwareVersion.setSoftwareVersion(new ServicesSoftwareVersion(SemanticVersion.DEFAULT, 0));
}

public static Stream<Arguments> migrationTestArguments() {
return Stream.of(
Arguments.of("eventFiles/previewnet-53/2024-08-26T10_38_35.016340634Z.events", 637, 4),
Arguments.of("eventFiles/testnet-53/2024-09-10T00_00_00.021456201Z.events", 635, 5));
}

/**
* Tests the migration of events as we are switching events to protobuf. The main thing we are testing is that the
* hashes of old events can still be calculated when the code changes. This is done by calculating the hashes of the
Expand All @@ -53,21 +63,17 @@ public static void setUp() throws ConstructableRegistryException {
* Even though this could be considered a platform test, it needs to be in the services module because the event
* contains a {@link SerializableSemVers} which is a services class
*/
@Test
public void migration() throws URISyntaxException, IOException {
final int numEventsExpected = 637;
final int unmatchedHashesExpected = 4;
@ParameterizedTest
@MethodSource("migrationTestArguments")
public void migration(
@NonNull final String fileName, final int numEventsExpected, final int unmatchedHashesExpected)
throws URISyntaxException, IOException {
final Set<Hash> eventHashes = new HashSet<>();
final Set<Hash> parentHashes = new HashSet<>();
int numEventsFound = 0;

try (final EventStreamSingleFileIterator iterator = new EventStreamSingleFileIterator(
new File(this.getClass()
.getClassLoader()
.getResource("eventFiles/previewnet-53/2024-08-26T10_38_35.016340634Z.events")
.toURI())
.toPath(),
false)) {
new File(this.getClass().getClassLoader().getResource(fileName).toURI()).toPath(), false)) {
while (iterator.hasNext()) {
final PlatformEvent platformEvent = iterator.next().getPlatformEvent();
new DefaultEventHasher().hashEvent(platformEvent);
Expand Down
Binary file not shown.
Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion hedera-node/test-clients/record-snapshots/Block.json

This file was deleted.

This file was deleted.

Loading

0 comments on commit c65d67f

Please sign in to comment.