def test_messagefederate_test_message_federate_send(mFed): epid1 = h.helicsFederateRegisterEndpoint(mFed, "ep1", "") epid2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "ep2", "random") h.helicsFederateSetTimeProperty(mFed, h.HELICS_PROPERTY_TIME_DELTA, 1.0) h.helicsFederateEnterExecutingMode(mFed) data = "random-data" h.helicsEndpointSendEventRaw(epid1, "ep2", data, 1.0) granted_time = h.helicsFederateRequestTime(mFed, 2.0) assert granted_time == 1.0 res = h.helicsFederateHasMessage(mFed) assert res is True res = h.helicsEndpointHasMessage(epid1) assert res is False res = h.helicsEndpointHasMessage(epid2) assert res is True message = h.helicsEndpointGetMessage(epid2) assert h.helicsMessageGetMessageID(message) == 55 assert h.helicsMessageIsValid(message) is True assert h.helicsMessageGetString(message) == "random-data" assert h.helicsMessageGetRawDataSize(message) == 11 assert h.helicsMessageGetOriginalDestination(message) == "" assert h.helicsMessageGetOriginalSource(message) == "TestA Federate/ep1" assert h.helicsMessageGetSource(message) == "TestA Federate/ep1" assert h.helicsMessageGetTime(message) == 1.0
def test_messagefederate_message_object_tests(mFed): epid1 = h.helicsFederateRegisterEndpoint(mFed, "ep1", "") epid2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "ep2", "random") h.helicsFederateSetTimeProperty(mFed, h.HELICS_PROPERTY_TIME_DELTA, 1.0) h.helicsFederateEnterExecutingMode(mFed) assert h.helicsFederateGetState(mFed) == h.HELICS_STATE_EXECUTION msg = h.helicsFederateCreateMessage(mFed) h.helicsMessageSetDestination(msg, "ep2") h.helicsMessageGetDestination(msg) == "ep2" h.helicsMessageSetData(msg, "".join(["a" for _ in range(0, 500)]).encode()) h.helicsMessageSetTime(msg, 0.0) h.helicsEndpointSendMessage(epid1, msg) t = h.helicsFederateRequestTime(mFed, 1.0) assert t == 1.0 assert h.helicsFederateHasMessage(mFed) is True assert h.helicsEndpointHasMessage(epid1) is False assert h.helicsEndpointHasMessage(epid2) is True msg = h.helicsEndpointGetMessage(epid2) assert h.helicsMessageGetRawDataSize(msg) == 500 # TODO: segfaults # print(h.helicsMessageGetRawData(msg)) # @test_broken False # segfaults # rawdata = h.helicsMessageGetRawDataPointer(msg) # assert Char(unsafe_load(Ptr{Cchar}(rdata), 245)) == 'a' h.helicsFederateFinalize(mFed) assert h.helicsFederateGetState(mFed) == h.HELICS_STATE_FINALIZE h.helicsMessageSetFlagOption(msg, 7, True) assert h.helicsMessageCheckFlag(msg, 7) is True h.helicsMessageClearFlags(msg) assert h.helicsMessageCheckFlag(msg, 7) is False h.helicsEndpointSetDefaultDestination(epid1, "ep2")
def test_filter_test_types_clone_test_broker_dest_connections(): broker = createBroker(3) sFed, fedinfo1 = createMessageFederate(1, "source", 1.0) dFed, fedinfo2 = createMessageFederate(1, "dest", 1.0) dcFed, fedinfo3 = createMessageFederate(1, "dest_clone", 1.0) p1 = h.helicsFederateRegisterGlobalEndpoint(sFed, "src", "") p2 = h.helicsFederateRegisterGlobalEndpoint(dFed, "dest", "") p3 = h.helicsFederateRegisterGlobalEndpoint(dcFed, "cm", "") f1 = h.helicsFederateRegisterGlobalCloningFilter(dcFed, "filt1") h.helicsFilterAddDeliveryEndpoint(f1, "cm") h.helicsBrokerAddDestinationFilterToEndpoint(broker, "filt1", "dest") h.helicsBrokerAddDestinationFilterToEndpoint(broker, "", "dest") h.helicsFederateEnterExecutingModeAsync(sFed) h.helicsFederateEnterExecutingModeAsync(dcFed) h.helicsFederateEnterExecutingMode(dFed) h.helicsFederateEnterExecutingModeComplete(sFed) h.helicsFederateEnterExecutingModeComplete(dcFed) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "dest", data) h.helicsFederateRequestTimeAsync(sFed, 1.0) h.helicsFederateRequestTimeAsync(dcFed, 1.0) h.helicsFederateRequestTime(dFed, 1.0) h.helicsFederateRequestTimeComplete(sFed) h.helicsFederateRequestTimeComplete(dcFed) assert h.helicsFederateHasMessage(dFed) is True m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "src" assert h.helicsMessageGetOriginalSource(m2) == "src" assert h.helicsMessageGetDestination(m2) == "dest" assert h.helicsMessageGetRawDataSize(m2) == len(data) h.helicsFederateFinalizeAsync(sFed) h.helicsFederateFinalizeAsync(dFed) # TODO: figure out why this test fails on CI # @test_broken False # assert h.helicsFederateHasMessage(dcFed) is False # h.helicsFederateRequestTime(dcFed, 2.0) # assert h.helicsFederateHasMessage(dcFed) is True # m2 = h.helicsEndpointGetMessage(p3) # assert h.helicsMessageGetSource(m2) == "src" # assert h.helicsMessageGetOriginalSource(m2) == "src" # assert h.helicsMessageGetDestination(m2) == "cm" # assert h.helicsMessageGetOriginalDestination(m2) == "dest" # assert h.helicsMessageGetRawDataSize(m2) == len(data) # _ = h.helicsFederateHasMessage(dcFed) h.helicsFederateFinalize(dcFed) h.helicsFederateFinalizeComplete(sFed) h.helicsFederateFinalizeComplete(dFed) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(sFed, fedinfo1) destroyFederate(dFed, fedinfo2) destroyFederate(dcFed, fedinfo3) destroyBroker(broker)
def test_filter_callback_test(): broker = createBroker(2) assert """helics.HelicsBroker(identifier = "mainbroker", address = "tcp://127.0.0.1:23404")""" in repr( broker) fFed, fedinfo1 = createMessageFederate(1, "filter", 1.0) mFed, fedinfo2 = createMessageFederate(1, "message", 1.0) h.helicsFederateSetFlagOption(mFed, h.HELICS_FLAG_IGNORE_TIME_MISMATCH_WARNINGS, True) p1 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port1") p2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port2", "") assert ( """helics.HelicsEndpoint(name = "port1", type = "", info = "", is_valid = True, default_destination = "", n_pending_messages = 0)""" in repr(p1)) assert ( """helics.HelicsEndpoint(name = "port2", type = "", info = "", is_valid = True, default_destination = "", n_pending_messages = 0)""" in repr(p2)) f1 = h.helicsFederateRegisterFilter(fFed, h.HELICS_FILTER_TYPE_CUSTOM, "filter1") f2 = h.helicsFederateRegisterFilter(mFed, h.HELICS_FILTER_TYPE_DELAY, "dfilter") h.helicsFilterAddSourceTarget(f1, "port1") assert 'name = "Testfilter/filter1"' in repr(f1) userdata = UserData(5) handle = h.ffi.new_handle(userdata) h.helicsFilterSetCustomCallback(f1, filterFunc1, handle) with pt.raises(h.HelicsException): h.helicsFilterSetCustomCallback(f2, filterFunc1, handle) assert ( """helics.HelicsMessageFederate(name = "Testfilter", state = HelicsFederateState.STARTUP, current_time = -9223372036.854776, n_publications = 0, n_subscriptions = 0, n_endpoints = 0, n_filters = 1, n_pending_messages = 0)""" in repr(fFed)) assert ( """helics.HelicsMessageFederate(name = "Testmessage", state = HelicsFederateState.STARTUP, current_time = -9223372036.854776, n_publications = 0, n_subscriptions = 0, n_endpoints = 2, n_filters = 1, n_pending_messages = 0)""" in repr(mFed)) h.helicsFederateEnterExecutingModeAsync(fFed) h.helicsFederateEnterExecutingMode(mFed) h.helicsFederateEnterExecutingModeComplete(fFed) assert ( """helics.HelicsMessageFederate(name = "Testfilter", state = HelicsFederateState.EXECUTION, current_time = 0.0, n_publications = 0, n_subscriptions = 0, n_endpoints = 0, n_filters = 1, n_pending_messages = 0)""" in repr(fFed)) assert ( """helics.HelicsMessageFederate(name = "Testmessage", state = HelicsFederateState.EXECUTION, current_time = 0.0, n_publications = 0, n_subscriptions = 0, n_endpoints = 2, n_filters = 1, n_pending_messages = 0)""" in repr(mFed)) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "port2", data) h.helicsFederateRequestTimeAsync(mFed, 1.0) h.helicsFederateRequestTime(fFed, 1.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsFederateHasMessage(mFed) is False h.helicsFederateRequestTimeAsync(mFed, 2.0) h.helicsFederateRequestTime(fFed, 2.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsEndpointHasMessage(p2) is False h.helicsFederateRequestTimeAsync(fFed, 3.0) h.helicsFederateRequestTime(mFed, 3.0) assert h.helicsEndpointHasMessage(p2) m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "port1" assert h.helicsMessageGetOriginalSource(m2) == "port1" assert h.helicsMessageGetDestination(m2) == "port2" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsMessageGetTime(m2) == 2.5 h.helicsFederateRequestTime(mFed, 3.0) h.helicsFederateRequestTimeComplete(fFed) h.helicsFederateFinalizeAsync(mFed) h.helicsFederateFinalize(fFed) h.helicsFederateFinalizeComplete(mFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(fFed, fedinfo1) destroyFederate(mFed, fedinfo2) destroyBroker(broker)
def test_filter_test_types_clone_test_connections(): broker = createBroker(3) sFed, fedinfo1 = createMessageFederate( 1, "source", 1.0, ) dFed, fedinfo2 = createMessageFederate(1, "dest", 1.0) dcFed, fedinfo3 = createMessageFederate(1, "dest_clone", 1.0) p1 = h.helicsFederateRegisterGlobalEndpoint(sFed, "src", "") p2 = h.helicsFederateRegisterGlobalEndpoint(dFed, "dest", "") p3 = h.helicsFederateRegisterGlobalEndpoint(dcFed, "cm", "") f1 = h.helicsFederateRegisterGlobalCloningFilter(dcFed, "filt1") h.helicsFilterAddDeliveryEndpoint(f1, "cm") cr = h.helicsFederateGetCoreObject(sFed) h.helicsCoreAddSourceFilterToEndpoint(cr, "filt1", "src") h.helicsCoreAddSourceFilterToEndpoint(cr, "", "src") h.helicsFederateEnterExecutingModeAsync(sFed) h.helicsFederateEnterExecutingModeAsync(dcFed) h.helicsFederateEnterExecutingMode(dFed) h.helicsFederateEnterExecutingModeComplete(sFed) h.helicsFederateEnterExecutingModeComplete(dcFed) q = h.helicsCreateQuery("", "filtered_endpoints") filteredEndpoints = h.helicsQueryExecute(q, sFed) assert "srcFilters" in str(filteredEndpoints) assert "(cloning)" in str(filteredEndpoints) h.helicsQueryFree(q) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "dest", data) h.helicsFederateRequestTimeAsync(sFed, 1.0) h.helicsFederateRequestTimeAsync(dcFed, 1.0) h.helicsFederateRequestTime(dFed, 1.0) h.helicsFederateRequestTimeComplete(sFed) h.helicsFederateRequestTimeComplete(dcFed) assert h.helicsFederateHasMessage(dFed) is True m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "src" assert h.helicsMessageGetOriginalSource(m2) == "src" assert h.helicsMessageGetDestination(m2) == "dest" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsFederateHasMessage(dcFed) is True m2 = h.helicsEndpointGetMessage(p3) assert h.helicsMessageGetSource(m2) == "src" assert h.helicsMessageGetOriginalSource(m2) == "src" assert h.helicsMessageGetDestination(m2) == "cm" assert h.helicsMessageGetOriginalDestination(m2) == "dest" assert h.helicsMessageGetRawDataSize(m2) == len(data) h.helicsFederateFinalizeAsync(sFed) h.helicsFederateFinalizeAsync(dFed) h.helicsFederateFinalize(dcFed) h.helicsFederateFinalizeComplete(sFed) h.helicsFederateFinalizeComplete(dFed) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(sFed, fedinfo1) destroyFederate(dFed, fedinfo2) destroyFederate(dcFed, fedinfo3) destroyBroker(broker)
def test_filter_test_types_clone_test(): broker = createBroker(3) sFed, fedinfo1 = createMessageFederate(1, "source", 1) dFed, fedinfo2 = createMessageFederate(1, "dest", 1) dcFed, fedinfo3 = createMessageFederate(1, "dest_clone", 1) p1 = h.helicsFederateRegisterGlobalEndpoint(sFed, "src", "") p2 = h.helicsFederateRegisterGlobalEndpoint(dFed, "dest", "") p3 = h.helicsFederateRegisterGlobalEndpoint(dcFed, "cm", "") f1 = h.helicsFederateRegisterCloningFilter(dcFed, "") h.helicsFilterAddDeliveryEndpoint(f1, "cm") h.helicsFilterAddSourceTarget(f1, "src") h.helicsFederateEnterExecutingModeAsync(sFed) h.helicsFederateEnterExecutingModeAsync(dcFed) h.helicsFederateEnterExecutingMode(dFed) h.helicsFederateEnterExecutingModeComplete(sFed) h.helicsFederateEnterExecutingModeComplete(dcFed) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_EXECUTION state = h.helicsFederateGetState(dcFed) assert state == h.HELICS_STATE_EXECUTION state = h.helicsFederateGetState(dFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "dest", data) h.helicsFederateRequestTimeAsync(sFed, 1.0) h.helicsFederateRequestTimeAsync(dcFed, 1.0) h.helicsFederateRequestTime(dFed, 1.0) h.helicsFederateRequestTimeComplete(sFed) h.helicsFederateRequestTimeComplete(dcFed) assert h.helicsFederateHasMessage(dFed) m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "src" assert h.helicsMessageGetOriginalSource(m2) == "src" assert h.helicsMessageGetDestination(m2) == "dest" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsFederateHasMessage(dcFed) m2 = h.helicsEndpointGetMessage(p3) assert h.helicsMessageGetSource(m2) == "src" assert h.helicsMessageGetOriginalSource(m2) == "src" assert h.helicsMessageGetDestination(m2) == "cm" assert h.helicsMessageGetOriginalDestination(m2) == "dest" assert h.helicsMessageGetRawDataSize(m2) == len(data) h.helicsFederateFinalizeAsync(sFed) h.helicsFederateFinalizeAsync(dFed) h.helicsFederateFinalize(dcFed) h.helicsFederateFinalizeComplete(sFed) h.helicsFederateFinalizeComplete(dFed) state = h.helicsFederateGetState(sFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(sFed, fedinfo1) destroyFederate(dFed, fedinfo2) destroyFederate(dcFed, fedinfo3) destroyBroker(broker)
def test_filter_test_types_message_filter_function3(): broker = createBroker(2) fFed, fedinfo1 = createMessageFederate(1, "filter", 1) mFed, fedinfo2 = createMessageFederate(1, "message", 1) p1 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port1", "") p2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port2", "random") f1 = h.helicsFederateRegisterGlobalFilter(fFed, h.HELICS_FILTER_TYPE_CUSTOM, "filter1") h.helicsFilterAddSourceTarget(f1, "port1") f2 = h.helicsFederateRegisterGlobalFilter(fFed, h.HELICS_FILTER_TYPE_DELAY, "filter2") h.helicsFilterAddSourceTarget(f2, "port1") h.helicsFederateRegisterEndpoint(fFed, "fout", "") f3 = h.helicsFederateRegisterFilter(fFed, h.HELICS_FILTER_TYPE_RANDOM_DELAY, "filter3") h.helicsFilterAddSourceTarget(f3, "filter0/fout") h.helicsFilterSet(f2, "delay", 2.5) h.helicsFederateEnterExecutingModeAsync(fFed) h.helicsFederateEnterExecutingMode(mFed) h.helicsFederateEnterExecutingModeComplete(fFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_EXECUTION data = "hello world".encode() h.helicsEndpointSendMessageRaw(p1, "port2", data) h.helicsFederateRequestTimeAsync(mFed, 1.0) h.helicsFederateRequestTime(fFed, 1.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsFederateHasMessage(mFed) is False h.helicsEndpointSendMessageRaw(p2, "port1", data) h.helicsFederateRequestTimeAsync(mFed, 2.0) h.helicsFederateRequestTime(fFed, 2.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsEndpointHasMessage(p2) is False # there may be something wrong here yet but this test isn't the one to find it and # this may prevent spurious errors for now. # std::this_thread::yield() h.helicsFederateRequestTimeAsync(mFed, 3.0) h.helicsFederateRequestTime(fFed, 3.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsEndpointHasMessage(p2) m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "port1" assert h.helicsMessageGetOriginalSource(m2) == "port1" assert h.helicsMessageGetDestination(m2) == "port2" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsMessageGetTime(m2) == 2.5 assert h.helicsEndpointHasMessage(p1) is True h.helicsFederateFinalize(mFed) h.helicsFederateFinalize(fFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(mFed, fedinfo1) destroyFederate(fFed, fedinfo2) destroyBroker(broker)
def test_filter_test_types_function2(): broker = createBroker(2) fFed, fedinfo1 = createMessageFederate(1, "filter") mFed, fedinfo2 = createMessageFederate(1, "message") p1 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port1", "") p2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port2", "") f1 = h.helicsFederateRegisterFilter(fFed, h.HELICS_FILTER_TYPE_DELAY, "filter1") h.helicsFilterAddSourceTarget(f1, "port1") h.helicsFilterSet(f1, "delay", 2.5) f2 = h.helicsFederateRegisterFilter(fFed, h.HELICS_FILTER_TYPE_DELAY, "filter2") h.helicsFilterAddSourceTarget(f2, "port2") h.helicsFilterSet(f2, "delay", 2.5) # this is expected to fail since a regular filter doesn't have a delivery endpoint # @test_throws h.HELICSErrorInvalidObject h.helicsFilterAddDeliveryEndpoint(f2, "port1") h.helicsFederateEnterExecutingModeAsync(fFed) h.helicsFederateEnterExecutingMode(mFed) h.helicsFederateEnterExecutingModeComplete(fFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "port2", data) h.helicsFederateRequestTimeAsync(mFed, 1.0) h.helicsFederateRequestTime(fFed, 1.0) h.helicsFederateRequestTimeComplete(mFed) res = h.helicsFederateHasMessage(mFed) assert res is False h.helicsEndpointSendMessageRaw(p2, "port1", data) h.helicsFederateRequestTimeAsync(mFed, 2.0) h.helicsFederateRequestTime(fFed, 2.0) h.helicsFederateRequestTimeComplete(mFed) assert h.helicsEndpointHasMessage(p2) is False # there may be something wrong here yet but this test isn't the one to find it and # this may prevent spurious errors for now. # std::this_thread::yield() h.helicsFederateRequestTime(mFed, 3.0) assert h.helicsEndpointHasMessage(p2) is True m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "port1" assert h.helicsMessageGetOriginalSource(m2) == "port1" assert h.helicsMessageGetDestination(m2) == "port2" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsMessageGetTime(m2) == 2.5 assert h.helicsEndpointHasMessage(p1) is False h.helicsFederateRequestTime(mFed, 4.0) assert h.helicsEndpointHasMessage(p1) is True h.helicsFederateFinalizeAsync(mFed) h.helicsFederateFinalize(fFed) h.helicsFederateFinalizeComplete(mFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(fFed, fedinfo1) destroyFederate(mFed, fedinfo2) destroyBroker(broker)
def test_filter_test_types_function_two_stage(): broker = createBroker(3) fFed, fedinfo1 = createMessageFederate(1, "filter") fFed2, fedinfo2 = createMessageFederate(1, "filter2") mFed, fedinfo3 = createMessageFederate(1, "message") p1 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port1", "") p2 = h.helicsFederateRegisterGlobalEndpoint(mFed, "port2", "") f1 = h.helicsFederateRegisterFilter(fFed, h.HELICS_FILTER_TYPE_DELAY, "filter1") h.helicsFilterAddSourceTarget(f1, "port1") h.helicsFilterSet(f1, "delay", 1.25) f2 = h.helicsFederateRegisterFilter(fFed2, h.HELICS_FILTER_TYPE_DELAY, "filter2") h.helicsFilterAddSourceTarget(f2, "port1") h.helicsFilterSet(f2, "delay", 1.25) h.helicsFederateEnterExecutingModeAsync(fFed) h.helicsFederateEnterExecutingModeAsync(fFed2) h.helicsFederateEnterExecutingMode(mFed) h.helicsFederateEnterExecutingModeComplete(fFed) h.helicsFederateEnterExecutingModeComplete(fFed2) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_EXECUTION data = "".join(["a" for _ in range(0, 500)]).encode() h.helicsEndpointSendMessageRaw(p1, "port2", data) h.helicsFederateRequestTimeAsync(mFed, 0.0) h.helicsFederateRequestTimeAsync(fFed, 1.0) h.helicsFederateRequestTime(fFed2, 1.0) h.helicsFederateRequestTimeComplete(mFed) h.helicsFederateRequestTimeComplete(fFed) assert h.helicsFederateHasMessage(mFed) is False h.helicsFederateRequestTimeAsync(mFed, 0.0) h.helicsFederateRequestTimeAsync(fFed2, 2.0) h.helicsFederateRequestTime(fFed, 2.0) h.helicsFederateRequestTimeComplete(mFed) h.helicsFederateRequestTimeComplete(fFed2) assert h.helicsEndpointHasMessage(p2) is False h.helicsFederateRequestTimeAsync(fFed, 3.0) h.helicsFederateRequestTimeAsync(fFed2, 3.0) h.helicsFederateRequestTime(mFed, 3.0) assert h.helicsEndpointHasMessage(p2) is True m2 = h.helicsEndpointGetMessage(p2) assert h.helicsMessageGetSource(m2) == "port1" assert h.helicsMessageGetOriginalSource(m2) == "port1" assert h.helicsMessageGetDestination(m2) == "port2" assert h.helicsMessageGetRawDataSize(m2) == len(data) assert h.helicsMessageGetTime(m2) == 2.5 h.helicsFederateRequestTimeComplete(fFed) h.helicsFederateRequestTimeComplete(fFed2) h.helicsFederateFinalizeAsync(mFed) h.helicsFederateFinalizeAsync(fFed) h.helicsFederateFinalize(fFed2) h.helicsFederateFinalizeComplete(mFed) h.helicsFederateFinalizeComplete(fFed) state = h.helicsFederateGetState(fFed) assert state == h.HELICS_STATE_FINALIZE destroyFederate(fFed, fedinfo1) destroyFederate(fFed2, fedinfo2) destroyFederate(mFed, fedinfo3) destroyBroker(broker)