summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkjnilsson <knilsson@pivotal.io>2019-07-08 12:00:22 +0100
committerkjnilsson <knilsson@pivotal.io>2019-07-08 12:00:22 +0100
commitd35182b709ed91b12b9b988ba28d1dcbf063370d (patch)
treecedcef62003e1c3346abea81b24786427b364a8d /test
parentdf5952afac610c0af8fd570baa3b16fada7fecd7 (diff)
downloadrabbitmq-server-git-d35182b709ed91b12b9b988ba28d1dcbf063370d.tar.gz
Future proof test_util:fake_pid/1
in OTP 23 pids hava new type tag: 88 (previously 103). To account for this copy whatever the local pid returns and insert that in the output binary.
Diffstat (limited to 'test')
-rw-r--r--test/test_util.erl15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/test_util.erl b/test/test_util.erl
index 7fcf247898..9a82b0ea1c 100644
--- a/test/test_util.erl
+++ b/test/test_util.erl
@@ -10,8 +10,19 @@ fake_pid(Node) ->
ThisNodeSize = size(term_to_binary(node())) + 1,
Pid = spawn(fun () -> ok end),
%% drop the local node data from a local pid
- <<_:ThisNodeSize/binary, LocalPidData/binary>> = term_to_binary(Pid),
+ <<Pre:ThisNodeSize/binary, LocalPidData/binary>> = term_to_binary(Pid),
S = size(NodeBin),
+ %% get the encoding type of the pid
+ <<_:8, Type:8/unsigned, _/binary>> = Pre,
%% replace it with the incoming node binary
- Final = <<131,103, 100, S:16/unsigned, NodeBin/binary, LocalPidData/binary>>,
+ Final = <<131, Type, 100, S:16/unsigned, NodeBin/binary, LocalPidData/binary>>,
binary_to_term(Final).
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+
+fake_pid_test() ->
+ _ = fake_pid(banana),
+ ok.
+
+-endif.