@@ -236,11 +236,43 @@ def send_json_with_retry(self, message):
236236 dummy = DummyPort ()
237237 concore .zmq_ports ["test_zmq" ] = dummy
238238
239+ # Reset simtime for predictable test behavior
240+ concore .simtime = 0
241+
239242 payload = [np .int64 (7 ), np .float64 (3.5 ), {"x" : np .float32 (1.25 )}]
240243 concore .write ("test_zmq" , "data" , payload )
241244
242245 assert dummy .sent is not None
243- assert dummy .sent == [7 , 3.5 , {"x" : 1.25 }]
244- assert not isinstance (dummy .sent [0 ], np .generic )
246+ # ZMQ write now prepends simtime (0 in this case) to match file-based write behavior
247+ assert dummy .sent == [0 , 7 , 3.5 , {"x" : 1.25 }]
248+ # Data values (after simtime) should be converted from numpy types
245249 assert not isinstance (dummy .sent [1 ], np .generic )
246- assert not isinstance (dummy .sent [2 ]["x" ], np .generic )
250+ assert not isinstance (dummy .sent [2 ], np .generic )
251+ assert not isinstance (dummy .sent [3 ]["x" ], np .generic )
252+
253+ def test_zmq_write_read_roundtrip (self ):
254+ """Test that ZMQ write+read returns original data without simtime prefix."""
255+ import concore
256+
257+ class DummyZMQPort :
258+ def __init__ (self ):
259+ self .buffer = None
260+
261+ def send_json_with_retry (self , message ):
262+ self .buffer = message
263+
264+ def recv_json_with_retry (self ):
265+ return self .buffer
266+
267+ dummy = DummyZMQPort ()
268+ concore .zmq_ports ["roundtrip_test" ] = dummy
269+
270+ # Reset simtime for predictable test behavior
271+ concore .simtime = 0
272+
273+ original_data = [1.5 , 2.5 , 3.5 ]
274+ concore .write ("roundtrip_test" , "data" , original_data )
275+
276+ # Read should return original data (simtime stripped)
277+ result = concore .read ("roundtrip_test" , "data" , "[]" )
278+ assert result == original_data
0 commit comments