Skip to content

Commit 6ed5155

Browse files
committed
remove CONVEX_SCRYPT
1 parent 8b08ff6 commit 6ed5155

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

convex_api/api.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
class API:
3838

3939
LANGUAGE_LISP = 'convex-lisp'
40-
LANGUAGE_SCRYPT = 'convex-scrypt'
41-
LANGUAGE_ALLOWED = [LANGUAGE_LISP, LANGUAGE_SCRYPT]
40+
# Convex Scrypt Language disabled
41+
# LANGUAGE_SCRYPT = 'convex-scrypt'
42+
LANGUAGE_ALLOWED = [LANGUAGE_LISP]
4243

4344
def __init__(self, url, language=LANGUAGE_LISP):
4445
self._url = url
@@ -420,8 +421,10 @@ def get_address(self, function_name, address_account):
420421
"""
421422

422423
line = f'(address {function_name})'
424+
"""
423425
if self._language == API.LANGUAGE_SCRYPT:
424426
line = f'address({function_name})'
427+
"""
425428
result = self.query(line, address_account)
426429
if result and 'value' in result:
427430
return to_address(result['value'])
@@ -469,8 +472,10 @@ def get_balance(self, address_account, account_from=None):
469472
else:
470473
address_from = account_from.address
471474
line = f'(balance #{address})'
475+
"""
472476
if self._language == API.LANGUAGE_SCRYPT:
473477
line = f'balance(#{address})'
478+
"""
474479
try:
475480

476481
result = self._transaction_query(address_from, line)
@@ -522,9 +527,10 @@ def transfer(self, to_address_account, amount, account):
522527
raise ValueError(f'You must provide a valid to account/address ({transfer_to_address}) to transfer funds too')
523528

524529
line = f'(transfer #{transfer_to_address} {amount})'
530+
"""
525531
if self._language == API.LANGUAGE_SCRYPT:
526532
line = f'transfer(#{transfer_to_address}, {amount})'
527-
533+
"""
528534
result = self.send(line, account)
529535
if result and 'value' in result:
530536
return result['value']
@@ -577,8 +583,10 @@ def transfer_account(self, from_account, to_account):
577583
raise ValueError('You need to have the to account registered with an address')
578584

579585
line = f'(set-key {from_account.key_pair.public_key_checksum})'
586+
"""
580587
if self._language == API.LANGUAGE_SCRYPT:
581588
line = f'set-key({from_account.key_pair.public_key_checksum})'
589+
"""
582590
result = self.send(line, to_account)
583591
if result and 'value' in result and from_account.key_pair.is_equal(result['value']):
584592
return Account(from_account.key_pair, to_account.address, to_account.name)

tests/intergration/test_api.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_api_language_setup(convex_url):
2525
convex = API(convex_url, API.LANGUAGE_LISP)
2626
assert(convex.language == API.LANGUAGE_LISP)
2727

28-
convex = API(convex_url, API.LANGUAGE_SCRYPT)
29-
assert(convex.language == API.LANGUAGE_SCRYPT)
28+
# convex = API(convex_url, API.LANGUAGE_SCRYPT)
29+
# assert(convex.language == API.LANGUAGE_SCRYPT)
3030

3131
with pytest.raises(ValueError, match='language'):
3232
convex = API(convex_url, "bad-language")
@@ -135,7 +135,8 @@ def test_convex_api_send_basic_lisp(convex_url, test_account):
135135
assert 'value' in result
136136
assert(result['value'] == [2, 3, 4, 5, 6])
137137

138-
def test_convex_api_send_basic_scrypt(convex_url, test_account):
138+
139+
def DISABLED_test_convex_api_send_basic_scrypt(convex_url, test_account):
139140
convex = API(convex_url, API.LANGUAGE_SCRYPT)
140141
request_amount = convex.request_funds(TEST_FUNDING_AMOUNT, test_account)
141142
result = convex.send('map(inc, [1, 2, 3, 4, 5])', test_account)
@@ -197,7 +198,7 @@ def test_convex_api_call(convex_url):
197198
assert(call_get_result['value'] == test_number)
198199

199200
# now api calls using language scrypt
200-
201+
"""
201202
convex = API(convex_url, API.LANGUAGE_SCRYPT)
202203
test_number = secrets.randbelow(1000)
203204
call_set_result = convex.send(f'call storage_example set({test_number})', account)
@@ -214,7 +215,7 @@ def test_convex_api_call(convex_url):
214215
215216
address = convex.get_address('storage_example', account)
216217
assert(address == contract_address)
217-
218+
"""
218219
def test_convex_api_transfer(convex_url):
219220
convex = API(convex_url)
220221
key_pair = KeyPair()
@@ -239,7 +240,8 @@ def test_convex_api_query_lisp(convex_url, test_account):
239240
# return value is the address as a checksum
240241
assert(to_address(result['value']) == test_account.address)
241242

242-
def test_convex_api_query_scrypt(convex_url, test_account):
243+
244+
def DISABLED_test_convex_api_query_scrypt(convex_url, test_account):
243245
convex = API(convex_url, API.LANGUAGE_SCRYPT)
244246
result = convex.query(f'address({test_account.address})', test_account)
245247
assert(result)

tests/intergration/test_basic_api.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
from convex_api.utils import (
1212
to_hex,
1313
remove_0x_prefix,
14-
to_bytes
14+
to_bytes,
15+
to_public_key_checksum
1516
)
1617

18+
1719
PRIVATE_TEST_KEY = 0x973f69bcd654b264759170724e1e30ccd2e75fc46b7993fd24ce755f0a8c24d0
1820
PUBLIC_ADDRESS = '5288fec4153b702430771dfac8aed0b21cafca4344dae0d47b97f0bf532b3306'
1921

@@ -29,13 +31,23 @@ def get_test_account():
2931
assert(public_address == PUBLIC_ADDRESS)
3032
return private_key, public_address
3133

34+
def generate_test_keys():
35+
private_key = Ed25519PrivateKey.generate()
36+
public_key = private_key.public_key()
37+
public_key_bytes = public_key.public_bytes(
38+
encoding=serialization.Encoding.Raw,
39+
format=serialization.PublicFormat.Raw
40+
)
41+
public_address = remove_0x_prefix(to_hex(public_key_bytes))
42+
return private_key, public_address
43+
3244

3345
def create_account(convex_url, public_address):
3446
account_data = {
35-
'accountKey': public_address,
47+
'accountKey': remove_0x_prefix(to_public_key_checksum(public_address)),
3648
}
37-
print('create_account send', account_data)
3849
url = f'{convex_url}/api/v1/createAccount'
50+
print('create_account send to ', url, 'data:', account_data)
3951
response = requests.post(url, data=json.dumps(account_data))
4052
assert(response.status_code == 200)
4153
result = response.json()
@@ -57,7 +69,7 @@ def request_funds(convex_url, address):
5769

5870
def test_submit_transaction(convex_url):
5971

60-
private_key, public_address = get_test_account()
72+
private_key, public_address = generate_test_keys()
6173
address = create_account(convex_url, public_address)
6274
request_funds(convex_url, address)
6375
# faucet request amount
@@ -99,7 +111,7 @@ def test_submit_transaction(convex_url):
99111

100112

101113
def test_query_lisp(convex_url):
102-
private_key, public_address = get_test_account()
114+
private_key, public_address = generate_test_keys()
103115
address = create_account(convex_url, public_address)
104116
request_funds(convex_url, address)
105117
query_data = {
@@ -118,8 +130,8 @@ def test_query_lisp(convex_url):
118130
assert(result['value'] > 0)
119131

120132

121-
def test_query_scrypt(convex_url):
122-
private_key, public_address = get_test_account()
133+
def DISABLED_test_query_scrypt(convex_url):
134+
private_key, public_address = generate_test_keys()
123135
address = create_account(convex_url, public_address)
124136
request_funds(convex_url, address)
125137
query_data = {

0 commit comments

Comments
 (0)