forked from CalloraOrg/Callora-Contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_tests.py
More file actions
22 lines (17 loc) · 1.15 KB
/
Copy pathpatch_tests.py
File metadata and controls
22 lines (17 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import re
for root, _, files in os.walk('c:/Users/Stephan/Documents/Callora-Contracts/contracts/vault/src'):
for file in files:
if file.startswith('test') and file.endswith('.rs'):
path = os.path.join(root, file)
with open(path, 'r', encoding='utf-8') as f:
content = f.read()
# Replace deduct calls: &u16::MAX) -> &u16::MAX, &Address::generate(&env))
# Also replace other max_fee_bps values if any (e.g. &50), let's just do a regex
# deduct(&owner, &5, &None, &50) -> deduct(&owner, &5, &None, &50, &Address::generate(&env))
content = re.sub(r'(client\.deduct\([^;]+?)(,\s*&[^,]+)\)', r'\1\2, &Address::generate(&env))', content)
content = re.sub(r'(vault_client\.deduct\([^;]+?)(,\s*&[^,]+)\)', r'\1\2, &Address::generate(&env))', content)
# Replace DeductItem { amount, request_id }
content = re.sub(r'(request_id:\s*[^,}]+)\s*}', r'\1, developer: Address::generate(&env) }', content)
with open(path, 'w', encoding='utf-8') as f:
f.write(content)