Skip to content
Snippets Groups Projects
Commit 876ab933 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

fixed more bugs

parent bc7e458f
No related branches found
No related tags found
2 merge requests!53Release,!46fixed more bugs
...@@ -179,7 +179,7 @@ Flags: ...@@ -179,7 +179,7 @@ Flags:
(default 1) (default 1)
--sendDelay uint The delay between sending the messages in ms --sendDelay uint The delay between sending the messages in ms
(default 500) (default 500)
--sendid uiverboseRoundTrackingnt Use precanned user id (must be between 1 and --sendid uint Use precanned user id (must be between 1 and
40, inclusive) 40, inclusive)
--slowPolling bool Enables polling for all network updates and RSA signed rounds. --slowPolling bool Enables polling for all network updates and RSA signed rounds.
Defaults to true (filtered updates with ECC signed rounds) if not set Defaults to true (filtered updates with ECC signed rounds) if not set
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"strings" "strings"
"sync"
"time" "time"
) )
...@@ -187,11 +188,14 @@ var rootCmd = &cobra.Command{ ...@@ -187,11 +188,14 @@ var rootCmd = &cobra.Command{
} }
paramsE2E := params.GetDefaultE2E() paramsE2E := params.GetDefaultE2E()
paramsUnsafe := params.GetDefaultUnsafe() paramsUnsafe := params.GetDefaultUnsafe()
wg := &sync.WaitGroup{}
sendCnt := int(viper.GetUint("sendCount")) sendCnt := int(viper.GetUint("sendCount"))
wg.Add(sendCnt)
go func(){
//sendDelay := time.Duration(viper.GetUint("sendDelay")) //sendDelay := time.Duration(viper.GetUint("sendDelay"))
for i := 0; i < sendCnt; i++ { for i := 0; i < sendCnt; i++ {
go func(){ go func(){
defer wg.Done()
fmt.Printf("Sending to %s: %s\n", recipientID, msgBody) fmt.Printf("Sending to %s: %s\n", recipientID, msgBody)
var roundIDs []id.Round var roundIDs []id.Round
var roundTimeout time.Duration var roundTimeout time.Duration
...@@ -225,6 +229,7 @@ var rootCmd = &cobra.Command{ ...@@ -225,6 +229,7 @@ var rootCmd = &cobra.Command{
} }
}() }()
} }
}()
// Wait until message timeout or we receive enough then exit // Wait until message timeout or we receive enough then exit
// TODO: Actually check for how many messages we've received // TODO: Actually check for how many messages we've received
...@@ -233,6 +238,7 @@ var rootCmd = &cobra.Command{ ...@@ -233,6 +238,7 @@ var rootCmd = &cobra.Command{
waitSecs := viper.GetUint("waitTimeout") waitSecs := viper.GetUint("waitTimeout")
waitTimeout := time.Duration(waitSecs) waitTimeout := time.Duration(waitSecs)
done := false done := false
for !done && expectedCnt != 0 { for !done && expectedCnt != 0 {
timeoutTimer := time.NewTimer(waitTimeout * time.Second) timeoutTimer := time.NewTimer(waitTimeout * time.Second)
select { select {
...@@ -255,7 +261,7 @@ var rootCmd = &cobra.Command{ ...@@ -255,7 +261,7 @@ var rootCmd = &cobra.Command{
if roundsNotepad != nil { if roundsNotepad != nil {
roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds()) roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds())
} }
wg.Wait()
err = client.StopNetworkFollower() err = client.StopNetworkFollower()
if err != nil { if err != nil {
jww.WARN.Printf( jww.WARN.Printf(
......
...@@ -120,6 +120,8 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager, ...@@ -120,6 +120,8 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager,
MessageType: message.KeyExchangeConfirm, MessageType: message.KeyExchangeConfirm,
} }
//send the message under the key exchange //send the message under the key exchange
e2eParams := params.GetDefaultE2E() e2eParams := params.GetDefaultE2E()
...@@ -150,13 +152,13 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager, ...@@ -150,13 +152,13 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager,
"transmit %v/%v paritions: %v round failures, %v timeouts", "transmit %v/%v paritions: %v round failures, %v timeouts",
session, numRoundFail+numTimeOut, len(rounds), numRoundFail, session, numRoundFail+numTimeOut, len(rounds), numRoundFail,
numTimeOut) numTimeOut)
sess.GetCriticalMessages().Failed(m) sess.GetCriticalMessages().Failed(m, e2eParams)
return nil return nil
} }
// otherwise, the transmission is a success and this should be denoted // otherwise, the transmission is a success and this should be denoted
// in the session and the log // in the session and the log
sess.GetCriticalMessages().Succeeded(m) sess.GetCriticalMessages().Succeeded(m, e2eParams)
jww.INFO.Printf("Key Negotiation transmission for %s successfully", jww.INFO.Printf("Key Negotiation transmission for %s successfully",
session) session)
......
...@@ -51,8 +51,9 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) { ...@@ -51,8 +51,9 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) {
//critical messages //critical messages
for msg, param, has := critMsgs.Next(); has; msg, param, has = critMsgs.Next() { for msg, param, has := critMsgs.Next(); has; msg, param, has = critMsgs.Next() {
go func(msg message.Send, param params.E2E) { go func(msg message.Send, param params.E2E) {
jww.INFO.Printf("Resending critical message to %s ",
msg.Recipient) jww.INFO.Printf("Resending critical message to %s with params %#v",
msg.Recipient, msg, param)
//send the message //send the message
rounds, _, _, err := m.SendE2E(msg, param, stop) rounds, _, _, err := m.SendE2E(msg, param, stop)
//if the message fail to send, notify the buffer so it can be handled //if the message fail to send, notify the buffer so it can be handled
...@@ -61,7 +62,7 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) { ...@@ -61,7 +62,7 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) {
jww.ERROR.Printf("Failed to send critical message to %s "+ jww.ERROR.Printf("Failed to send critical message to %s "+
" on notification of healthy network: %+v", msg.Recipient, " on notification of healthy network: %+v", msg.Recipient,
err) err)
critMsgs.Failed(msg) critMsgs.Failed(msg, param)
return return
} }
//wait on the results to make sure the rounds were successful //wait on the results to make sure the rounds were successful
...@@ -77,13 +78,13 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) { ...@@ -77,13 +78,13 @@ func (m *Manager) criticalMessages(stop *stoppable.Single) {
"to transmit transmit %v/%v paritions on rounds %d: %v "+ "to transmit transmit %v/%v paritions on rounds %d: %v "+
"round failures, %v timeouts", msg.Recipient, "round failures, %v timeouts", msg.Recipient,
numRoundFail+numTimeOut, len(rounds), rounds, numRoundFail, numTimeOut) numRoundFail+numTimeOut, len(rounds), rounds, numRoundFail, numTimeOut)
critMsgs.Failed(msg) critMsgs.Failed(msg, param)
return return
} }
jww.INFO.Printf("Successful resend of critical message "+ jww.INFO.Printf("Successful resend of critical message "+
"to %s on rounds %d", msg.Recipient, rounds) "to %s on rounds %d", msg.Recipient, rounds)
critMsgs.Succeeded(msg) critMsgs.Succeeded(msg, param)
}(msg, param) }(msg, param)
} }
......
...@@ -103,6 +103,7 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, ...@@ -103,6 +103,7 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message,
jww.WARN.Printf("Failed to GetUpcomingRealtime (msgDigest: %s): %+v", msg.Digest(), err) jww.WARN.Printf("Failed to GetUpcomingRealtime (msgDigest: %s): %+v", msg.Digest(), err)
} }
if bestRound == nil { if bestRound == nil {
jww.WARN.Printf("Best round on send is nil")
continue continue
} }
......
...@@ -155,12 +155,12 @@ func (emb *E2eMessageBuffer) Next() (message.Send, params.E2E, bool) { ...@@ -155,12 +155,12 @@ func (emb *E2eMessageBuffer) Next() (message.Send, params.E2E, bool) {
message.Type(msg.MessageType)}, msg.Params, true message.Type(msg.MessageType)}, msg.Params, true
} }
func (emb *E2eMessageBuffer) Succeeded(m message.Send) { func (emb *E2eMessageBuffer) Succeeded(m message.Send, p params.E2E) {
emb.mb.Succeeded(e2eMessage{m.Recipient.Marshal(), emb.mb.Succeeded(e2eMessage{m.Recipient.Marshal(),
m.Payload, uint32(m.MessageType), params.E2E{}}) m.Payload, uint32(m.MessageType), p})
} }
func (emb *E2eMessageBuffer) Failed(m message.Send) { func (emb *E2eMessageBuffer) Failed(m message.Send, p params.E2E) {
emb.mb.Failed(e2eMessage{m.Recipient.Marshal(), emb.mb.Failed(e2eMessage{m.Recipient.Marshal(),
m.Payload, uint32(m.MessageType), params.E2E{}}) m.Payload, uint32(m.MessageType), p})
} }
...@@ -9,6 +9,7 @@ package utility ...@@ -9,6 +9,7 @@ package utility
import ( import (
"encoding/json" "encoding/json"
"fmt"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
...@@ -112,7 +113,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) { ...@@ -112,7 +113,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) {
if !exists { if !exists {
t.Error("Next() did not find any messages in buffer.") t.Error("Next() did not find any messages in buffer.")
} }
cmb.Succeeded(msg) cmb.Succeeded(msg, params.E2E{})
if len(cmb.mb.messages) != 1 { if len(cmb.mb.messages) != 1 {
t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d", t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d",
...@@ -127,7 +128,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) { ...@@ -127,7 +128,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) {
t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d", t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d",
0, len(cmb.mb.messages)) 0, len(cmb.mb.messages))
} }
cmb.Failed(msg) cmb.Failed(msg,params.E2E{})
if len(cmb.mb.messages) != 1 { if len(cmb.mb.messages) != 1 {
t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d", t.Errorf("Unexpected length of buffer.\n\texpected: %d\n\trecieved: %d",
...@@ -138,7 +139,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) { ...@@ -138,7 +139,7 @@ func TestE2EMessageHandler_Smoke(t *testing.T) {
if !exists { if !exists {
t.Error("Next() did not find any messages in buffer.") t.Error("Next() did not find any messages in buffer.")
} }
cmb.Succeeded(msg) cmb.Succeeded(msg, params.E2E{})
msg, _, exists = cmb.Next() msg, _, exists = cmb.Next()
if exists { if exists {
...@@ -174,3 +175,43 @@ func makeTestE2EMessages(n int, t *testing.T) ([]e2eMessage, []message.Send) { ...@@ -174,3 +175,43 @@ func makeTestE2EMessages(n int, t *testing.T) ([]e2eMessage, []message.Send) {
return msgs, send return msgs, send
} }
func TestE2EParamMarshalUnmarshal(t *testing.T) {
msg := e2eMessage{
Recipient: id.DummyUser[:],
Payload: []byte{1,2,3,4,5,6,7,8,9},
MessageType: 42,
Params: params.E2E{
Type: 1,
RetryCount: 7,
CMIX: params.CMIX{
RoundTries: 6,
Timeout: 99,
RetryDelay: -4,
},
},
}
b, err := json.Marshal(&msg)
if err!=nil{
t.Errorf("Failed to Marshal E2eMessage")
}
fmt.Printf("%s\n", string(b))
msg2 := &e2eMessage{}
err = json.Unmarshal(b,&msg2)
if err!=nil{
t.Errorf("Failed to Unmarshal E2eMessage")
}
fmt.Printf("%#v\n", msg2)
if !reflect.DeepEqual(msg,msg2){
t.Errorf("Unmarshaled message is not the same")
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment