Skip to content
Snippets Groups Projects
Commit e63d5c66 authored by Jono Wenger's avatar Jono Wenger
Browse files

Fix Test_asymmetricClient_Smoke

parent b2ae067f
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!386Channels restructure,!340Project/channels
......@@ -7,7 +7,6 @@
package broadcast
/*
import (
"bytes"
"fmt"
......@@ -57,23 +56,25 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
rngGen := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG)
cName := "MyChannel"
cDesc := "This is my channel about stuff."
packetPayloadLength := newMockCmix(cMixHandler).GetMaxMessageLength()
channel, pk, _ := crypto.NewChannel(cName, cDesc,
newMockCmix(cMixHandler).GetMaxMessageLength(), rngGen.GetStream())
channel, pk, _ := crypto.NewChannel(
cName, cDesc, packetPayloadLength, rngGen.GetStream())
cid := channel.ReceptionID
// must mutate cMixHandler such that it's processorMap contains a
// Must mutate cMixHandler such that it's processorMap contains a
// message.Processor
processor := newMockProcessor()
mockProc := newMockProcessor()
cMixHandler.processorMap[*cid] = make(map[string][]message.Processor)
cMixHandler.processorMap[*cid]["AsymmBcast"] = []message.Processor{processor}
cMixHandler.processorMap[*cid]["AsymmBcast"] = []message.Processor{mockProc}
const n = 1
cbChans := make([]chan []byte, n)
clients := make([]Channel, n)
for i := range clients {
cbChan := make(chan []byte, 10)
cb := func(payload []byte, _ receptionID.EphemeralIdentity,
_ rounds.Round) {
cb := func(
payload []byte, _ receptionID.EphemeralIdentity, _ rounds.Round) {
cbChan <- payload
}
......@@ -90,7 +91,7 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
cbChans[i] = cbChan
clients[i] = s
// Test that Get returns the expected channel
// Test that Channel.Get returns the expected channel
if !reflect.DeepEqual(s.Get(), channel) {
t.Errorf("Cmix %d returned wrong channel."+
"\nexpected: %+v\nreceived: %+v", i, channel, s.Get())
......@@ -163,4 +164,4 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
}
wg.Wait()
}*/
}
......@@ -8,12 +8,9 @@
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"
......@@ -24,19 +21,8 @@ import (
"gitlab.com/elixxir/primitives/format"
)
// newRsaPubKey generates a new random RSA public key for testing.
func newRsaPubKey(seed int64, t *testing.T) *rsa.PublicKey {
prng := rand.New(rand.NewSource(seed))
privKey, err := rsa.GenerateKey(prng, 64)
if err != nil {
t.Errorf("Failed to generate new RSA key: %+v", err)
}
return privKey.GetPublic()
}
////////////////////////////////////////////////////////////////////////////////
// Mock cMix //
// Mock cMix //
////////////////////////////////////////////////////////////////////////////////
type mockCmixHandler struct {
......@@ -58,18 +44,19 @@ type mockCmix struct {
func newMockCmix(handler *mockCmixHandler) *mockCmix {
return &mockCmix{
numPrimeBytes: 4096,
numPrimeBytes: 4096 / 8,
health: true,
handler: handler,
}
}
func (m *mockCmix) GetMaxMessageLength() int {
return format.NewMessage(m.numPrimeBytes * 2).ContentsSize()
return format.NewMessage(m.numPrimeBytes).ContentsSize()
}
func (m *mockCmix) SendWithAssembler(recipient *id.ID, assembler cmix.MessageAssembler,
cmixParams cmix.CMIXParams) (rounds.Round, ephemeral.Id, error) {
func (m *mockCmix) SendWithAssembler(recipient *id.ID,
assembler cmix.MessageAssembler, _ cmix.CMIXParams) (
rounds.Round, ephemeral.Id, error) {
fingerprint, service, payload, mac, err := assembler(42)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment