diff --git a/ud/networkManager_test.go b/ud/networkManager_test.go index 3af69d9efaab5db21c45ea17f46c21313bb4e197..0277b1b84f8984ece01740520996374346203091 100644 --- a/ud/networkManager_test.go +++ b/ud/networkManager_test.go @@ -27,6 +27,41 @@ type testNetworkManager struct { responseProcessor message.Processor } +func (tnm *testNetworkManager) SendWithAssembler(recipient *id.ID, assembler cmix.MessageAssembler, + cmixParams cmix.CMIXParams) (id.Round, ephemeral.Id, error) { + + msg := format.NewMessage(tnm.instance.GetE2EGroup().GetP().ByteLen()) + + var rid id.Round = 123 + ephemeralId := new(ephemeral.Id) + + fingerprint, service, payload, mac, err := assembler(rid) + if err != nil { + return rid, *ephemeralId, err + } + + // Build message. Will panic if inputs are not correct. + msg.SetKeyFP(fingerprint) + msg.SetContents(payload) + msg.SetMac(mac) + msg.SetSIH(service.Hash(msg.GetContents())) + // If the recipient for a call to Send is UD, then this + // is the request pathway. Call the UD processor to simulate + // the UD picking up the request + if bytes.Equal(tnm.instance.GetFullNdf(). + Get().UDB.ID, + recipient.Bytes()) { + tnm.responseProcessor.Process(msg, receptionID.EphemeralIdentity{}, rounds.Round{}) + + } else { + // This should happen when the mock UD service Sends back a response. + // Calling process mocks up the requester picking up the response. + tnm.requestProcess.Process(msg, receptionID.EphemeralIdentity{}, rounds.Round{}) + } + + return 0, ephemeral.Id{}, nil +} + func (tnm *testNetworkManager) Send(recipient *id.ID, fingerprint format.Fingerprint, service message.Service, payload, mac []byte, cmixParams cmix.CMIXParams) (id.Round, ephemeral.Id, error) {