diff --git a/tests/pubsub/dummy_account_node.py b/tests/pubsub/dummy_account_node.py index 930dc57..0773533 100644 --- a/tests/pubsub/dummy_account_node.py +++ b/tests/pubsub/dummy_account_node.py @@ -37,6 +37,7 @@ class DummyAccountNode(): We use create as this serves as a factory function and allows us to use async await, unlike the init function """ + print ("**DUMMY** CREATE ACCOUNT NODE") self = DummyAccountNode() libp2p_node = await new_node(transport_opt=["/ip4/127.0.0.1/tcp/0"]) @@ -54,14 +55,17 @@ class DummyAccountNode(): """ while True: incoming = await self.q.get() - rpc_incoming = rpc_pb2.RPC() - rpc_incoming.ParseFromString(incoming) - for message in rpc_incoming.publish: - msg_comps = message.split(",") - if msg_comps[0] == "send": - self.handle_send_crypto(msg_comps[1], msg_comps[2], int(msg_comps[3])) - elif msg_comps[0] == "set": - self.handle_set_crypto_for_user(msg_comps[1], int(msg_comps[2])) + print ("**DUMMY** HANDLE INCOMING") + print (incoming) + print ("========================") + + msg_comps = incoming.data.decode('utf-8').split(",") + print (msg_comps) + print ("--------") + if msg_comps[0] == "send": + self.handle_send_crypto(msg_comps[1], msg_comps[2], int(msg_comps[3])) + elif msg_comps[0] == "set": + self.handle_set_crypto(msg_comps[1], int(msg_comps[2])) async def setup_crypto_networking(self): """ @@ -103,6 +107,7 @@ class DummyAccountNode(): :param dest_user: user to send crypto to :param amount: amount of crypto to send """ + print ("**DUMMY** IN HANDLE SEND CRYPTO") if source_user in self.balances: self.balances[source_user] -= amount else: @@ -113,12 +118,15 @@ class DummyAccountNode(): else: self.balances[dest_user] = amount - def handle_set_crypto_for_user(self, dest_user, amount): + def handle_set_crypto(self, dest_user, amount): """ Handle incoming set_crypto message :param dest_user: user to set crypto for :param amount: amount of crypto """ + print ("**DUMMY** IN HANDLE SET CRYPTO") + print (type (dest_user)) + print (amount) self.balances[dest_user] = amount def get_balance(self, user): @@ -127,6 +135,9 @@ class DummyAccountNode(): :param user: user to get balance for :return: balance of user """ + print ("GET BALACNCE") + print (user) + print (self.balances) if user in self.balances: return self.balances[user] else: @@ -155,7 +166,4 @@ def generate_RPC_packet(origin_id, topics, msg_content, msg_id): )]) packet.publish.extend([message]) - print ("HEYHO") - print (packet) - return packet