Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Dec 13, 2023
1 parent 9b054d3 commit 62378e2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Processes/dan_wallet_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def claim_burn(self, burn: Any, account: Any):
def get_balances(self, account: Any):
return self.call("accounts.get_balances", [account["account"]["name"], True])

def transfer(self, account: Any, amount: int, resource_address: Any, destination_publickey: Any, fee: Optional[int]):
def transfer(self, account: Any, amount: int, resource_address: Any, destination_publickey: Any, fee: Optional[int], dry_run: bool = False):
id = stats.start_run("accounts.transfer")
res = self.call("accounts.transfer", [account["account"]["name"], amount, resource_address, destination_publickey, fee])
stats.end_run(id)
Expand Down
4 changes: 2 additions & 2 deletions Processes/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def __init__(self, indexer_id: int, base_node_grpc_port: int, peers=[]):
"indexer.p2p.allow_test_addresses=true",
"-p",
f"{NETWORK}.p2p.seeds.peer_seeds={','.join(peers)}",
"-p",
f"indexer.p2p.public_addresses={self.public_adress}",
# "-p",
# f"indexer.p2p.public_addresses={self.public_adress}",
"-p",
f"indexer.json_rpc_address={self.json_listen_address}",
"-p",
Expand Down
27 changes: 15 additions & 12 deletions Processes/validator_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def __init__(self, base_node_grpc_port, wallet_grpc_port, node_id, peers=[]):
f"{NETWORK}.p2p.seeds.peer_seeds={','.join(peers)}",
# "-p",
# f"validator_node.p2p.public_address={self.public_adress}",
"-p",
f"validator_node.public_address={self.public_address}",
# "-p",
# f"validator_node.public_address={self.public_address}",
"-p",
f"validator_node.json_rpc_address={self.json_listen_address}",
"-p",
Expand All @@ -97,14 +97,15 @@ def __init__(self, base_node_grpc_port, wallet_grpc_port, node_id, peers=[]):
self.jrpc_client = JrpcValidatorNode(f"http://{self.json_connect_address}")

def get_address(self) -> str:
validator_node_id_file_name = os.path.join(DATA_FOLDER, self.name, NETWORK, "validator_node_id.json")
while not os.path.exists(validator_node_id_file_name):
time.sleep(1)
f = open(validator_node_id_file_name, "rt")
content = "".join(f.readlines())
node_id, public_key, public_address = re.search(r'"node_id":"(.*?)","public_key":"(.*?)".*"public_addresses":\["(.*?)"', content).groups()
public_address = public_address.replace("\\/", "/")
return f"{public_key}::{public_address}"
return ""
# validator_node_id_file_name = os.path.join(DATA_FOLDER, self.name, NETWORK, "validator_node_id.json")
# while not os.path.exists(validator_node_id_file_name):
# time.sleep(1)
# f = open(validator_node_id_file_name, "rt")
# content = "".join(f.readlines())
# node_id, public_key, public_address = re.search(r'"node_id":"(.*?)","public_key":"(.*?)".*"public_addresses":\["(.*?)"', content).groups()
# public_address = public_address.replace("\\/", "/")
# return f"{public_key}::{public_address}"

def register(self, local_ip: str):
if USE_BINARY_EXECUTABLE:
Expand All @@ -123,6 +124,8 @@ def register(self, local_ip: str):
*run,
"--vn-daemon-jrpc-endpoint",
f"/ip4/{local_ip}/tcp/{self.json_rpc_port}",
# "--validator-maturity",
# "1000",
"vn",
"register",
"d6d21f5c18406b390ce405fd21773d90bddb221b38c950dccf8f26840937004d",
Expand All @@ -133,12 +136,12 @@ def register(self, local_ip: str):
)
if self.cli_process != 0:
raise Exception("Validator node cli registration process failed")
print(f"Validator node register: {self.cli_process}")
print(f"Validator node register: ok")
else:
self.cli_process = SubprocessWrapper.call(self.exec_cli)
print(f"Validator node register: {self.cli_process}")
if self.cli_process != 0:
raise Exception("Validator node cli registration process failed")
print(f"Validator node register: ok")

def get_info_for_ui(self):
return {"http": self.http_connect_address, "jrpc": self.json_connect_address}
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def cli_loop():


# this is how many times we send the funds back and forth for each of two wallets
def stress_test(num_of_tx: int = 1):
def stress_test(num_of_tx: int = 1, dry_run: bool = True):
# The dry run is ignored for now, once there will be a change in the PR I will update this.
global base_node, miner, tari_connector_sample, server
global total_num_of_tx
total_num_of_tx = 0
Expand All @@ -234,7 +235,7 @@ def send_tx(account0: int, account1: int):
print(f"tx {account0} -> {account1} ({i})")
# dan0.jrpc_client.confidential_transfer(acc0, 1, res_addr, public_key1, 2000)
# dan1.jrpc_client.confidential_transfer(acc1, 1, res_addr, public_key0, 2000)
dan0.jrpc_client.transfer(acc0, 2000, res_addr, public_key1, 2000)
dan0.jrpc_client.transfer(acc0, 2000, res_addr, public_key1, 2000, dry_run)
total_num_of_tx += 1
# dan_wallets[dst_id].jrpc_client.transfer(dst_account, 1, res_addr, src_public_key, 2000)

Expand Down Expand Up @@ -419,9 +420,9 @@ def spawn_wallet(d_id: int):
def create_account(i: int, amount: int):
name = {"Name": f"TestAccount_{i}"}
dan_wallet_jrpc = dan_wallets[i % SPAWN_WALLETS].jrpc_client
print(f"Account {name} creation started")
print(f"Account {name["Name"]} creation started")
dan_wallet_jrpc.create_free_test_coins(name, amount)
print(f"Account {name} created")
print(f"Account {name["Name"]} created")

threads.set_semaphore_limit(1)
for i in range(CREATE_ACCOUNTS):
Expand Down

0 comments on commit 62378e2

Please sign in to comment.