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