From 1cbd909dc20c2af2258de696ef02172387f6986f Mon Sep 17 00:00:00 2001 From: zixuanzh Date: Sat, 30 Mar 2019 19:30:58 -0400 Subject: [PATCH] fix encoding issue --- libp2p/pubsub/floodsub.py | 3 +++ tests/pubsub/dummy_account_node.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libp2p/pubsub/floodsub.py b/libp2p/pubsub/floodsub.py index dd4dfc1..8b9ba1c 100644 --- a/libp2p/pubsub/floodsub.py +++ b/libp2p/pubsub/floodsub.py @@ -57,6 +57,9 @@ class FloodSub(IPubsubRouter): """ packet = rpc_pb2.RPC() + print ("IN FLOOODSUB PUBLISH") + print (message) + print ("++++++++++++++++") packet.publish.extend([message]) msg_sender = str(sender_peer_id) diff --git a/tests/pubsub/dummy_account_node.py b/tests/pubsub/dummy_account_node.py index de78211..930dc57 100644 --- a/tests/pubsub/dummy_account_node.py +++ b/tests/pubsub/dummy_account_node.py @@ -141,17 +141,21 @@ def generate_message_id(): def generate_RPC_packet(origin_id, topics, msg_content, msg_id): packet = rpc_pb2.RPC() - packet.publish.extend([rpc_pb2.Message( + message = rpc_pb2.Message( from_id=origin_id.encode('utf-8'), seqno=msg_id.encode('utf-8'), - data=msg_content.encode('utf-8'), - topicIDs=topics.encode('utf-8')) - ]) + data=msg_content.encode('utf-8') + ) for topic in topics: + message.topicIDs.extend([topic.encode('utf-8')]) packet.subscriptions.extend([rpc_pb2.RPC.SubOpts( subscribe=True, topicid = topic.encode('utf-8') )]) + packet.publish.extend([message]) + print ("HEYHO") + print (packet) + return packet