Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/workflows/pr-check-primary-test-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'

- name: Run test file naming check
run: node .github/scripts/pr-check-test-files.js
6 changes: 5 additions & 1 deletion .github/workflows/pr-check-secondary-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ jobs:

- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@692b186bd2e4c8d46b9deb1c067dc6ddcf0abcd7 #v0.15.0
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 #v0.19.0
with:
installMirrorNode: true
soloVersion: v0.65.0
mirrorNodeVersion: v0.153.0
hieroVersion: v0.73.0

- name: Run Examples
env:
OPERATOR_ID: ${{ steps.solo.outputs.accountId }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ jobs:

- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@692b186bd2e4c8d46b9deb1c067dc6ddcf0abcd7 # v0.15.0
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 # v0.19.0
with:
installMirrorNode: true
soloVersion: v0.65.0
mirrorNodeVersion: v0.153.0
hieroVersion: v0.73.0

- name: Run integration tests
id: integration
Expand Down
19 changes: 9 additions & 10 deletions examples/account/account_update_transaction_with_keylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,15 @@ def account_update_with_keylist():
threshold_key = KeyList([threshold_key_1.public_key(), threshold_key_2.public_key()], threshold=2)

print("\nRotating account key to a 2-of-2 threshold KeyList...")
key_list_receipt = (
AccountUpdateTransaction()
.set_account_id(account_id)
.set_key(threshold_key)
.freeze_with(client)
.sign(current_private_key) # Sign with current key
.sign(threshold_key_1) # First signature for threshold=2
.sign(threshold_key_2) # Second signature for threshold=2
.execute(client)
)
tx = AccountUpdateTransaction().set_account_id(account_id).set_key(threshold_key)

tx.transaction_fee = Hbar.from_hbars(10)

tx.freeze_with(client)
tx.sign(current_private_key) # Sign with current key
tx.sign(threshold_key_1) # First signature for threshold=2
tx.sign(threshold_key_2) # Second signature for threshold=2
key_list_receipt = tx.execute(client)

if key_list_receipt.status != ResponseCode.SUCCESS:
print(f"KeyList rotation failed with status: {ResponseCode(key_list_receipt.status).name}")
Expand Down
9 changes: 8 additions & 1 deletion examples/nodes/node_create_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dotenv import load_dotenv

from hiero_sdk_python import AccountId, Client, Network, PrivateKey
from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.nodes.node_create_transaction import NodeCreateTransaction
from hiero_sdk_python.response_code import ResponseCode
Expand Down Expand Up @@ -65,7 +66,13 @@ def node_create():

# Node account ID - this should be an existing account
# that will be associated with the node
account_id = AccountId.from_string("0.0.4")
account_id = (
AccountCreateTransaction()
.set_key_without_alias(PrivateKey.generate_ecdsa())
.freeze_with(client)
.execute(client)
.account_id
)

# Node description
description = "Example node"
Expand Down
9 changes: 8 additions & 1 deletion examples/nodes/node_delete_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dotenv import load_dotenv

from hiero_sdk_python import AccountId, Client, Network, PrivateKey
from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.nodes.node_create_transaction import NodeCreateTransaction
from hiero_sdk_python.nodes.node_delete_transaction import NodeDeleteTransaction
Expand Down Expand Up @@ -64,7 +65,13 @@ def create_node(client):
"""Create a node on the network and return its ID and admin key."""
# Node account ID - this should be an existing account
# that will be associated with the node
account_id = AccountId.from_string("0.0.4")
account_id = account_id = (
AccountCreateTransaction()
.set_key_without_alias(PrivateKey.generate_ecdsa())
.freeze_with(client)
.execute(client)
.account_id
)

# Node description
description = "Example node for deletion"
Expand Down
28 changes: 16 additions & 12 deletions examples/nodes/node_update_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dotenv import load_dotenv

from hiero_sdk_python import AccountId, Client, Network, PrivateKey
from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.nodes.node_create_transaction import NodeCreateTransaction
from hiero_sdk_python.nodes.node_update_transaction import NodeUpdateTransaction
Expand Down Expand Up @@ -60,12 +61,8 @@ def setup_client():
return client


def create_node(client):
def create_node(client, account_id):
"""Create a node on the network and return its ID and admin key."""
# Node account ID - this should be an existing account
# that will be associated with the node
account_id = AccountId.from_string("0.0.4")

# Node description
description = "Example node"

Expand Down Expand Up @@ -108,11 +105,8 @@ def create_node(client):
return receipt.node_id, admin_key


def update_node(client, node_id, admin_key):
def update_node(client, account_id, node_account_key, node_id, admin_key):
"""Update an existing node with new parameters."""
# Node account ID
account_id = AccountId.from_string("0.0.4")

# Updated node description
updated_description = "Updated example node"

Expand All @@ -139,7 +133,8 @@ def update_node(client, node_id, admin_key):
.set_grpc_web_proxy_endpoint(updated_grpc_proxy_endpoint)
.set_decline_reward(False)
.freeze_with(client)
.sign(admin_key) # Sign with the admin key
.sign(admin_key)
.sign(node_account_key)
.execute(client)
)

Expand All @@ -163,11 +158,20 @@ def node_update():
# Set up client with operator account
client = setup_client()

node_account_private_key = PrivateKey.generate_ecdsa()
node_account_id = (
AccountCreateTransaction()
.set_key_without_alias(node_account_private_key)
.freeze_with(client)
.execute(client)
.account_id
)

# Create a new node and get its ID and admin key
node_id, admin_key = create_node(client)
node_id, admin_key = create_node(client, node_account_id)

# Update the newly created node with modified parameters
update_node(client, node_id, admin_key)
update_node(client, node_account_id, node_account_private_key, node_id, admin_key)

print("\nNode creation and update example completed successfully!")

Expand Down
18 changes: 9 additions & 9 deletions tests/integration/account_update_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def test_integration_account_update_transaction_set_key_with_threshold_keylist(e
key_2_private = PrivateKey.generate_ed25519()
threshold_key = KeyList([key_1_private.public_key(), key_2_private.public_key()], threshold=2)

receipt = (
AccountUpdateTransaction()
.set_account_id(account_id)
.set_key(threshold_key)
.freeze_with(env.client)
.sign(key_1_private)
.sign(key_2_private)
.execute(env.client)
)
tx = AccountUpdateTransaction().set_account_id(account_id).set_key(threshold_key)

tx.transaction_fee = Hbar.from_hbars(5)
tx.freeze_with(env.client)
tx.sign(key_1_private)
tx.sign(key_2_private)

receipt = tx.execute(env.client)

assert receipt.status == ResponseCode.SUCCESS, (
f"Account key rotation to KeyList failed with status: {ResponseCode(receipt.status).name}"
)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/batch_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hiero_sdk_python.crypto.private_key import PrivateKey
from hiero_sdk_python.crypto.public_key import PublicKey
from hiero_sdk_python.file.file_id import FileId
from hiero_sdk_python.hbar import Hbar
from hiero_sdk_python.query.account_info_query import AccountInfoQuery
from hiero_sdk_python.query.transaction_get_receipt_query import TransactionGetReceiptQuery
from hiero_sdk_python.response_code import ResponseCode
Expand Down Expand Up @@ -96,6 +97,7 @@ def test_batch_transaction_can_execute_large_batch(env):

batch_tx.add_inner_transaction(transfer_tx)

batch_tx.transaction_fee = Hbar.from_hbars(10)
batch_tx.freeze_with(env.client)
batch_tx.sign(batch_key)

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/ethereum_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def test_integration_ethereum_transaction_jumbo_transaction(env):
alias_private_key,
)

receipt = EthereumTransaction().set_ethereum_data(transaction_data).execute(env.client)
tx = EthereumTransaction().set_ethereum_data(transaction_data)
tx.transaction_fee = Hbar.from_hbars(10)
receipt = tx.execute(env.client)
assert receipt.status == ResponseCode.SUCCESS, (
f"Ethereum transaction failed with status: {ResponseCode(receipt.status).name}"
)
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/node_create_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest

from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.account.account_id import AccountId
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.client.client import Client
Expand Down Expand Up @@ -42,7 +43,13 @@ def test_node_create_transaction_can_execute():
client.set_operator(AccountId(0, 0, 2), original_operator_key)

# The account of the new node
account_id = AccountId(0, 0, 4)
account_id = (
AccountCreateTransaction()
.set_key_without_alias(PrivateKey.generate_ecdsa())
.freeze_with(client)
.execute(client)
.account_id
)

# Description of the new node
description = "test"
Expand Down
10 changes: 9 additions & 1 deletion tests/integration/node_delete_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest

from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.account.account_id import AccountId
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.client.client import Client
Expand Down Expand Up @@ -39,7 +40,14 @@ def test_node_delete_transaction_can_execute():
)
client.set_operator(AccountId(0, 0, 2), original_operator_key)

account_id = AccountId(0, 0, 4) # This is the account of the node
# This is the account of the node
account_id = (
AccountCreateTransaction()
.set_key_without_alias(PrivateKey.generate_ecdsa())
.freeze_with(client)
.execute(client)
.account_id
)

# Endpoints for the node
endpoint = Endpoint(domain_name="test.com", port=123)
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/node_update_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest

from hiero_sdk_python.account.account_create_transaction import AccountCreateTransaction
from hiero_sdk_python.account.account_id import AccountId
from hiero_sdk_python.address_book.endpoint import Endpoint
from hiero_sdk_python.client.client import Client
Expand Down Expand Up @@ -39,7 +40,11 @@ def test_node_update_transaction_can_execute():
)
client.set_operator(AccountId(0, 0, 2), original_operator_key)

account_id = AccountId(0, 0, 4) # This is the account of the node
# This is the account of the node
account_key = PrivateKey.generate_ecdsa()
account_id = (
AccountCreateTransaction().set_key_without_alias(account_key).freeze_with(client).execute(client).account_id
)

# Endpoints for the node
endpoint = Endpoint(domain_name="test.com", port=123)
Expand Down Expand Up @@ -79,6 +84,7 @@ def test_node_update_transaction_can_execute():
.set_grpc_web_proxy_endpoint(update_proxy_endpoint)
.freeze_with(client)
.sign(admin_key)
.sign(account_key)
.execute(client)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ def test_integration_scheduled_topic_message_submit_transaction_can_execute_with
.set_topic_id(topic_id)
.set_message("Hello, Python SDK!")
.add_custom_fee_limit(topic_message_submit_fee_limit)
.schedule()
)
tx.transaction_fee = Hbar(2).to_tinybars()
tx = tx.schedule()

receipt = tx.execute(env.client)

assert receipt.status == ResponseCode.SUCCESS, (
Expand Down
Loading