Skip to content
Snippets Groups Projects
Commit a48993c9 authored by Jake Taylor's avatar Jake Taylor
Browse files

Merge branch 'release' into hotfix/GetRoundResultsFix

parents 7e379978 62141ddd
No related branches found
No related tags found
2 merge requests!170Release,!144attempt to fix GetRoundResults by making the follower only send one RoundEvent...
......@@ -13,7 +13,6 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/utility"
"gitlab.com/elixxir/client/storage/reception"
ds "gitlab.com/elixxir/comms/network/dataStructures"
contact2 "gitlab.com/elixxir/crypto/contact"
......@@ -51,8 +50,7 @@ func (m *Manager) TransmitSingleUse(partner contact2.Contact, payload []byte,
rngReader := m.rng.GetStream()
defer rngReader.Close()
return m.transmitSingleUse(partner, payload, tag, maxMsgs, rngReader,
callback, timeout, m.net.GetInstance().GetRoundEvents())
return m.transmitSingleUse(partner, payload, tag, maxMsgs, rngReader, callback, timeout)
}
// roundEvents interface allows custom round events to be passed in for testing.
......@@ -63,7 +61,7 @@ type roundEvents interface {
// transmitSingleUse has the fields passed in for easier testing.
func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
tag string, MaxMsgs uint8, rng io.Reader, callback ReplyComm, timeout time.Duration, roundEvents roundEvents) error {
tag string, MaxMsgs uint8, rng io.Reader, callback ReplyComm, timeout time.Duration) error {
// Get ephemeral ID address space size; this blocks until the address space
// size is set for the first time
......@@ -123,7 +121,7 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
if err != nil {
errorString := fmt.Sprintf("failed to send single-use transmission "+
"CMIX message: %+v", err)
jww.ERROR.Print(errorString)
jww.ERROR.Printf(errorString)
// Exit the state timeout handler, delete the state from map, and
// return an error on the callback
......@@ -140,40 +138,9 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
"message because the timeout handler quit.")
return
}
// Update the timeout for the elapsed time
roundEventTimeout := timeout - netTime.Since(timeStart) - time.Millisecond
// Check message delivery
sendResults := make(chan ds.EventReturn, 1)
roundEvents.AddRoundEventChan(round, sendResults, roundEventTimeout,
states.COMPLETED, states.FAILED)
im := fmt.Sprintf("Sent single-use transmission CMIX "+
jww.DEBUG.Printf("Sent single-use transmission CMIX "+
"message to %s and ephemeral ID %d on round %d.",
partner.ID, ephID.Int64(), round)
jww.DEBUG.Print(im)
if m.client != nil {
m.client.ReportEvent(1, "SingleUse", "MessageSend", im)
}
// Wait until the result tracking responds
success, numRoundFail, numTimeOut := utility.TrackResults(sendResults, 1)
if !success {
errorString := fmt.Sprintf("failed to send single-use transmission "+
"message: %d round failures, %d round event time outs.",
numRoundFail, numTimeOut)
jww.ERROR.Print(errorString)
// Exit the state timeout handler, delete the state from map, and
// return an error on the callback
quitChan <- struct{}{}
m.p.Lock()
delete(m.p.singleUse, *rid)
m.p.Unlock()
go callback(nil, errors.New(errorString))
}
jww.DEBUG.Print("Tracked single-use transmission message round.")
}()
return nil
......
......@@ -50,8 +50,7 @@ func TestManager_transmitSingleUse(t *testing.T) {
callback, callbackChan := createReplyComm()
timeout := 15 * time.Millisecond
err := m.transmitSingleUse(partner, payload, tag, maxMsgs, prng,
callback, timeout, newTestRoundEvents(false))
err := m.transmitSingleUse(partner, payload, tag, maxMsgs, prng, callback, timeout)
if err != nil {
t.Errorf("transmitSingleUse() returned an error: %+v", err)
}
......@@ -93,7 +92,7 @@ func TestManager_transmitSingleUse_QuitChanError(t *testing.T) {
timeout := 15 * time.Millisecond
err := m.transmitSingleUse(partner, []byte{}, "testTag", 9,
rand.New(rand.NewSource(42)), callback, timeout, newTestRoundEvents(false))
rand.New(rand.NewSource(42)), callback, timeout)
if err != nil {
t.Errorf("transmitSingleUse() returned an error: %+v", err)
}
......@@ -125,7 +124,7 @@ func TestManager_transmitSingleUse_AddIdentityError(t *testing.T) {
callback, callbackChan := createReplyComm()
err := m.transmitSingleUse(partner, []byte{}, "testTag", 9,
rand.New(rand.NewSource(42)), callback, timeout, newTestRoundEvents(false))
rand.New(rand.NewSource(42)), callback, timeout)
if err != nil {
t.Errorf("transmitSingleUse() returned an error: %+v", err)
}
......@@ -158,7 +157,7 @@ func TestManager_transmitSingleUse_SendCMIXError(t *testing.T) {
timeout := 15 * time.Millisecond
err := m.transmitSingleUse(partner, []byte{}, "testTag", 9,
rand.New(rand.NewSource(42)), callback, timeout, newTestRoundEvents(false))
rand.New(rand.NewSource(42)), callback, timeout)
if err != nil {
t.Errorf("transmitSingleUse() returned an error: %+v", err)
}
......@@ -182,7 +181,7 @@ func TestManager_transmitSingleUse_MakeTransmitCmixMessageError(t *testing.T) {
prng := rand.New(rand.NewSource(42))
payload := make([]byte, m.store.Cmix().GetGroup().GetP().ByteLen())
err := m.transmitSingleUse(contact2.Contact{}, payload, "", 0, prng, nil, 0, nil)
err := m.transmitSingleUse(contact2.Contact{}, payload, "", 0, prng, nil, 0)
if err == nil {
t.Error("transmitSingleUse() did not return an error when the payload " +
"is too large.")
......@@ -212,7 +211,7 @@ func TestManager_transmitSingleUse_AddStateError(t *testing.T) {
m.p.singleUse[*rid] = newState(dhKey, maxMsgs, nil)
err = m.transmitSingleUse(partner, payload, tag, maxMsgs,
rand.New(rand.NewSource(42)), callback, timeout, nil)
rand.New(rand.NewSource(42)), callback, timeout)
if !check(err, "failed to add pending state") {
t.Errorf("transmitSingleUse() failed to error when on adding state "+
"when the state already exists: %+v", err)
......@@ -232,8 +231,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
callback, callbackChan := createReplyComm()
timeout := 15 * time.Millisecond
err := m.transmitSingleUse(partner, payload, "testTag", 8, prng, callback,
timeout, newTestRoundEvents(true))
err := m.transmitSingleUse(partner, payload, "testTag", 8, prng, callback, timeout)
if err != nil {
t.Errorf("transmitSingleUse() returned an error: %+v", err)
}
......@@ -242,7 +240,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
select {
case results := <-callbackChan:
if results.payload != nil || !check(results.err, "round failures") {
if results.payload != nil || !check(results.err, "timed out") {
t.Errorf("Callback did not return the correct error when it "+
"should have timed out.\npayload: %+v\nerror: %+v",
results.payload, results.err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment