Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.
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
9 changes: 6 additions & 3 deletions iota/commands/extended/traverse_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import filters as f

from iota import BadApiResponse, BundleHash, Transaction, \
TransactionHash, TryteString, Bundle
TransactionHash, TryteString, Bundle, TransactionTrytes
from iota.commands import FilterCommand, RequestFilter
from iota.commands.core.get_trytes import GetTrytesCommand
from iota.exceptions import with_context
Expand Down Expand Up @@ -55,10 +55,13 @@ def _traverse_bundle(self, txn_hash, target_bundle_hash):
GetTrytesCommand(self.adapter)(hashes=[txn_hash])['trytes']
) # type: List[TryteString]

if not trytes:
# If no tx was found by the node for txn_hash, it returns 9s,
# so we check here if it returned all 9s trytes.
if not trytes or trytes == [TransactionTrytes('')]:
raise with_context(
exc=BadApiResponse(
'Bundle transactions not visible '
'Could not get trytes of bundle transaction from the Tangle. '
'Bundle transactions not visible.'
'(``exc.context`` has more info).',
),

Expand Down
17 changes: 17 additions & 0 deletions test/commands/extended/traverse_bundle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,20 @@ def test_missing_transaction(self):
b'ORYCRDX9TOMJPFCRB9R9KPUUGFPVOWYXFIWEW9999'
),
)

def test_missing_transaction_zero_trytes(self):
"""
Unable to find the requested transaction.
getTrytes returned only zeros, no tx was found.
"""
zero_trytes = TransactionTrytes('')
self.adapter.seed_response('getTrytes', {'trytes': [zero_trytes]})

with self.assertRaises(BadApiResponse):
self.command(
transaction =
TransactionHash(
b'FSEWUNJOEGNUI9QOCRFMYSIFAZLJHKZBPQZZYFG9'
b'ORYCRDX9TOMJPFCRB9R9KPUUGFPVOWYXFIWEW9999'
),
)