Skip to content

Commit eea6a01

Browse files
committed
Test Codex32String reassignment, deletion, and slots
1 parent 19656e6 commit eea6a01

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎tests/test_bip93.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,28 @@
5050
from codex32.checksums import CODEX32, CODEX32_LONG
5151

5252

53+
@pytest.mark.parametrize(
54+
"name", ("s", "is_upper", "hrp", "payload", "k", "ident", "share_idx")
55+
)
56+
def test_codex32_string_read_only_attributes(name):
57+
"""Stored metadata cannot be reassigned or deleted after parsing."""
58+
share = Codex32String(VECTOR_1["secret_s"])
59+
original = str(share)
60+
with pytest.raises(AttributeError):
61+
setattr(share, name, "changed")
62+
with pytest.raises(AttributeError):
63+
delattr(share, name)
64+
assert str(share) == original
65+
66+
67+
def test_codex32_string_slots():
68+
"""Instances cannot acquire arbitrary attributes or an instance dict."""
69+
share = Codex32String(VECTOR_1["secret_s"])
70+
with pytest.raises(AttributeError):
71+
setattr(share, "unexpected", "value")
72+
assert not hasattr(share, "__dict__")
73+
74+
5375
def test_parts():
5476
"""Test Vector 1: parse a codex32 string into parts"""
5577
s = Codex32String(VECTOR_1["secret_s"])

0 commit comments

Comments
 (0)