def test_query_broker_tests(): broker = createBroker(2) vFed1, fedinfo1 = createValueFederate(1, "fed0") vFed2, fedinfo2 = createValueFederate(1, "fed1") core = h.helicsFederateGetCoreObject(vFed1) q1 = h.helicsCreateQuery("root", "federates") res = h.helicsQueryCoreExecute(q1, core) name1 = h.helicsFederateGetName(vFed1) name2 = h.helicsFederateGetName(vFed2) try: assert f"[{name1};{name2}]" == res except AssertionError: assert [name1, name2] == res res = h.helicsQueryExecute(q1, vFed1) try: assert f"[{name1};{name2}]" == res except AssertionError: assert [name1, name2] == res h.helicsFederateEnterInitializingModeAsync(vFed1) h.helicsFederateEnterInitializingMode(vFed2) h.helicsFederateEnterInitializingModeComplete(vFed1) h.helicsQueryFree(q1) h.helicsCoreFree(core) h.helicsFederateFinalizeAsync(vFed1) h.helicsFederateFinalize(vFed2) h.helicsFederateFinalizeComplete(vFed1) destroyFederate(vFed1, fedinfo1) destroyFederate(vFed2, fedinfo2) destroyBroker(broker)
def test_valuefederate_test_info_filed(): broker = createBroker() vFed, fedinfo = createValueFederate(1, "fed0") h.helicsFederateSetFlagOption(vFed, h.HELICS_HANDLE_OPTION_CONNECTION_OPTIONAL, True) # register the publications/subscriptions subid1 = h.helicsFederateRegisterSubscription(vFed, "sub1", "") pubid1 = h.helicsFederateRegisterTypePublication(vFed, "pub1", "string", "") pubid2 = h.helicsFederateRegisterGlobalTypePublication(vFed, "pub2", "string", "") # Set info fields h.helicsInputSetInfo(subid1, "sub1_test") h.helicsPublicationSetInfo(pubid1, "pub1_test") h.helicsPublicationSetInfo(pubid2, "pub2_test") h.helicsFederateEnterExecutingMode(vFed) assert h.helicsInputGetInfo(subid1) == "sub1_test" assert h.helicsPublicationGetInfo(pubid1) == "pub1_test" assert h.helicsPublicationGetInfo(pubid2) == "pub2_test" cr = h.helicsFederateGetCoreObject(vFed) h.helicsFederateFinalize(vFed) wait = h.helicsCoreWaitForDisconnect(cr, 70) if wait is False: wait = h.helicsCoreWaitForDisconnect(cr, 500) assert wait is True destroyFederate(vFed, fedinfo) destroyBroker(broker)
def test_query_federate_tests(): broker = createBroker(2) vFed1, fedinfo1 = createValueFederate(1, "fed0") vFed2, fedinfo2 = createValueFederate(1, "fed1") h.helicsFederateRegisterGlobalTypePublication(vFed1, "pub1", "double", "") h.helicsFederateRegisterTypePublication(vFed1, "pub2", "double", "") h.helicsFederateRegisterTypePublication(vFed2, "pub3", "double", "") h.helicsFederateEnterInitializingModeAsync(vFed1) h.helicsFederateEnterInitializingMode(vFed2) h.helicsFederateEnterInitializingModeComplete(vFed1) core = h.helicsFederateGetCoreObject(vFed1) q1 = h.helicsCreateQuery("Testfed0", "publications") res = h.helicsQueryCoreExecute(q1, core) try: assert res == "[pub1;Testfed0/pub2]" except: assert res == ["pub1", "Testfed0/pub2"] # res = h.helicsQueryExecute(q1, vFed2) # assert res == "[pub1;Testfed0/pub2]" h.helicsQueryFree(q1) # q1 = h.helicsCreateQuery("Testfed1", "isinit") # res = h.helicsQueryExecute(q1, vFed1) # assert res, "True" # h.helicsQueryFree(q1) # q1 = h.helicsCreateQuery("Testfed1", "publications") # res = h.helicsQueryExecute(q1, vFed1) # assert res == "[Testfed1/pub3]" # h.helicsQueryFree(q1) h.helicsCoreFree(core) h.helicsFederateFinalizeAsync(vFed1) h.helicsFederateFinalize(vFed2) h.helicsFederateFinalizeComplete(vFed1) destroyFederate(vFed1, fedinfo1) destroyFederate(vFed2, fedinfo2) destroyBroker(broker)
def test_bad_input_filter_core_tests(): broker = createBroker(1) mFed1, fedinfo = createMessageFederate(1, "test") cr = h.helicsFederateGetCoreObject(mFed1) filt1 = h.helicsCoreRegisterFilter(cr, h.HELICS_FILTER_TYPE_DELAY, "filt1") # @test_throws h.HELICSErrorRegistrationFailure with pt.raises(h.HelicsException): filt2 = h.helicsCoreRegisterFilter(cr, h.HELICS_FILTER_TYPE_DELAY, "filt1") h.helicsFilterSetOption(filt1, h.HELICS_HANDLE_OPTION_CONNECTION_OPTIONAL, True) assert h.helicsFilterGetOption(filt1, h.HELICS_HANDLE_OPTION_CONNECTION_OPTIONAL) h.helicsFederateFinalize(mFed1) h.helicsCoreDestroy(cr) destroyFederate(mFed1, fedinfo) destroyBroker(broker)
def test_bad_inputs_core_link(): broker = createBroker(1) vFed1, fedinfo = createValueFederate(1, "fed0") # register the publications h.helicsFederateRegisterGlobalTypePublication(vFed1, "pub1", "custom1", "") h.helicsFederateRegisterTypeInput(vFed1, "inp1", "custom2", "") fed2 = h.helicsGetFederateByName(h.helicsFederateGetName(vFed1)) assert h.helicsFederateGetName(fed2) == h.helicsFederateGetName(vFed1) # @test_throws h.HELICSErrorInvalidArgument with pt.raises(h.HelicsException): fed3 = h.helicsGetFederateByName("fed_unknown") cr = h.helicsFederateGetCoreObject(vFed1) h.helicsCoreDataLink(cr, "pub1", "fed0/inp1") # @test_throws h.HELICSErrorInvalidArgument with pt.raises(h.HelicsException): h.helicsCoreMakeConnections(cr, "unknownfile.json") # TODO: This test should throw an error # @test_throws h.HELICSErrorInvalidArgument h.helicsCoreDataLink(cr, "pub1", "") # @test_broken False cr2 = h.helicsCoreClone(cr) assert h.helicsCoreGetAddress(cr2) == h.helicsCoreGetAddress(cr) # TODO: this should error as well # h.helicsFederateEnterExecutingMode(vFed1) # @test_broken False h.helicsFederateFinalize(vFed1) destroyFederate(vFed1, fedinfo) destroyBroker(broker)
def test_filter_test_types_clone_test_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", 2.0) p1 = h.helicsFederateRegisterGlobalEndpoint(sFed, "src", "") _ = h.helicsFederateRegisterGlobalEndpoint(dFed, "dest", "") _ = h.helicsFederateRegisterGlobalEndpoint(dcFed, "cm", "") f1 = h.helicsFederateRegisterGlobalCloningFilter(dcFed, "filt1") h.helicsFilterAddDeliveryEndpoint(f1, "cm") cr = h.helicsFederateGetCoreObject(sFed) h.helicsCoreAddDestinationFilterToEndpoint(cr, "filt1", "dest") h.helicsCoreAddDestinationFilterToEndpoint(cr, "", "dest") h.helicsCoreFree(cr) h.helicsFederateEnterExecutingModeAsync(sFed) h.helicsFederateEnterExecutingModeAsync(dcFed) h.helicsFederateEnterExecutingMode(dFed) h.helicsFederateEnterExecutingModeComplete(sFed) h.helicsFederateEnterExecutingModeComplete(dcFed) q = h.helicsCreateQuery("", "filtered_endpoints") filteredEndpoints = h.helicsQueryExecute(q, dFed) assert "cloningdestFilter" 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.helicsFederateFinalize(sFed) # TODO: implement threading # auto dFedExec = [&]() { # h.helicsFederateRequestTime(dFed, 1.0) # m2 = h.helicsEndpointGetMessage(p2) # h.helicsFederateFinalize(dFed, "") # } # h.helics_message m3 # auto dcFedExec = [&]() { # h.helicsFederateRequestTime(dcFed, 2.0) # auto res = h.helicsFederateHasMessage(dcFed) # if (res == h.helics_False) { # std::this_thread::sleep_for(std::chrono::milliseconds(50)) # h.helicsFederateRequestTime(dcFed, 4.0) # } # m3 = h.helicsEndpointGetMessage(p3) # h.helicsFederateFinalize(dcFed) # } # auto threaddFed = std::thread(dFedExec) # auto threaddcFed = std::thread(dcFedExec) # threaddFed.join() # (m2.source, "src") # (m2.original_source, "src") # (m2.dest, "dest") # (m2.length, static_cast<int64_t>(data.size())) # threaddcFed.join() # (m3.source, "src") # (m3.original_source, "src") # (m3.dest, "cm") # (m3.original_dest, "dest") # (m3.length, static_cast<int64_t>(data.size())) # (state = h.helicsFederateGetState(sFed)) # (state == h.helics_state_finalize) destroyFederate(sFed, fedinfo1) destroyFederate(dFed, fedinfo2) destroyFederate(dcFed, fedinfo3) 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_misc_api(): fedInfo1 = h.helicsCreateFederateInfo() h.helicsFederateInfoSetCoreInitString(fedInfo1, "-f 1") h.helicsFederateInfoSetCoreName(fedInfo1, "core3") h.helicsFederateInfoSetCoreType(fedInfo1, 3) h.helicsFederateInfoSetCoreTypeFromString(fedInfo1, "zmq") h.helicsFederateInfoSetFlagOption(fedInfo1, 1, True) h.helicsFederateInfoSetTimeProperty(fedInfo1, h.HELICS_PROPERTY_TIME_INPUT_DELAY, 1.0) h.helicsFederateInfoSetIntegerProperty(fedInfo1, h.HELICS_PROPERTY_INT_LOG_LEVEL, 1) h.helicsFederateInfoSetIntegerProperty( fedInfo1, h.HELICS_PROPERTY_INT_MAX_ITERATIONS, 100) h.helicsFederateInfoSetTimeProperty(fedInfo1, h.HELICS_PROPERTY_TIME_OUTPUT_DELAY, 1.0) h.helicsFederateInfoSetTimeProperty(fedInfo1, h.HELICS_PROPERTY_TIME_PERIOD, 1.0) h.helicsFederateInfoSetTimeProperty(fedInfo1, h.HELICS_PROPERTY_TIME_DELTA, 1.0) h.helicsFederateInfoSetTimeProperty(fedInfo1, h.HELICS_PROPERTY_TIME_OFFSET, 0.1) h.helicsFederateInfoFree(fedInfo1) broker3 = h.helicsCreateBroker("zmq", "broker3", "--federates 1 --loglevel 1") fedInfo2 = h.helicsCreateFederateInfo() coreInitString = "--federates 1" h.helicsFederateInfoSetCoreInitString(fedInfo2, coreInitString) h.helicsFederateInfoSetCoreTypeFromString(fedInfo2, "zmq") h.helicsFederateInfoSetIntegerProperty(fedInfo2, h.HELICS_PROPERTY_INT_LOG_LEVEL, 1) h.helicsFederateInfoSetTimeProperty(fedInfo2, h.HELICS_PROPERTY_TIME_DELTA, 1.0) fed1 = h.helicsCreateCombinationFederate("fed1", fedInfo2) fed2 = h.helicsFederateClone(fed1) _ = h.helicsGetFederateByName("fed1") h.helicsFederateSetFlagOption(fed2, 1, False) h.helicsFederateSetTimeProperty(fed2, h.HELICS_PROPERTY_TIME_INPUT_DELAY, 1.0) h.helicsFederateSetIntegerProperty(fed1, h.HELICS_PROPERTY_INT_LOG_LEVEL, 1) h.helicsFederateSetIntegerProperty(fed2, h.HELICS_PROPERTY_INT_MAX_ITERATIONS, 100) h.helicsFederateSetTimeProperty(fed2, h.HELICS_PROPERTY_TIME_OUTPUT_DELAY, 1.0) h.helicsFederateSetTimeProperty(fed2, h.HELICS_PROPERTY_TIME_PERIOD, 0.0) h.helicsFederateSetTimeProperty(fed2, h.HELICS_PROPERTY_TIME_DELTA, 1.0) _ = h.helicsFederateRegisterCloningFilter(fed1, "fed1/Ep1") fed1DestinationFilter = h.helicsFederateRegisterFilter( fed1, h.HELICS_FILTER_TYPE_DELAY, "fed1DestinationFilter") h.helicsFilterAddDestinationTarget(fed1DestinationFilter, "Ep2") ep1 = h.helicsFederateRegisterEndpoint(fed1, "Ep1", "string") ep2 = h.helicsFederateRegisterGlobalEndpoint(fed1, "Ep2", "string") pub1 = h.helicsFederateRegisterGlobalPublication(fed1, "pub1", h.HELICS_DATA_TYPE_DOUBLE, "") pub2 = h.helicsFederateRegisterGlobalTypePublication( fed1, "pub2", "complex", "") sub1 = h.helicsFederateRegisterSubscription(fed1, "pub1") sub2 = h.helicsFederateRegisterSubscription(fed1, "pub2") h.helicsInputAddTarget(sub2, "Ep2") pub3 = h.helicsFederateRegisterPublication(fed1, "pub3", h.HELICS_DATA_TYPE_STRING, "") pub1KeyString = h.helicsPublicationGetKey(pub1) pub1TypeString = h.helicsPublicationGetType(pub1) pub1UnitsString = h.helicsPublicationGetUnits(pub1) sub1KeyString = h.helicsSubscriptionGetKey(sub1) sub1UnitsString = h.helicsInputGetUnits(sub1) assert "pub1" == pub1KeyString assert "double" == pub1TypeString assert "" == pub1UnitsString assert "pub1" == sub1KeyString assert "" == sub1UnitsString fed1SourceFilter = h.helicsFederateRegisterFilter( fed1, h.HELICS_FILTER_TYPE_DELAY, "fed1SourceFilter") h.helicsFilterAddSourceTarget(fed1SourceFilter, "Ep2") h.helicsFilterAddDestinationTarget(fed1SourceFilter, "fed1/Ep1") h.helicsFilterRemoveTarget(fed1SourceFilter, "fed1/Ep1") h.helicsFilterAddSourceTarget(fed1SourceFilter, "Ep2") h.helicsFilterRemoveTarget(fed1SourceFilter, "Ep2") fed1SourceFilterNameString = h.helicsFilterGetName(fed1SourceFilter) assert fed1SourceFilterNameString == "fed1/fed1SourceFilter" sub3 = h.helicsFederateRegisterSubscription(fed1, "fed1/pub3", "") pub4 = h.helicsFederateRegisterTypePublication(fed1, "pub4", "int", "") sub4 = h.helicsFederateRegisterSubscription(fed1, "fed1/pub4", "") pub5 = h.helicsFederateRegisterGlobalTypePublication( fed1, "pub5", "boolean", "") sub5 = h.helicsFederateRegisterSubscription(fed1, "pub5", "") pub6 = h.helicsFederateRegisterGlobalPublication(fed1, "pub6", h.HELICS_DATA_TYPE_VECTOR, "") sub6 = h.helicsFederateRegisterSubscription(fed1, "pub6", "") pub7 = h.helicsFederateRegisterGlobalPublication( fed1, "pub7", h.HELICS_DATA_TYPE_NAMED_POINT, "") sub7 = h.helicsFederateRegisterSubscription(fed1, "pub7", "") assert """helics.HelicsPublication(name = "pub1", type = "double", units = "", info = "")""" in repr( pub1) assert """helics.HelicsPublication(name = "pub2", type = "complex", units = "", info = "")""" in repr( pub2) assert """helics.HelicsPublication(name = "fed1/pub3", type = "string", units = "", info = "")""" in repr( pub3) assert """helics.HelicsPublication(name = "fed1/pub4", type = "int", units = "", info = "")""" in repr( pub4) assert """helics.HelicsPublication(name = "pub5", type = "boolean", units = "", info = "")""" in repr( pub5) assert """helics.HelicsPublication(name = "pub6", type = "double_vector", units = "", info = "")""" in repr( pub6) assert """helics.HelicsPublication(name = "pub7", type = "named_point", units = "", info = "")""" in repr( pub7) assert ( """helics.HelicsInput(name = "_input_18", units = "", injection_units = "", publication_type = "", type = "", target = "pub7", info = "")""" in repr(sub7)) h.helicsInputSetDefaultBoolean(sub5, False) h.helicsInputSetDefaultComplex(sub2, -9.9 + 2.5j) h.helicsInputSetDefaultDouble(sub1, 3.4) h.helicsInputSetDefaultInteger(sub4, 6) h.helicsInputSetDefaultNamedPoint(sub7, "hollow", 20.0) h.helicsInputSetDefaultString(sub3, "default") sub6Default = [3.4, 90.9, 4.5] h.helicsInputSetDefaultVector(sub6, sub6Default) h.helicsEndpointSubscribe(ep2, "fed1/pub3") h.helicsFederateEnterInitializingModeAsync(fed1) rs = h.helicsFederateIsAsyncOperationCompleted(fed1) if rs == 0: time.sleep(0.500) rs = h.helicsFederateIsAsyncOperationCompleted(fed1) if rs == 0: time.sleep(0.500) rs = h.helicsFederateIsAsyncOperationCompleted(fed1) if rs == 0: assert True is False h.helicsFederateEnterInitializingModeComplete(fed1) h.helicsFederateEnterExecutingModeAsync(fed1) h.helicsFederateEnterExecutingModeComplete(fed1) assert ( """helics.HelicsInput(name = "_input_18", units = "", injection_units = "", publication_type = "named_point", type = "", target = "pub7", info = "")""" in repr(sub7)) mesg1 = h.helicsFederateCreateMessage(fed1) h.helicsMessageSetString(mesg1, "Hello") h.helicsMessageSetSource(mesg1, "fed1/Ep1") h.helicsMessageSetOriginalSource(mesg1, "fed1/Ep1") h.helicsMessageSetDestination(mesg1, "Ep2") h.helicsMessageSetOriginalDestination(mesg1, "Ep2") h.helicsEndpointSendMessage(ep1, mesg1) mesg1 = h.helicsFederateCreateMessage(fed1) h.helicsMessageSetString(mesg1, "There") h.helicsMessageSetSource(mesg1, "fed1/Ep1") h.helicsMessageSetOriginalSource(mesg1, "fed1/Ep1") h.helicsMessageSetDestination(mesg1, "Ep2") h.helicsMessageSetOriginalDestination(mesg1, "Ep2") h.helicsEndpointSendMessage(ep1, mesg1) h.helicsEndpointSetDefaultDestination(ep2, "fed1/Ep1") ep1NameString = h.helicsEndpointGetName(ep1) ep1TypeString = h.helicsEndpointGetType(ep1) assert ep1NameString == "fed1/Ep1" assert ep1TypeString == "string" _ = h.helicsFederateGetCoreObject(fed1) fed1Time = h.helicsFederateGetCurrentTime(fed1) assert fed1Time == 0.0 fed1EndpointCount = h.helicsFederateGetEndpointCount(fed1) assert fed1EndpointCount == 2 fed1NameString = h.helicsFederateGetName(fed1) assert fed1NameString == "fed1" fed1State = h.helicsFederateGetState(fed1) assert fed1State == 2 fed1PubCount = h.helicsFederateGetPublicationCount(fed1) assert fed1PubCount == 7 fed1SubCount = h.helicsFederateGetInputCount(fed1) assert fed1SubCount == 7 h.helicsPublicationPublishBoolean(pub5, True) h.helicsPublicationPublishComplex(pub2, 5.6 + -0.67j) h.helicsPublicationPublishDouble(pub1, 457.234) h.helicsPublicationPublishInteger(pub4, 1) h.helicsPublicationPublishNamedPoint(pub7, "Blah Blah", 20.0) h.helicsPublicationPublishString(pub3, "Mayhem") pub6Vector = [4.5, 56.5] h.helicsPublicationPublishVector(pub6, pub6Vector) time.sleep(0.500) h.helicsFederateRequestTimeAsync(fed1, 1.0) returnTime = h.helicsFederateRequestTimeComplete(fed1) assert returnTime == 1.0 ep2MsgCount = h.helicsEndpointPendingMessages(ep2) assert ep2MsgCount == 2 ep2HasMsg = h.helicsEndpointHasMessage(ep2) assert ep2HasMsg == 1 msg2 = h.helicsEndpointGetMessage(ep2) assert h.helicsMessageGetTime(msg2) == 1.0 assert h.helicsMessageGetString(msg2) == "Hello" assert h.helicsMessageGetOriginalSource(msg2) == "fed1/Ep1" assert h.helicsMessageGetSource(msg2) == "fed1/Ep1" assert h.helicsMessageGetDestination(msg2) == "Ep2" assert h.helicsMessageGetOriginalDestination(msg2) == "Ep2" fed1MsgCount = h.helicsFederatePendingMessages(fed1) assert fed1MsgCount == 1 assert h.helicsFederateHasMessage(fed1) == 1 msg3 = h.helicsFederateGetMessage(fed1) assert h.helicsMessageGetTime(msg3) == 1.0 assert h.helicsMessageGetString(msg3) == "There" assert h.helicsMessageGetOriginalSource(msg3) == "fed1/Ep1" assert h.helicsMessageGetSource(msg3) == "fed1/Ep1" assert h.helicsMessageGetDestination(msg3) == "Ep2" assert h.helicsMessageGetOriginalDestination(msg3) == "Ep2" sub1Updated = h.helicsInputIsUpdated(sub1) # TODO: figure out why this test is broken assert sub1Updated is False # TODO: figure out why this test is broken assert h.helicsInputLastUpdateTime(sub2) == 0.0 # assert h.helicsInputGetComplex(sub2) == 5.6 - 0.67j # assert h.helicsInputGetDouble(sub1) == 457.234 # assert h.helicsInputGetInteger(sub4) == 1 sub7PointString, sub7DoubleValue = h.helicsInputGetNamedPoint(sub7) # assert sub7PointString == "Blah Blah" assert sub7DoubleValue == 20.0 # assert h.helicsInputGetBoolean(sub5) == True # assert h.helicsInputGetString(sub3) == "Mayhem" sub3ValueSize = h.helicsInputGetRawValueSize(sub3) # assert sub3ValueSize == 6 # assert h.helicsInputGetVector(sub6) == [4.5, 56.5] h.helicsFederateFinalize(fed1) h.helicsFederateFinalize(fed2) h.helicsFederateFree(fed1) h.helicsFederateFinalize(fed2) h.helicsFederateFree(fed2) h.helicsFederateInfoFree(fedInfo2) h.helicsBrokerDisconnect(broker3) h.helicsBrokerFree(broker3) h.helicsCleanupLibrary() h.helicsCloseLibrary()