The downside is that they can be pretty time-intensive. Just a test for the length of signature bytes added 7 seconds to a 53-second test suite.
--- a/tests/core/eth-module/test_accounts.py
+++ b/tests/core/eth-module/test_accounts.py
@@ -2,10 +2,19 @@
import pytest
+from eth_keys.constants import (
+ SECPK1_N,
+)
from eth_utils import (
is_checksum_address,
)
+from hypothesis import (
+ example,
+ given,
+ strategies as st,
+)
+
from web3 import (
Account,
Web3,
@@ -268,6 +277,16 @@ def test_eth_account_sign(acct, message, key, expected_bytes, expected_hash, v,
assert account.sign(message_text=message) == signed
+@given(st.binary(), st.integers(
+ min_value=Web3.toInt(hexstr='0x1' + '00' * 31),
+ max_value=SECPK1_N - 1
+ )
+)
+def test_message_signature_length(acct, message, key):
+ signed = acct.sign(message, key)
+ assert len(signed.signature) == 65
+
+
@pytest.mark.parametrize(
'txn, private_key, expected_raw_tx, tx_hash, r, s, v',
(
What was wrong?
Want to catch/prevent more issues like ApeWorX/web3.py#466 earlier.
How can it be fixed?
More hypothesis tests. Piper's suggestions (on ApeWorX/web3.py#477):
The downside is that they can be pretty time-intensive. Just a test for the length of signature bytes added 7 seconds to a 53-second test suite.
Example: