diff --git a/iota/commands/extended/traverse_bundle.py b/iota/commands/extended/traverse_bundle.py index d81196d..d1176db 100644 --- a/iota/commands/extended/traverse_bundle.py +++ b/iota/commands/extended/traverse_bundle.py @@ -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 @@ -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).', ), diff --git a/test/commands/extended/traverse_bundle_test.py b/test/commands/extended/traverse_bundle_test.py index f28066f..b869b36 100644 --- a/test/commands/extended/traverse_bundle_test.py +++ b/test/commands/extended/traverse_bundle_test.py @@ -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' + ), + ) \ No newline at end of file