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

Minor fixes

parent e1b9261f
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
...@@ -53,7 +53,7 @@ type RoundsComms interface { ...@@ -53,7 +53,7 @@ type RoundsComms interface {
} }
// RoundResultCallback is the used callback when a round is found. // RoundResultCallback is the used callback when a round is found.
type RoundResultCallback func(info Round, success bool) type RoundResultCallback func(round Round, success bool)
// roundRequest is an internal structure that tracks a request. // roundRequest is an internal structure that tracks a request.
type roundRequest struct { type roundRequest struct {
......
...@@ -84,8 +84,8 @@ func Test_processHistoricalRoundsResponse(t *testing.T) { ...@@ -84,8 +84,8 @@ func Test_processHistoricalRoundsResponse(t *testing.T) {
} }
expiredRR := roundRequest{ expiredRR := roundRequest{
rid: id.Round(42), rid: id.Round(42),
RoundResultCallback: func(info Round, success bool) { RoundResultCallback: func(round Round, success bool) {
if info.ID == 0 && !success { if round.ID == 0 && !success {
return return
} }
t.Errorf("Expired called with bad params.") t.Errorf("Expired called with bad params.")
...@@ -108,12 +108,15 @@ func Test_processHistoricalRoundsResponse(t *testing.T) { ...@@ -108,12 +108,15 @@ func Test_processHistoricalRoundsResponse(t *testing.T) {
infos := make([]*pb.RoundInfo, 3) infos := make([]*pb.RoundInfo, 3)
infos[0] = nil infos[0] = nil
infos[1] = nil infos[1] = nil
infos[2] = &pb.RoundInfo{ID: 43} infos[2] = &pb.RoundInfo{
ID: 43,
Topology: [][]byte{{1}, {2}},
}
response := &pb.HistoricalRoundsResponse{Rounds: infos} response := &pb.HistoricalRoundsResponse{Rounds: infos}
events := &testEventMgr{} events := &testEventMgr{}
rids, retries := processHistoricalRoundsResponse(response, rrs, rids, retries := processHistoricalRoundsResponse(
params.MaxHistoricalRoundsRetries, events) response, rrs, params.MaxHistoricalRoundsRetries, events)
if len(rids) != 1 || rids[0] != 43 { if len(rids) != 1 || rids[0] != 43 {
t.Errorf("Bad return: %v, expected [43]", rids) t.Errorf("Bad return: %v, expected [43]", rids)
......
...@@ -10,10 +10,10 @@ import ( ...@@ -10,10 +10,10 @@ import (
) )
type Round struct { type Round struct {
//ID of the round. Ids are sequential and monotonic // ID of the round. IDs are sequential and monotonic.
ID id.Round ID id.Round
// Last known state of the round. Possible states are: // State is the last known state of the round. Possible states are:
// PENDING - not started yet // PENDING - not started yet
// PRECOMPUTING - In the process of preparing to process messages // PRECOMPUTING - In the process of preparing to process messages
// STANDBY - Completed precomputing but not yet scheduled to run // STANDBY - Completed precomputing but not yet scheduled to run
...@@ -23,32 +23,32 @@ type Round struct { ...@@ -23,32 +23,32 @@ type Round struct {
// FAILED - Failed to deliver messages // FAILED - Failed to deliver messages
State states.Round State states.Round
// List of Nodes in the round // Topology contains the list of nodes in the round.
Topology *connect.Circuit Topology *connect.Circuit
// Timestamps of all events that have occurred in the round // Timestamps of all events that have occurred in the round (see the above
// (See the above states). // states).
// The Queued state's timestamp is different, it denotes when Realtime // The QUEUED state's timestamp is different; it denotes when Realtime
// was/is scheduled to start, not whe the Queued state is entered // was/is scheduled to start, not whe the QUEUED state is entered.
Timestamps map[states.Round]time.Time Timestamps map[states.Round]time.Time
// Errors that occurred in the round. Will only be present in the failed // Errors that occurred in the round. Will only be present in the failed
// state // state.
Errors []RoundError Errors []RoundError
/* Properties */ /* Properties */
// Max number of messages the round can process // BatchSize is the max number of messages the round can process.
BatchSize uint32 BatchSize uint32
// Ephemeral Address space size used in the round // AddressSpaceSize is the ephemeral address space size used in the round.
AddressSpaceSize uint8 AddressSpaceSize uint8
// Monotonic counter between all round updates denoting when this updated // UpdateID is a monotonic counter between all round updates denoting when
//occurred in the queue // this updated occurred in the queue.
UpdateID uint64 UpdateID uint64
// RawData round data, including signatures // Raw is raw round data, including signatures.
Raw *pb.RoundInfo Raw *pb.RoundInfo
} }
...@@ -57,7 +57,7 @@ type RoundError struct { ...@@ -57,7 +57,7 @@ type RoundError struct {
Error string Error string
} }
//MakeRound Builds an accessable round object from a RoundInfo Protobuff // MakeRound builds an accessible round object from a RoundInfo protobuf.
func MakeRound(ri *pb.RoundInfo) Round { func MakeRound(ri *pb.RoundInfo) Round {
// Build the timestamps map // Build the timestamps map
timestamps := make(map[states.Round]time.Time) timestamps := make(map[states.Round]time.Time)
...@@ -77,7 +77,7 @@ func MakeRound(ri *pb.RoundInfo) Round { ...@@ -77,7 +77,7 @@ func MakeRound(ri *pb.RoundInfo) Round {
nodes[i] = &newNodeID nodes[i] = &newNodeID
} }
//build the errors // Build the errors
errs := make([]RoundError, len(ri.Errors)) errs := make([]RoundError, len(ri.Errors))
for i := range ri.Errors { for i := range ri.Errors {
errNodeID := id.ID{} errNodeID := id.ID{}
...@@ -101,8 +101,8 @@ func MakeRound(ri *pb.RoundInfo) Round { ...@@ -101,8 +101,8 @@ func MakeRound(ri *pb.RoundInfo) Round {
} }
} }
// GetEndTimestamp Returns the timestamp of the last known event, // GetEndTimestamp returns the timestamp of the last known event, which is
// which is generally the state unless in queued, which stores the next event // generally the state unless in queued, which stores the next event.
func (r Round) GetEndTimestamp() time.Time { func (r Round) GetEndTimestamp() time.Time {
switch r.State { switch r.State {
case states.PENDING: case states.PENDING:
...@@ -121,6 +121,7 @@ func (r Round) GetEndTimestamp() time.Time { ...@@ -121,6 +121,7 @@ func (r Round) GetEndTimestamp() time.Time {
jww.FATAL.Panicf("Could not get final timestamp of round, "+ jww.FATAL.Panicf("Could not get final timestamp of round, "+
"invalid state: %s", r.State) "invalid state: %s", r.State)
} }
//unreachable
// Unreachable
return time.Time{} return time.Time{}
} }
...@@ -39,7 +39,8 @@ func TestHandler_CheckInProgressMessages(t *testing.T) { ...@@ -39,7 +39,8 @@ func TestHandler_CheckInProgressMessages(t *testing.T) {
t.Errorf("Failed to add fingerprint: %+v", err) t.Errorf("Failed to add fingerprint: %+v", err)
} }
h.inProcess.Add(msg, h.inProcess.Add(msg,
&pb.RoundInfo{ID: 1, Timestamps: []uint64{0, 1, 2, 3}}, &pb.RoundInfo{ID: 1, Timestamps: []uint64{0, 1, 2, 3},
Topology: [][]byte{{1}, {2}}},
receptionID.EphemeralIdentity{Source: cid}) receptionID.EphemeralIdentity{Source: cid})
stop := stoppable.NewSingle("stop") stop := stoppable.NewSingle("stop")
......
...@@ -41,14 +41,14 @@ func (m *manager) GetMessagesFromRound( ...@@ -41,14 +41,14 @@ func (m *manager) GetMessagesFromRound(
identity.Source) identity.Source)
err = m.historical.LookupHistoricalRound( err = m.historical.LookupHistoricalRound(
roundID, func(info historical.Round, success bool) { roundID, func(round historical.Round, success bool) {
if !success { if !success {
// TODO: Implement me // TODO: Implement me
} }
// If found, send to Message Retrieval Workers // If found, send to Message Retrieval Workers
m.lookupRoundMessages <- roundLookup{ m.lookupRoundMessages <- roundLookup{
Round: info, Round: round,
Identity: identity, Identity: identity,
} }
}) })
......
...@@ -71,14 +71,14 @@ func Test_manager_processMessageRetrieval(t *testing.T) { ...@@ -71,14 +71,14 @@ func Test_manager_processMessageRetrieval(t *testing.T) {
Source: requestGateway, Source: requestGateway,
} }
roundInfo := historical.Round{ round := historical.Round{
ID: roundId, ID: roundId,
Topology: connect.NewCircuit([]*id.ID{requestGateway}), Topology: connect.NewCircuit([]*id.ID{requestGateway}),
} }
// Send a round look up request // Send a round look up request
testManager.lookupRoundMessages <- roundLookup{ testManager.lookupRoundMessages <- roundLookup{
Round: roundInfo, Round: round,
Identity: ephIdentity, Identity: ephIdentity,
} }
...@@ -159,14 +159,14 @@ func Test_manager_processMessageRetrieval_NoRound(t *testing.T) { ...@@ -159,14 +159,14 @@ func Test_manager_processMessageRetrieval_NoRound(t *testing.T) {
Source: dummyGateway, Source: dummyGateway,
} }
roundInfo := historical.Round{ round := historical.Round{
ID: roundId, ID: roundId,
Topology: connect.NewCircuit([]*id.ID{dummyGateway}), Topology: connect.NewCircuit([]*id.ID{dummyGateway}),
} }
// Send a round look up request // Send a round look up request
testManager.lookupRoundMessages <- roundLookup{ testManager.lookupRoundMessages <- roundLookup{
Round: roundInfo, Round: round,
Identity: identity, Identity: identity,
} }
...@@ -236,14 +236,14 @@ func Test_manager_processMessageRetrieval_FalsePositive(t *testing.T) { ...@@ -236,14 +236,14 @@ func Test_manager_processMessageRetrieval_FalsePositive(t *testing.T) {
requestGateway := id.NewIdFromString(FalsePositive, id.Gateway, t) requestGateway := id.NewIdFromString(FalsePositive, id.Gateway, t)
roundInfo := historical.Round{ round := historical.Round{
ID: roundId, ID: roundId,
Topology: connect.NewCircuit([]*id.ID{requestGateway}), Topology: connect.NewCircuit([]*id.ID{requestGateway}),
} }
// Send a round look up request // Send a round look up request
testManager.lookupRoundMessages <- roundLookup{ testManager.lookupRoundMessages <- roundLookup{
Round: roundInfo, Round: round,
Identity: identity, Identity: identity,
} }
...@@ -309,13 +309,13 @@ func Test_manager_processMessageRetrieval_Quit(t *testing.T) { ...@@ -309,13 +309,13 @@ func Test_manager_processMessageRetrieval_Quit(t *testing.T) {
requestGateway := id.NewIdFromString(ReturningGateway, id.Gateway, t) requestGateway := id.NewIdFromString(ReturningGateway, id.Gateway, t)
roundInfo := historical.Round{ round := historical.Round{
ID: roundId, ID: roundId,
Topology: connect.NewCircuit([]*id.ID{requestGateway}), Topology: connect.NewCircuit([]*id.ID{requestGateway}),
} }
// Send a round look up request // Send a round look up request
testManager.lookupRoundMessages <- roundLookup{ testManager.lookupRoundMessages <- roundLookup{
Round: roundInfo, Round: round,
Identity: identity, Identity: identity,
} }
...@@ -353,9 +353,8 @@ func Test_manager_processMessageRetrieval_MultipleGateways(t *testing.T) { ...@@ -353,9 +353,8 @@ func Test_manager_processMessageRetrieval_MultipleGateways(t *testing.T) {
p := gateway.DefaultPoolParams() p := gateway.DefaultPoolParams()
p.MaxPoolSize = 1 p.MaxPoolSize = 1
testManager.sender, _ = gateway.NewSender(p, testManager.sender, _ = gateway.NewSender(
testManager.rng, p, testManager.rng, testNdf, mockComms, testManager.session, nil)
testNdf, mockComms, testManager.session, nil)
// Create a local channel so reception is possible // Create a local channel so reception is possible
// (testManager.messageBundles is sent only via newManager call above) // (testManager.messageBundles is sent only via newManager call above)
...@@ -380,17 +379,17 @@ func Test_manager_processMessageRetrieval_MultipleGateways(t *testing.T) { ...@@ -380,17 +379,17 @@ func Test_manager_processMessageRetrieval_MultipleGateways(t *testing.T) {
Source: requestGateway, Source: requestGateway,
} }
roundInfo := historical.Round{ round := historical.Round{
ID: roundId, ID: roundId,
// Create a list of IDs in which some error gateways must be // Create a list of IDs in which some error gateways must be
// contacted before the happy path // contacted before the happy path
Topology: connect.NewCircuit([]*id.ID{errorGateway, errorGateway, Topology: connect.NewCircuit(
requestGateway}), []*id.ID{errorGateway, requestGateway}),
} }
// Send a round look up request // Send a round look up request
testManager.lookupRoundMessages <- roundLookup{ testManager.lookupRoundMessages <- roundLookup{
Round: roundInfo, Round: round,
Identity: identity, Identity: identity,
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment