X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fbindings%2Frmr-python%2Ftests%2Ftest_rmr.py;h=cd0754529512c5a9d653c2df04e40b6f6b686d51;hb=acb31bd5a9daecc76e228bac2df4cb3a09f55f72;hp=e43b170b6ba4bb9db3fd7c2719c79470c1d4b4e5;hpb=758fb1cd425aaa6d733f549348ee37974212009b;p=ric-plt%2Flib%2Frmr.git diff --git a/src/bindings/rmr-python/tests/test_rmr.py b/src/bindings/rmr-python/tests/test_rmr.py index e43b170..cd07545 100644 --- a/src/bindings/rmr-python/tests/test_rmr.py +++ b/src/bindings/rmr-python/tests/test_rmr.py @@ -287,3 +287,21 @@ def test_alloc_fancy(): assert summary["message state"] == 0 assert summary["message type"] == 14 assert summary["meid"] == b"asdf" + + +def test_resize_payload(): + """test the ability to insert a larger payload into an existing message""" + mtype = 99 + subid = 100 + + mbuf = rmr.rmr_alloc_msg(MRC_SEND, 25) # allocate buffer with small payload + mbuf.contents.mtype = mtype # type and sub-id should not change + mbuf.contents.sub_id = subid + + long_payload = b"This is a long payload that should force the message buffer to be reallocated" + rmr.set_payload_and_length(long_payload, mbuf) + summary = rmr.message_summary(mbuf) + assert summary["payload max size"] >= len(long_payload) # RMR may allocate a larger payload space + assert summary["payload length"] == len(long_payload) # however, the length must be exactly the same + assert summary["message type"] == mtype # both mtype and sub-id should be preserved in new + assert summary["subscription id"] == subid