Skip to content
Snippets Groups Projects
Commit 3c29423c authored by David Stainton's avatar David Stainton
Browse files

Attempt to fix Test_asymmetricClient_Smoke

parent 7633d35e
Branches
Tags
5 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!371[Channel RSAtoPrivate] Implement Reverse Asymmetric in Client/Broadcast,!354Channels impl,!340Project/channels
......@@ -3,18 +3,22 @@ package broadcast
import (
"bytes"
"fmt"
"reflect"
"sync"
"testing"
"time"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/rounds"
crypto "gitlab.com/elixxir/crypto/broadcast"
cMixCrypto "gitlab.com/elixxir/crypto/cmix"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/signature/rsa"
"reflect"
"sync"
"testing"
"time"
"gitlab.com/elixxir/primitives/format"
)
// Tests that symmetricClient adheres to the Symmetric interface.
......@@ -23,6 +27,26 @@ var _ Channel = (*broadcastClient)(nil)
// Tests that symmetricClient adheres to the Symmetric interface.
var _ Client = (cmix.Client)(nil)
type mockProcessor struct {
messages []format.Message
}
var _ message.Processor = (*mockProcessor)(nil)
func newMockProcessor() *mockProcessor {
m := new(mockProcessor)
m.messages = make([]format.Message, 0)
return m
}
func (p *mockProcessor) Process(message format.Message, receptionID receptionID.EphemeralIdentity,
round rounds.Round) {
p.messages = append(p.messages, message)
}
func (p mockProcessor) String() string {
return "hello"
}
func Test_asymmetricClient_Smoke(t *testing.T) {
cMixHandler := newMockCmixHandler()
rngGen := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG)
......@@ -46,6 +70,13 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
RsaPubKey: cpubkey,
}
///
// must mutate cMixHandler such that it's processorMap contains a
// message.Processor
processor := newMockProcessor()
cMixHandler.processorMap[*cid] = make(map[string][]message.Processor)
cMixHandler.processorMap[*cid]["AsymmBcast"] = []message.Processor{processor}
const n = 5
cbChans := make([]chan []byte, n)
clients := make([]Channel, n)
......
......@@ -8,18 +8,20 @@
package broadcast
import (
"math/rand"
"sync"
"testing"
"time"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"math/rand"
"sync"
"testing"
"time"
)
// newRsaPubKey generates a new random RSA public key for testing.
......@@ -69,7 +71,10 @@ func (m *mockCmix) GetMaxMessageLength() int {
func (m *mockCmix) SendWithAssembler(recipient *id.ID, assembler cmix.MessageAssembler,
cmixParams cmix.CMIXParams) (id.Round, ephemeral.Id, error) {
fingerprint, service, payload, mac, _ := assembler(42)
fingerprint, service, payload, mac, err := assembler(42)
if err != nil {
panic(err)
}
msg := format.NewMessage(m.numPrimeBytes)
msg.SetContents(payload)
......@@ -78,6 +83,7 @@ func (m *mockCmix) SendWithAssembler(recipient *id.ID, assembler cmix.MessageAss
m.handler.Lock()
defer m.handler.Unlock()
for _, p := range m.handler.processorMap[*recipient][service.Tag] {
p.Process(msg, receptionID.EphemeralIdentity{}, rounds.Round{})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment