-
Notifications
You must be signed in to change notification settings - Fork 180
feat: otter test nodes change keys #21830
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a445c52
refactor generate method
lpetrovic05 fac4053
test working
lpetrovic05 4dae5ab
finish test
lpetrovic05 1eb4eb4
for now
lpetrovic05 4021f64
final touches
lpetrovic05 8266cfb
s
lpetrovic05 ebbf909
Merge branch 'main' into 20282-otter-test-nodes-change-keys
lpetrovic05 2cdbdac
pr comments
lpetrovic05 1f57466
pr comments
lpetrovic05 2eacd4e
s
lpetrovic05 06f733b
qg
lpetrovic05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...-sdk/consensus-otter-tests/src/test/java/org/hiero/otter/fixtures/NetworkRosterTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| package org.hiero.otter.fixtures; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import com.hedera.hapi.node.state.roster.Roster; | ||
| import com.hedera.pbj.runtime.io.buffer.Bytes; | ||
| import com.swirlds.platform.crypto.KeyGeneratingException; | ||
| import com.swirlds.platform.crypto.KeysAndCertsGenerator; | ||
| import java.security.NoSuchAlgorithmException; | ||
| import java.security.NoSuchProviderException; | ||
| import java.security.SecureRandom; | ||
| import java.security.cert.CertificateEncodingException; | ||
| import java.util.List; | ||
| import org.hiero.consensus.model.node.KeysAndCerts; | ||
| import org.hiero.otter.fixtures.turtle.TurtleTestEnvironment; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Tests for verifying that the network roster correctly incorporates node parameters into the network roster. | ||
| */ | ||
| public class NetworkRosterTests { | ||
| /** | ||
| * Tests that when nodes are created with overridden keys and certificates, the network roster correctly reflects | ||
| * those certificates. | ||
| */ | ||
| @Test | ||
| void testCertificates() | ||
| throws NoSuchAlgorithmException, KeyGeneratingException, NoSuchProviderException, | ||
| CertificateEncodingException { | ||
| final TurtleTestEnvironment env = new TurtleTestEnvironment(); | ||
| try { | ||
| // Create a network with 2 nodes | ||
| final Network network = env.network(); | ||
| final List<Node> nodes = network.addNodes(2); | ||
| final Node node0 = nodes.get(0); | ||
| final Node node1 = nodes.get(1); | ||
|
|
||
| // Override the keys and certs for each node | ||
| final SecureRandom secureRandom = SecureRandom.getInstanceStrong(); | ||
| final KeysAndCerts kac0 = KeysAndCertsGenerator.generate(node0.selfId(), secureRandom, secureRandom); | ||
| final KeysAndCerts kac1 = KeysAndCertsGenerator.generate(node0.selfId(), secureRandom, secureRandom); | ||
| node0.keysAndCerts(kac0); | ||
| node1.keysAndCerts(kac1); | ||
|
|
||
| // Start the network so that the roster is created | ||
| network.start(); | ||
|
|
||
| // Verify that the roster uses the overridden certificates | ||
| final Roster roster = network.roster(); | ||
| assertThat(roster.rosterEntries().size()).isEqualTo(2); | ||
| assertThat(roster.rosterEntries().get(0).gossipCaCertificate()) | ||
| .isEqualTo(Bytes.wrap(kac0.sigCert().getEncoded())); | ||
| assertThat(roster.rosterEntries().get(1).gossipCaCertificate()) | ||
| .isEqualTo(Bytes.wrap(kac1.sigCert().getEncoded())); | ||
| } finally { | ||
| env.destroy(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.