Skip to content

Commit

Permalink
patch coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Mar 5, 2025
1 parent f5d5ceb commit c20fe19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def unpack(message):
if asset == config.BTC:
raise exceptions.AssetNameError(f"{config.BTC} not allowed")

except struct.error as e:
except (struct.error, TypeError) as e:
logger.trace(f"enhanced send unpack error: {e}")
raise exceptions.UnpackError(f"could not unpack: {e}") # noqa: B904

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def test_new_unpack(defaults):
b"\x15\x01\x9c\x8d\x1fT\x05E\x1d\xe6\x07\x0b\xf1\xdb\x86\xabj\xcc\xb4\x95\xb6%\x01\x03\x04test"
) == {"destination": defaults["addresses"][5], "flags": 3, "memo": "test"}

with pytest.raises(exceptions.UnpackError, match="could not unpack"):
sweep.new_unpack(
b"\x01\x9c\x8d\x1fT\x05E\x1d\xe6\x07\x0b\xf1\xdb\x86\xabj\xcc\xb4\x95\xb6%\x01\x03"
)


def test_unpack(defaults):
with ProtocolChangesDisabled("taproot_support"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ def test_unpack(ledger_db, defaults):
enhancedsend.unpack(
b'\x01\x00\x02\xe8\x03"\x03\x01qe0u\xb3n\xe3\xd25\x1bU\x81\xd9\xb9\x90W!\xcb\xfe`\xb7\x1c\xe2%\x01\xe1\xb4N\xd0:\x96\x84\x03\xab\xcd\xef'
)

with ProtocolChangesDisabled(["taproot_support"]):
with pytest.raises(exceptions.UnpackError, match="could not unpack"):
result = enhancedsend.unpack(
"x02\xe1\xb4N\xd0:\x96x02\xe1\xb4N\xd0:\x96x02\xe1\xb4N\xd0:\x96x02\xe1\xb4N\xd0:\x96a"
)
print(result)

0 comments on commit c20fe19

Please sign in to comment.