5
5
"""
6
6
import os
7
7
import pytest
8
-
8
+ import secrets
9
9
10
10
from convex_api .key_pair import KeyPair
11
11
from tests .types import KeyPairInfo
12
12
13
13
14
14
SIGN_HASH_TEXT = '5bb1ce718241bfec110552b86bb7cccf0d95b8a5f462fbf6dff7c48543622ba5'
15
15
SIGN_TEXT = '0x7eceffab47295be3891ea745838a99102bfaf525ec43632366c7ec3f54db4822b5d581573aecde94c420554f963baebbf412e4304ad8636886ddfa7b1049f70e' # noqa: E501
16
+
17
+ PUBLIC_KEY = '0x5288fec4153b702430771dfac8aed0b21cafca4344dae0d47b97f0bf532b3306'
18
+ PUBLIC_KEY_CHECKSUM = '0x5288Fec4153b702430771DFAC8AeD0B21CAFca4344daE0d47B97F0bf532b3306'
19
+
16
20
def test_key_pair_create_new ():
17
21
key_pair = KeyPair ()
18
22
assert (key_pair )
@@ -84,3 +88,23 @@ def test_key_pair_is_equal(test_key_pair: KeyPair):
84
88
assert (not key_pair .is_equal (test_key_pair ))
85
89
with pytest .raises (TypeError ):
86
90
assert (not key_pair .is_equal (test_key_pair .public_key_bytes )) # type: ignore
91
+
92
+ def test_key_pair_is_public_key_hex ():
93
+ public_key = secrets .token_hex (32 )
94
+ assert (KeyPair .is_public_key_hex (public_key ))
95
+
96
+ def test_key_pair_is_public_key ():
97
+ public_key = secrets .token_hex (32 )
98
+ assert (KeyPair .is_public_key (public_key ))
99
+
100
+ def test_key_pair_is_public_key_checksum ():
101
+ public_key = secrets .token_hex (32 )
102
+ public_key_checksum = KeyPair .to_public_key_checksum (public_key )
103
+ assert (KeyPair .is_public_key_checksum (public_key_checksum ))
104
+
105
+ def test_key_pair_to_public_key_checksum ():
106
+ # generate a ethereum public_key
107
+ # convex public_key to checksum
108
+ public_key_checksum = KeyPair .to_public_key_checksum (PUBLIC_KEY )
109
+ assert (KeyPair .is_public_key_checksum (public_key_checksum ))
110
+ assert (public_key_checksum == PUBLIC_KEY_CHECKSUM )
0 commit comments