From 19f1732c47817e473f425eec02bb89a32a4751b3 Mon Sep 17 00:00:00 2001 From: David Stainton <dstainton@elixxir.io> Date: Mon, 29 Aug 2022 16:32:38 -0400 Subject: [PATCH] WIP --- ud/networkManager_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ud/networkManager_test.go b/ud/networkManager_test.go index 3af69d9ef..0277b1b84 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) { -- GitLab