Skip to content

Commit

Permalink
Align Forward message to RFC 0094: msg should be JSON dict, not a str…
Browse files Browse the repository at this point in the history
…ing.

Signed-off-by: Sergey Minaev <[email protected]>
  • Loading branch information
jovfer committed Dec 24, 2019
1 parent 3582fdc commit 44ed4af
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aries_cloudagent/protocols/routing/messages/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Meta:
message_type = FORWARD
schema_class = "ForwardSchema"

def __init__(self, *, to: str = None, msg: str = None, **kwargs):
def __init__(self, *, to: str = None, msg: dict = None, **kwargs):
"""
Initialize forward message object.
Expand All @@ -41,4 +41,4 @@ class Meta:
model_class = Forward

to = fields.Str(required=True)
msg = fields.Str(required=True)
msg = fields.Dict(required=True)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_serialize(self, message_schema_dump):

class TestForwardSchema(TestCase):
def test_make_model(self):
message = Forward(to="to", msg="msg")
message = Forward(to="to", msg={"some": "msg"})
data = message.serialize()
model_instance = Forward.deserialize(data)
assert isinstance(model_instance, Forward)
1 change: 1 addition & 0 deletions aries_cloudagent/transport/pack_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ async def pack(
if routing_keys:
recip_keys = recipient_keys
for router_key in routing_keys:
message = json.loads(message.decode("utf-8"))
fwd_msg = Forward(to=recip_keys[0], msg=message)
# Forwards are anon packed
recip_keys = [router_key]
Expand Down

0 comments on commit 44ed4af

Please sign in to comment.