Skip to content

Commit c2c9bdb

Browse files
committed
refactor: remove generate_transaction_id
Signed-off-by: exploreriii <[email protected]>
1 parent 1abfe97 commit c2c9bdb

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

tests/unit/conftest.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@ def mock_account_ids():
2222
token_id_2 = TokenId(2, 2, 2)
2323
return account_id_sender, account_id_recipient, node_account_id, token_id_1, token_id_2
2424

25-
@pytest.fixture
26-
def generate_transaction_id():
27-
"""
28-
Return a factory which, given an AccountId proto, returns a TransactionId
29-
stamped with the current time.
30-
"""
31-
def _make(account_id_proto):
32-
now = time.time()
33-
secs = int(now)
34-
nanos = int((now - secs) * 1e9)
35-
ts = timestamp_pb2.Timestamp(seconds=secs, nanos=nanos)
36-
return TransactionId(valid_start=ts, account_id=account_id_proto)
37-
return _make
38-
3925
@pytest.fixture
4026
def amount():
4127
"""Fixture to provide a default amount for fungible tokens."""

tests/unit/test_token_pause_transaction.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@
2020

2121
pytestmark = pytest.mark.unit
2222

23-
# This test uses fixture mock_account_ids and generate_transaction id as parameter
24-
def test_build_transaction_body(mock_account_ids, generate_transaction_id, token_id):
23+
# This test uses fixture mock_account_ids and token_id as parameter
24+
def test_build_transaction_body(mock_account_ids, token_id):
2525
"""Test building a fungible token pause transaction body with valid values."""
2626
account_id, _, node_account_id, _, _ = mock_account_ids
2727

2828
pause_tx = TokenPauseTransaction().set_token_id(token_id)
29-
pause_tx.transaction_id = generate_transaction_id(account_id)
29+
pause_tx.operator_account_id = account_id
3030
pause_tx.node_account_id = node_account_id
3131

32-
transaction_body = pause_tx.build_transaction_body()
32+
transaction_body = pause_tx.build_transaction_body() # Will generate a transaction_id
3333

3434
assert transaction_body.token_pause.token == token_id.to_proto()
3535
assert transaction_body.transactionID == pause_tx.transaction_id.to_proto()
3636
assert transaction_body.nodeAccountID == pause_tx.node_account_id.to_proto()
3737

38-
def test_build_transaction_body_nft(mock_account_ids, generate_transaction_id, nft_id):
38+
def test_build_transaction_body_nft(mock_account_ids, nft_id):
3939
"""Test building an NFT‐pause transaction body with valid values."""
4040
account_id, _, node_account_id, _, _ = mock_account_ids
4141

4242
# nft_id is NftId(tokenId=TokenId(...), serialNumber=...)
4343
base_token_id = nft_id.tokenId
4444

4545
pause_tx = TokenPauseTransaction().set_token_id(base_token_id)
46-
pause_tx.transaction_id = generate_transaction_id(account_id)
46+
pause_tx.operator_account_id = account_id
4747
pause_tx.node_account_id = node_account_id
4848

4949
transaction_body = pause_tx.build_transaction_body()
@@ -52,25 +52,22 @@ def test_build_transaction_body_nft(mock_account_ids, generate_transaction_id, n
5252
assert transaction_body.transactionID == pause_tx.transaction_id.to_proto()
5353
assert transaction_body.nodeAccountID == pause_tx.node_account_id.to_proto()
5454

55-
# This test uses fixture (mock_account_ids, mock_client) as parameter
56-
def test_to_proto(mock_account_ids, mock_client, generate_transaction_id):
55+
# This test uses fixture (token_id, mock_client) as parameter
56+
def test_to_proto(token_id, mock_client):
5757
"""Test converting the token pause transaction to protobuf format after signing."""
58-
account_id, _, _, token_id, _ = mock_account_ids
5958

6059
# Build the TokenPauseTransaction
6160
pause_tx = (
6261
TokenPauseTransaction()
6362
.set_token_id(token_id)
6463
)
6564

66-
pause_tx.transaction_id = generate_transaction_id(account_id)
67-
6865
# Create a fake pause key that returns certain bytes when sign() is called:
6966
pause_key = MagicMock()
7067
pause_key.sign.return_value = b'signature'
7168
pause_key.public_key().to_bytes_raw.return_value = b'public_key'
7269

73-
# Freeze and sign using the pause key:
70+
# Freeze and sign using the pause key, which also generates transaction_id:
7471
pause_tx.freeze_with(mock_client)
7572
pause_tx.sign(pause_key)
7673

0 commit comments

Comments
 (0)