-
Notifications
You must be signed in to change notification settings - Fork 134
(WIP) initial logic for changing node account id #2518
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
Open
emiliyank
wants to merge
28
commits into
hiero-ledger:main
Choose a base branch
from
emiliyank:feature/hip-1299-changing-node-account-id
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+638
−20
Open
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
f8cf1a6
initial logic for changing node account id
emiliyank 0c6c579
remove client property from GrpcRequest
emiliyank b04c0c2
add NodeUpdateAccountIdIntegrationTest
emiliyank 017dd5e
hip 1299 - in Executable handle status INVALID_NODE_ACCOUNT_ID
emiliyank c25d9cd
hip 1299 - add integration test to update AddressBook
emiliyank 9bcfbd3
hip 1299 - switch error from INVALID_NODE_ACCOUNT_ID to INVALID_NODE_…
emiliyank ba6351c
Merge branch 'main' into feature/hip-1299-changing-node-account-id
emiliyank c78f359
hip 1299 - use new method Client.updateNetworkFromAddressBook()
emiliyank ae7dcc3
Merge remote-tracking branch 'origin/feature/hip-1299-changing-node-a…
emiliyank 875d06f
hip-1299 add more integration tests
emiliyank 0f35473
initial logic for changing node account id
emiliyank d6edab7
remove client property from GrpcRequest
emiliyank a2c75ff
add NodeUpdateAccountIdIntegrationTest
emiliyank 7b273cb
hip 1299 - in Executable handle status INVALID_NODE_ACCOUNT_ID
emiliyank 99810ac
hip 1299 - add integration test to update AddressBook
emiliyank cd3870e
hip 1299 - switch error from INVALID_NODE_ACCOUNT_ID to INVALID_NODE_…
emiliyank b7388d4
hip 1299 - use new method Client.updateNetworkFromAddressBook()
emiliyank 84474ac
hip-1299 add more integration tests
emiliyank e1f2dce
move all dab tests to NodeUpdateTransactionIntegrationTest
emiliyank 06d46a9
Merge remote-tracking branch 'origin/feature/hip-1299-changing-node-a…
emiliyank 6249fdd
remove unused class NodeUpdateAccountIdIntegrationTest
emiliyank 63c79e9
use consensus node v0.68 on solo-action
emiliyank 2ebecb1
add --rerun-tasks on gradlew
emiliyank f60ea70
add --rerun-tasks on :aggregation:testCodeCoverageReport
emiliyank 76c8add
revert unused changes in Executable
emiliyank 3064770
Merge branch 'main' into feature/hip-1299-changing-node-account-id
emiliyank 073a3b3
fix: advance node on server error in async execution
emiliyank cda1929
refactor NodeUpdateTransactionIntegrationTest to fix Codacy warning
emiliyank 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
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
84 changes: 84 additions & 0 deletions
84
...on/java/com/hedera/hashgraph/sdk/test/integration/NodeUpdateAccountIdIntegrationTest.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,84 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| package com.hedera.hashgraph.sdk.test.integration; | ||
|
|
||
| import com.hedera.hashgraph.sdk.AccountId; | ||
| import com.hedera.hashgraph.sdk.AccountCreateTransaction; | ||
| import com.hedera.hashgraph.sdk.Client; | ||
| import com.hedera.hashgraph.sdk.Hbar; | ||
| import com.hedera.hashgraph.sdk.NodeUpdateTransaction; | ||
| import com.hedera.hashgraph.sdk.PrivateKey; | ||
| import com.hedera.hashgraph.sdk.Status; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatCode; | ||
|
|
||
| /** | ||
| * Integration test for NodeUpdateTransaction functionality, specifically testing | ||
| * the Dynamic Address Book (DAB) enhancement for updating node account IDs. | ||
| * | ||
| * This test verifies the complete flow of updating a node's account ID with | ||
| * proper signatures from both the node admin key and the account ID key. | ||
| */ | ||
| class NodeUpdateAccountIdIntegrationTest { | ||
|
|
||
| @Test | ||
| @DisplayName("NodeUpdateTransaction should succeed when updating account ID with proper signatures") | ||
| void shouldSucceedWhenUpdatingNodeAccountIdWithProperSignatures() throws Exception { | ||
| // Set up the local network with 2 nodes | ||
| var network = new HashMap<String, AccountId>(); | ||
| network.put("localhost:50211", new AccountId(0, 0, 3)); | ||
| network.put("localhost:50212", new AccountId(0, 0, 4)); | ||
|
|
||
| try (var client = Client.forNetwork(network) | ||
| .setMirrorNetwork(List.of("localhost:5600")) | ||
| .setTransportSecurity(false) | ||
| .setVerifyCertificates(false)) { | ||
| // Set the operator to be account 0.0.2 | ||
| var originalOperatorKey = PrivateKey.fromString( | ||
| "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137"); | ||
| client.setOperator(new AccountId(0, 0, 2), originalOperatorKey); | ||
|
|
||
| // Given: A node with an existing account ID | ||
| // First, create a new account that will be used as the new node account ID | ||
| var newAccountKey = PrivateKey.generateED25519(); | ||
| var newAccountCreateTransaction = new AccountCreateTransaction() | ||
| .setKey(newAccountKey.getPublicKey()) | ||
| .setInitialBalance(Hbar.from(10)) | ||
| .setMaxTransactionFee(Hbar.from(1)); | ||
|
|
||
| var newAccountResponse = newAccountCreateTransaction.execute(client); | ||
| var newAccountReceipt = newAccountResponse.getReceipt(client); | ||
| var newAccountId = newAccountReceipt.accountId; | ||
|
|
||
| // Create a node admin key | ||
| var nodeAdminKey = PrivateKey.generateED25519(); | ||
|
|
||
| // When: A NodeUpdateTransaction is submitted to change the account ID | ||
| var nodeUpdateTransaction = new NodeUpdateTransaction() | ||
| .setNodeId(0) // Using node 0 as in the existing test | ||
| .setAccountId(newAccountId) | ||
| .setAdminKey(nodeAdminKey.getPublicKey()) | ||
0xivanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .setMaxTransactionFee(Hbar.from(10)) | ||
| .setTransactionMemo("Update node account ID for DAB testing"); | ||
|
|
||
| // Sign with both the node admin key and the new account key | ||
| nodeUpdateTransaction.freezeWith(client) | ||
| .sign(nodeAdminKey) | ||
| .sign(newAccountKey); | ||
0xivanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Then: The transaction should succeed | ||
| assertThatCode(() -> { | ||
| var response = nodeUpdateTransaction.execute(client); | ||
| assertThat(response).isNotNull(); | ||
|
|
||
| // Verify the transaction was successful by checking the receipt | ||
| var receipt = response.getReceipt(client); | ||
| assertThat(receipt.status).isEqualTo(Status.SUCCESS); | ||
| }).doesNotThrowAnyException(); | ||
| } | ||
| } | ||
| } | ||
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.