diff --git a/api/client.go b/api/client.go index e70241ec757547aa7c3c81291cad52dd70aec947..eb12060227a9ae9cbcd8eef9d48ccbcb143cbebf 100644 --- a/api/client.go +++ b/api/client.go @@ -210,7 +210,7 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie } u := c.storage.GetUser() - jww.INFO.Printf("Client Logged in: \n\tTransmisstionID: %s " + + jww.INFO.Printf("Client Logged in: \n\tTransmisstionID: %s "+ "\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID) //Attach the services interface @@ -392,7 +392,7 @@ func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error { // Handles both auth confirm and requests func (c *Client) StartNetworkFollower() (<-chan interfaces.ClientError, error) { u := c.GetUser() - jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s " + + jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s "+ "\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID) c.clientErrorChannel = make(chan interfaces.ClientError, 1000) @@ -537,13 +537,13 @@ func (c *Client) GetNodeRegistrationStatus() (int, int, error) { cmixStore := c.storage.Cmix() var numRegistered int - for i, n := range nodes{ + for i, n := range nodes { nid, err := id.Unmarshal(n.ID) - if err!=nil{ - return 0,0, errors.Errorf("Failed to unmarshal node ID %v " + + if err != nil { + return 0, 0, errors.Errorf("Failed to unmarshal node ID %v "+ "(#%d): %s", n.ID, i, err.Error()) } - if cmixStore.Has(nid){ + if cmixStore.Has(nid) { numRegistered++ } } diff --git a/api/results_test.go b/api/results_test.go index 54433f2e9b8bcfd91e3d83e5745bdc1d3ceecc75..68e21e9aca1a317bada3ea1497c90166b1b4289c 100644 --- a/api/results_test.go +++ b/api/results_test.go @@ -40,7 +40,7 @@ func TestClient_GetRoundResults(t *testing.T) { // Create a new copy of the test client for this test client, err := newTestingClient(t) if err != nil { - t.Errorf("Failed in setup: %v", err) + t.Fatalf("Failed in setup: %v", err) } // Construct the round call back function signature @@ -103,7 +103,7 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) { // Create a new copy of the test client for this test client, err := newTestingClient(t) if err != nil { - t.Errorf("Failed in setup: %v", err) + t.Fatalf("Failed in setup: %v", err) } // Construct the round call back function signature @@ -161,7 +161,7 @@ func TestClient_GetRoundResults_HistoricalRounds(t *testing.T) { // Create a new copy of the test client for this test client, err := newTestingClient(t) if err != nil { - t.Errorf("Failed in setup: %v", err) + t.Fatalf("Failed in setup: %v", err) } // Overpopulate the round buffer, ensuring a circle back of the ring buffer @@ -219,7 +219,7 @@ func TestClient_GetRoundResults_Timeout(t *testing.T) { // Create a new copy of the test client for this test client, err := newTestingClient(t) if err != nil { - t.Errorf("Failed in setup: %v", err) + t.Fatalf("Failed in setup: %v", err) } // Construct the round call back function signature diff --git a/api/utils_test.go b/api/utils_test.go index 31e09e2d4f5b87a16e434ef1c6eef58423a903b3..ab2079ba39782e558cde5ff78ca2cd7f678fa217 100644 --- a/api/utils_test.go +++ b/api/utils_test.go @@ -61,7 +61,7 @@ func newTestingClient(face interface{}) (*Client, error) { thisInstance, err := network.NewInstanceTesting(instanceComms, def, def, nil, nil, face) if err != nil { - return nil, nil + return nil, err } c.network = &testNetworkManagerGeneric{instance: thisInstance} @@ -83,6 +83,7 @@ func getNDF(face interface{}) *ndf.NetworkDefinition { return &ndf.NetworkDefinition{ Registration: ndf.Registration{ TlsCertificate: string(cert), + EllipticPubKey: "/WRtT+mDZGC3FXQbvuQgfqOonAjJ47IKE0zhaGTQQ70=", }, Nodes: []ndf.Node{ { @@ -147,6 +148,6 @@ func signRoundInfo(ri *pb.RoundInfo) error { ourPrivateKey := &rsa.PrivateKey{PrivateKey: *pk} - return signature.Sign(ri, ourPrivateKey) + return signature.SignRsa(ri, ourPrivateKey) } diff --git a/bindings/callback.go b/bindings/callback.go index 34d26ecccaf4b4f105a2ab2e7b29d82fb1fe3728..d0fe898c204188646c74c647f41759b5988cbf69 100644 --- a/bindings/callback.go +++ b/bindings/callback.go @@ -97,16 +97,15 @@ type ClientError interface { Report(source, message, trace string) } - -type LogWriter interface{ +type LogWriter interface { Log(string) } -type writerAdapter struct{ +type writerAdapter struct { lw LogWriter } -func (wa *writerAdapter)Write(p []byte) (n int, err error){ +func (wa *writerAdapter) Write(p []byte) (n int, err error) { wa.lw.Log(string(p)) return len(p), nil } diff --git a/go.mod b/go.mod index 62f9d2992ffac2d2cb2d6d3e6538558ca5e1de46..c3fcb8243117f04d8a71924891960d50aea7c1dc 100644 --- a/go.mod +++ b/go.mod @@ -19,11 +19,11 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/viper v1.7.1 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 - gitlab.com/elixxir/comms v0.0.4-0.20210413194022-f5422be88efb + gitlab.com/elixxir/comms v0.0.4-0.20210414200820-10e888270d4d gitlab.com/elixxir/crypto v0.0.7-0.20210412231025-6f75c577f803 gitlab.com/elixxir/ekv v0.1.4 gitlab.com/elixxir/primitives v0.0.3-0.20210409190923-7bf3cd8d97e7 - gitlab.com/xx_network/comms v0.0.4-0.20210413200413-41a493c32b06 + gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2 gitlab.com/xx_network/crypto v0.0.5-0.20210413200952-56bd15ec9d99 gitlab.com/xx_network/primitives v0.0.4-0.20210412170941-7ef69bce5a5c golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad diff --git a/go.sum b/go.sum index 0cbd894a30f0947d2e12e9b2275dfc369e1e3c0d..bc295f668f349bb109d028dcc0bfe6793415fd80 100644 --- a/go.sum +++ b/go.sum @@ -283,6 +283,10 @@ gitlab.com/elixxir/comms v0.0.4-0.20210405183148-930ea17a1b5f h1:ZUY46FcnA7BOd9p gitlab.com/elixxir/comms v0.0.4-0.20210405183148-930ea17a1b5f/go.mod h1:jqqUYnsftpfQXJ57BPYp5A+i7qfA5IXhKUE9ZOSrqaE= gitlab.com/elixxir/comms v0.0.4-0.20210413194022-f5422be88efb h1:mPwoG9nAhihK4Rfl6Hph/DzMmkePv4zJ4nzTC+ewnEc= gitlab.com/elixxir/comms v0.0.4-0.20210413194022-f5422be88efb/go.mod h1:2meX6DKpVJAUcgt1d727t1I28C8qsZNSn9Vm8dlkgmA= +gitlab.com/elixxir/comms v0.0.4-0.20210414195240-0a29afe5c282 h1:sv1Yiv18o8Q/tpBSP3Bpm2GrbQYdWcGaXELIU6OGxVc= +gitlab.com/elixxir/comms v0.0.4-0.20210414195240-0a29afe5c282/go.mod h1:K0sExgT6vTjMY/agP7hRSutveJzGSNOuFjSsAl2vmz8= +gitlab.com/elixxir/comms v0.0.4-0.20210414200820-10e888270d4d h1:bHhOyckCTs0mRdgasEWgyxSz3JgK1J0ZBaV5cp2IjLk= +gitlab.com/elixxir/comms v0.0.4-0.20210414200820-10e888270d4d/go.mod h1:K0sExgT6vTjMY/agP7hRSutveJzGSNOuFjSsAl2vmz8= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw= @@ -311,6 +315,8 @@ gitlab.com/xx_network/comms v0.0.4-0.20210401160731-7b8890cdd8ad/go.mod h1:inre/ gitlab.com/xx_network/comms v0.0.4-0.20210407173545-dafd47029306/go.mod h1:PXbUpBMUcDygpEV1ptEc/pych07YkYQ/tv0AQPw+BRk= gitlab.com/xx_network/comms v0.0.4-0.20210413200413-41a493c32b06 h1:ejoRHig0h5oEXLbEqQbE3wjcJtEoK0q7mHkfZjphtRo= gitlab.com/xx_network/comms v0.0.4-0.20210413200413-41a493c32b06/go.mod h1:PXbUpBMUcDygpEV1ptEc/pych07YkYQ/tv0AQPw+BRk= +gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2 h1:4Xhw5zO9ggeD66z5SajzRcgkQ0RNdAENETwPlawo5aU= +gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2/go.mod h1:PXbUpBMUcDygpEV1ptEc/pych07YkYQ/tv0AQPw+BRk= gitlab.com/xx_network/crypto v0.0.3/go.mod h1:DF2HYvvCw9wkBybXcXAgQMzX+MiGbFPjwt3t17VRqRE= gitlab.com/xx_network/crypto v0.0.4 h1:lpKOL5mTJ2awWMfgBy30oD/UvJVrWZzUimSHlOdZZxo= gitlab.com/xx_network/crypto v0.0.4/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk= diff --git a/interfaces/params/network.go b/interfaces/params/network.go index 95e3bad0c3f1518203aaa03fc0fc583ae4281ecb..2f11441ea0b6ceb50924dbb163421051912d1bab 100644 --- a/interfaces/params/network.go +++ b/interfaces/params/network.go @@ -39,14 +39,14 @@ type Network struct { func GetDefaultNetwork() Network { n := Network{ - TrackNetworkPeriod: 100 * time.Millisecond, - MaxCheckedRounds: 500, - RegNodesBufferLen: 500, - NetworkHealthTimeout: 30 * time.Second, - E2EParams: GetDefaultE2ESessionParams(), + TrackNetworkPeriod: 100 * time.Millisecond, + MaxCheckedRounds: 500, + RegNodesBufferLen: 500, + NetworkHealthTimeout: 30 * time.Second, + E2EParams: GetDefaultE2ESessionParams(), ParallelNodeRegistrations: 8, - KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min - FastPolling: true, + KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min + FastPolling: true, } n.Rounds = GetDefaultRounds() n.Messages = GetDefaultMessage() diff --git a/interfaces/params/rounds.go b/interfaces/params/rounds.go index 87fa53fc04517b8262ffbc8be624b3989dddeb91..07c4c3c25d83f3c115263bef0269ab1c9226c7ee 100644 --- a/interfaces/params/rounds.go +++ b/interfaces/params/rounds.go @@ -39,9 +39,9 @@ func GetDefaultRounds() Rounds { HistoricalRoundsPeriod: 100 * time.Millisecond, NumMessageRetrievalWorkers: 8, - HistoricalRoundsBufferLen: 1000, - LookupRoundsBufferLen: 2000, - ForceHistoricalRounds: false, + HistoricalRoundsBufferLen: 1000, + LookupRoundsBufferLen: 2000, + ForceHistoricalRounds: false, MaxHistoricalRoundsRetries: 3, } } diff --git a/keyExchange/confirm_test.go b/keyExchange/confirm_test.go index 8cef6f6f60488568614208f751914332ca5267f9..10c5ab525f3bf266f8548a6503bf14ee4c011266 100644 --- a/keyExchange/confirm_test.go +++ b/keyExchange/confirm_test.go @@ -20,8 +20,14 @@ import ( // Smoke test for handleTrigger func TestHandleConfirm(t *testing.T) { // Generate alice and bob's session - aliceSession, _ := InitTestingContextGeneric(t) - bobSession, _ := InitTestingContextGeneric(t) + aliceSession, _, err := InitTestingContextGeneric(t) + if err != nil { + t.Fatalf("Failed to create alice session: %v", err) + } + bobSession, _, err := InitTestingContextGeneric(t) + if err != nil { + t.Fatalf("Failed to create bob session: %v", err) + } // Maintain an ID for bob bobID := id.NewIdFromBytes([]byte("test"), t) diff --git a/keyExchange/exchange.go b/keyExchange/exchange.go index d94e8800f60d440c3c0c8b41564c04f4ada32ba7..42b7a177e10595bf45dd1b11fe7715e3a0b0c4f2 100644 --- a/keyExchange/exchange.go +++ b/keyExchange/exchange.go @@ -32,7 +32,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte // create the trigger stoppable triggerStop := stoppable.NewSingle(keyExchangeTriggerName) - cleanupTrigger := func(){ + cleanupTrigger := func() { switchboard.Unregister(triggerID) } @@ -46,7 +46,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte // register the confirm stoppable confirmStop := stoppable.NewSingle(keyExchangeConfirmName) - cleanupConfirm := func(){ + cleanupConfirm := func() { switchboard.Unregister(confirmID) } diff --git a/keyExchange/trigger_test.go b/keyExchange/trigger_test.go index 430bba91a0ba734541b03a61260493caa03237e0..5dce2d6a7c50c8e774c3ecd88dd00f5e3db1cacc 100644 --- a/keyExchange/trigger_test.go +++ b/keyExchange/trigger_test.go @@ -23,9 +23,14 @@ import ( // Smoke test for handleTrigger func TestHandleTrigger(t *testing.T) { // Generate alice and bob's session - aliceSession, aliceManager := InitTestingContextGeneric(t) - bobSession, _ := InitTestingContextGeneric(t) - + aliceSession, aliceManager, err := InitTestingContextGeneric(t) + if err != nil { + t.Fatalf("Failed to create alice session: %v", err) + } + bobSession, _, err := InitTestingContextGeneric(t) + if err != nil { + t.Fatalf("Failed to create bob session: %v", err) + } // Pull the keys for Alice and Bob alicePrivKey := aliceSession.E2e().GetDHPrivateKey() bobPubKey := bobSession.E2e().GetDHPublicKey() @@ -62,7 +67,7 @@ func TestHandleTrigger(t *testing.T) { // Handle the trigger and check for an error rekeyParams := params.GetDefaultRekey() rekeyParams.RoundTimeout = 0 * time.Second - err := handleTrigger(aliceSession, aliceManager, receiveMsg, rekeyParams) + err = handleTrigger(aliceSession, aliceManager, receiveMsg, rekeyParams) if err != nil { t.Errorf("Handle trigger error: %v", err) } diff --git a/keyExchange/utils_test.go b/keyExchange/utils_test.go index a1447b990744f92b063420888ea1c96e1d9fb5dd..f02e056657b6d3e4fdfcd102cfc3093ddabb45e9 100644 --- a/keyExchange/utils_test.go +++ b/keyExchange/utils_test.go @@ -103,7 +103,7 @@ func (t *testNetworkManagerGeneric) InProgressRegistrations() int { return 0 } -func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.NetworkManager) { +func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.NetworkManager, error) { switch i.(type) { case *testing.T, *testing.M, *testing.B, *testing.PB: break @@ -120,12 +120,12 @@ func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.Netw thisInstance, err := network.NewInstanceTesting(instanceComms, def, def, nil, nil, i) if err != nil { - return nil, nil + return nil, nil, err } thisManager := &testNetworkManagerGeneric{instance: thisInstance} - return thisSession, thisManager + return thisSession, thisManager, nil } @@ -295,5 +295,8 @@ func getNDF() *ndf.NetworkDefinition { "BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0" + "DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7", }, + Registration: ndf.Registration{ + EllipticPubKey: "/WRtT+mDZGC3FXQbvuQgfqOonAjJ47IKE0zhaGTQQ70=", + }, } } diff --git a/network/checkedRounds.go b/network/checkedRounds.go index 8ffa9ba39804fd70017123859cf60137f12f8e78..d104ac9589bfb9d7b7bce41d967b7013fdfb9141 100644 --- a/network/checkedRounds.go +++ b/network/checkedRounds.go @@ -7,36 +7,35 @@ import ( "gitlab.com/xx_network/primitives/id" ) - type idFingerprint [16]byte -type checkedRounds struct{ +type checkedRounds struct { lookup map[idFingerprint]*checklist } -type checklist struct{ +type checklist struct { m map[id.Round]interface{} l *list.List } -func newCheckedRounds()*checkedRounds{ +func newCheckedRounds() *checkedRounds { return &checkedRounds{ lookup: make(map[idFingerprint]*checklist), } } -func (cr *checkedRounds)Check(identity reception.IdentityUse, rid id.Round)bool{ +func (cr *checkedRounds) Check(identity reception.IdentityUse, rid id.Round) bool { idFp := getIdFingerprint(identity) cl, exists := cr.lookup[idFp] - if !exists{ + if !exists { cl = &checklist{ m: make(map[id.Round]interface{}), l: list.New().Init(), } - cr.lookup[idFp]=cl + cr.lookup[idFp] = cl } - if _, exists := cl.m[rid]; !exists{ + if _, exists := cl.m[rid]; !exists { cl.m[rid] = nil cl.l.PushBack(rid) return true @@ -44,7 +43,7 @@ func (cr *checkedRounds)Check(identity reception.IdentityUse, rid id.Round)bool{ return false } -func (cr *checkedRounds)Prune(identity reception.IdentityUse, earliestAllowed id.Round){ +func (cr *checkedRounds) Prune(identity reception.IdentityUse, earliestAllowed id.Round) { idFp := getIdFingerprint(identity) cl, exists := cr.lookup[idFp] if !exists { @@ -52,19 +51,19 @@ func (cr *checkedRounds)Prune(identity reception.IdentityUse, earliestAllowed id } e := cl.l.Front() - for e!=nil { - if e.Value.(id.Round)<earliestAllowed{ - delete(cl.m,e.Value.(id.Round)) + for e != nil { + if e.Value.(id.Round) < earliestAllowed { + delete(cl.m, e.Value.(id.Round)) lastE := e e = e.Next() cl.l.Remove(lastE) - }else{ + } else { break } } } -func getIdFingerprint(identity reception.IdentityUse)idFingerprint{ +func getIdFingerprint(identity reception.IdentityUse) idFingerprint { h := md5.New() h.Write(identity.EphId[:]) h.Write(identity.Source[:]) @@ -72,4 +71,4 @@ func getIdFingerprint(identity reception.IdentityUse)idFingerprint{ fp := idFingerprint{} copy(fp[:], h.Sum(nil)) return fp -} \ No newline at end of file +} diff --git a/network/ephemeral/tracker_test.go b/network/ephemeral/tracker_test.go index aa4589ebe7650ab55d4d04ab97fb98cfb9d1c008..e6c3e11f8fd3b8a9e120f3634cac636b385f66c6 100644 --- a/network/ephemeral/tracker_test.go +++ b/network/ephemeral/tracker_test.go @@ -105,7 +105,7 @@ func setupInstance(instance interfaces.NetworkManager) error { if err != nil { return errors.Errorf("Failed to load cert from from file: %v", err) } - if err = signature.Sign(ri, testCert); err != nil { + if err = signature.SignRsa(ri, testCert); err != nil { return errors.Errorf("Failed to sign round info: %v", err) } if err = instance.GetInstance().RoundUpdate(ri); err != nil { @@ -115,7 +115,7 @@ func setupInstance(instance interfaces.NetworkManager) error { ri = &mixmessages.RoundInfo{ ID: 2, } - if err = signature.Sign(ri, testCert); err != nil { + if err = signature.SignRsa(ri, testCert); err != nil { return errors.Errorf("Failed to sign round info: %v", err) } if err = instance.GetInstance().RoundUpdate(ri); err != nil { diff --git a/network/follow.go b/network/follow.go index 5e6f6f1b4889c249e147311488c56fe569548647..ebf06e5db5060b5fe69b8e032329ef660a79fdcb 100644 --- a/network/follow.go +++ b/network/follow.go @@ -189,8 +189,8 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, update.State = uint32(states.FAILED) rnd, err := m.Instance.GetWrappedRound(id.Round(update.ID)) if err != nil { - jww.ERROR.Printf("Failed to report client error: " + - "Could not get round for event triggering: " + + jww.ERROR.Printf("Failed to report client error: "+ + "Could not get round for event triggering: "+ "Unable to get round %d from instance: %+v", id.Round(update.ID), err) break @@ -261,24 +261,24 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, earliestRemaining, roundsWithMessages, roundsUnknown := gwRoundsState.RangeUnchecked(updated, m.param.KnownRoundsThreshold, roundChecker) _, changed := identity.ER.Set(earliestRemaining) - if changed{ + if changed { jww.TRACE.Printf("External returns of RangeUnchecked: %d, %v, %v", earliestRemaining, roundsWithMessages, roundsUnknown) jww.DEBUG.Printf("New Earliest Remaining: %d", earliestRemaining) } - roundsWithMessages2 := identity.UR.Iterate(func(rid id.Round)bool{ - if gwRoundsState.Checked(rid){ + roundsWithMessages2 := identity.UR.Iterate(func(rid id.Round) bool { + if gwRoundsState.Checked(rid) { return rounds.Checker(rid, filterList) } return false }, roundsUnknown) - for _, rid := range roundsWithMessages{ - if m.checked.Check(identity, rid){ + for _, rid := range roundsWithMessages { + if m.checked.Check(identity, rid) { m.round.GetMessagesFromRound(rid, identity) } } - for _, rid := range roundsWithMessages2{ + for _, rid := range roundsWithMessages2 { m.round.GetMessagesFromRound(rid, identity) } @@ -289,10 +289,9 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, } - -func getEarliestToKeep(delta uint, lastchecked id.Round)id.Round{ - if uint(lastchecked)<delta{ +func getEarliestToKeep(delta uint, lastchecked id.Round) id.Round { + if uint(lastchecked) < delta { return 0 } - return lastchecked - id.Round(delta) + return lastchecked - id.Round(delta) } diff --git a/network/node/register.go b/network/node/register.go index 2b59d1e7ffd23853705541c46eb14242e8c3ca76..a27529b6eb612e9c3ae49a4e07393dbe67d8c347 100644 --- a/network/node/register.go +++ b/network/node/register.go @@ -45,7 +45,7 @@ func StartRegistration(instance *network.Instance, session *storage.Session, rng multi := stoppable.NewMulti("NodeRegistrations") - for i:=uint(0);i<numParallel;i++{ + for i := uint(0); i < numParallel; i++ { stop := stoppable.NewSingle(fmt.Sprintf("NodeRegistration %d", i)) go registerNodes(session, rngGen, comms, stop, c) diff --git a/network/rounds/check.go b/network/rounds/check.go index 9deb3ec6c16fb227a6406c9fd6181ffcf6e4d8b1..a22bafd8e7931ecbbe673b2df1c071bad4fb329c 100644 --- a/network/rounds/check.go +++ b/network/rounds/check.go @@ -47,9 +47,9 @@ func serializeRound(roundId id.Round) []byte { return b } -func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.IdentityUse){ +func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.IdentityUse) { ri, err := m.Instance.GetRound(roundID) - if err !=nil || m.params.ForceHistoricalRounds { + if err != nil || m.params.ForceHistoricalRounds { if m.params.ForceHistoricalRounds { jww.WARN.Printf("Forcing use of historical rounds for round ID %d.", roundID) @@ -59,8 +59,8 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden identity.Source) // If we didn't find it, send to Historical Rounds Retrieval m.historicalRounds <- historicalRoundRequest{ - rid: roundID, - identity: identity, + rid: roundID, + identity: identity, numAttempts: 0, } } else { @@ -74,4 +74,4 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden } } -} \ No newline at end of file +} diff --git a/network/rounds/historical.go b/network/rounds/historical.go index d5451989c4f3092652943d308d37c4a21bbf0524..6d2d76de30a44151e55cecc863f2113eb2a7a3fb 100644 --- a/network/rounds/historical.go +++ b/network/rounds/historical.go @@ -34,8 +34,8 @@ type historicalRoundsComms interface { //structure which contains a historical round lookup type historicalRoundRequest struct { - rid id.Round - identity reception.IdentityUse + rid id.Round + identity reception.IdentityUse numAttempts uint } @@ -124,19 +124,19 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, quitCh <-c // pick them up in the future. if roundInfo == nil { roundRequests[i].numAttempts++ - if roundRequests[i].numAttempts==m.params.MaxHistoricalRoundsRetries{ - jww.ERROR.Printf("Failed to retreive historical " + + if roundRequests[i].numAttempts == m.params.MaxHistoricalRoundsRetries { + jww.ERROR.Printf("Failed to retreive historical "+ "round %d on last attempt, will not try again", roundRequests[i].rid) - }else{ + } else { select { - case m.historicalRounds <-roundRequests[i]: - jww.WARN.Printf("Failed to retreive historical " + + case m.historicalRounds <- roundRequests[i]: + jww.WARN.Printf("Failed to retreive historical "+ "round %d, will try up to %d more times", roundRequests[i].rid, m.params.MaxHistoricalRoundsRetries-roundRequests[i].numAttempts) default: - jww.WARN.Printf("Failed to retreive historical " + - "round %d, failed to try again, round will not be " + + jww.WARN.Printf("Failed to retreive historical "+ + "round %d, failed to try again, round will not be "+ "retreived", roundRequests[i].rid) } } diff --git a/network/rounds/manager.go b/network/rounds/manager.go index 177c1c318b4807be0f17ccbb36bbe8720104deb4..6e94ef391a3812af4029298d225ec74ccf03e4aa 100644 --- a/network/rounds/manager.go +++ b/network/rounds/manager.go @@ -55,4 +55,4 @@ func (m *Manager) StartProcessors() stoppable.Stoppable { multi.Add(stopper) } return multi -} \ No newline at end of file +} diff --git a/network/rounds/utils_test.go b/network/rounds/utils_test.go index 69c5925ed5e5b787f2440169d5da9a24d373b219..c963199bedc637e13a050ac9c08d769d8c4a7acf 100644 --- a/network/rounds/utils_test.go +++ b/network/rounds/utils_test.go @@ -38,6 +38,7 @@ const ReturningGateway = "GetMessageRequest" const FalsePositive = "FalsePositive" const PayloadMessage = "Payload" const ErrorGateway = "Error" + type mockMessageRetrievalComms struct { testingSignature *testing.T } diff --git a/permissioning/permissioning_test.go b/permissioning/permissioning_test.go index 7f691f3a419f5a43109206da5a802b3bb2029be3..dc3e73c2e73a1872a812fb54f7ab374c8d37cf85 100644 --- a/permissioning/permissioning_test.go +++ b/permissioning/permissioning_test.go @@ -22,7 +22,9 @@ func TestInit(t *testing.T) { t.Fatal(err) } def := &ndf.NetworkDefinition{ - Registration: ndf.Registration{}, + Registration: ndf.Registration{ + EllipticPubKey: "MqaJJ3GjFisNRM6LRedRnooi14gepMaQxyWctXVU", + }, } reg, err := Init(comms, def) if err != nil { diff --git a/stoppable/cleanup.go b/stoppable/cleanup.go index 8111abe206492d4e22cfaffe31195acab58b77c5..b1e2c4561dc87c2af1ec654d48b787d47ca8182e 100644 --- a/stoppable/cleanup.go +++ b/stoppable/cleanup.go @@ -87,7 +87,7 @@ func (c *Cleanup) Close(timeout time.Duration) error { } }) - if err!=nil{ + if err != nil { jww.ERROR.Printf(err.Error()) } diff --git a/storage/cmix/store_test.go b/storage/cmix/store_test.go index f4dfc3a7af59ee29511a2172779c6b919ef6ec6b..63329b769b1706dc4a341988a03e28fe84a37642 100644 --- a/storage/cmix/store_test.go +++ b/storage/cmix/store_test.go @@ -70,7 +70,6 @@ func TestStore_AddRemove(t *testing.T) { } } - // Happy path Add/Has test func TestStore_AddHas(t *testing.T) { // Uncomment to print keys that Set and Get are called on diff --git a/storage/e2e/relationship.go b/storage/e2e/relationship.go index 6efd7081b133fae3845c83e1fbc5ecf3997da1ae..a492a72ed51d0f48f08657d786bc8dc6a3c861ed 100644 --- a/storage/e2e/relationship.go +++ b/storage/e2e/relationship.go @@ -303,9 +303,9 @@ func (r *relationship) getNewestRekeyableSession() *Session { // always valid. It isn't clear it can fail though because we are // accessing the data in the same order it would be written (i think) if s.Status() != RekeyEmpty { - if s.IsConfirmed(){ + if s.IsConfirmed() { return s - }else if unconfirmed == nil{ + } else if unconfirmed == nil { unconfirmed = s } } diff --git a/storage/e2e/relationship_test.go b/storage/e2e/relationship_test.go index 49fa51de4abe7df24421ae8c91b24c09f8c10b45..457e4f6dcd508abd2014248db7738f46badf947a 100644 --- a/storage/e2e/relationship_test.go +++ b/storage/e2e/relationship_test.go @@ -571,4 +571,4 @@ func Test_relationship_getNewestRekeyableSession(t *testing.T) { } }) } -} \ No newline at end of file +} diff --git a/storage/e2e/session.go b/storage/e2e/session.go index 5f0344378ae7f106edd4c447904dd89cb2b6ca94..ad684725a04918389f706566e44642c6c1fbaf16 100644 --- a/storage/e2e/session.go +++ b/storage/e2e/session.go @@ -119,7 +119,7 @@ func newSession(ship *relationship, t RelationshipType, myPrivKey, partnerPubKey relationshipFingerprint: relationshipFingerprint, negotiationStatus: negotiationStatus, partnerSource: trigger, - partner: ship.manager.partner.DeepCopy(), + partner: ship.manager.partner.DeepCopy(), } session.kv = session.generate(ship.kv) @@ -173,8 +173,8 @@ func loadSession(ship *relationship, kv *versioned.KV, } session.relationshipFingerprint = relationshipFingerprint - if !session.partner.Cmp(ship.manager.partner){ - return nil, errors.Errorf("Stored partner (%s) did not match " + + if !session.partner.Cmp(ship.manager.partner) { + return nil, errors.Errorf("Stored partner (%s) did not match "+ "relationship partner (%s)", session.partner, ship.manager.partner) } diff --git a/storage/e2e/session_test.go b/storage/e2e/session_test.go index 800cac5410e8b5236d9c89aa5ed90c36a49bc654..258cea9edab79a1e0fe6f214b4b6a78e4814e9d3 100644 --- a/storage/e2e/session_test.go +++ b/storage/e2e/session_test.go @@ -628,8 +628,8 @@ func makeTestSession() (*Session, *context) { e2eParams: params.GetDefaultE2ESessionParams(), relationship: &relationship{ manager: &Manager{ - ctx: ctx, - kv: kv, + ctx: ctx, + kv: kv, partner: &id.ID{}, }, kv: kv, @@ -638,7 +638,7 @@ func makeTestSession() (*Session, *context) { t: Receive, negotiationStatus: Confirmed, rekeyThreshold: 5, - partner: &id.ID{}, + partner: &id.ID{}, } var err error s.keyState, err = newStateVector(s.kv, diff --git a/storage/e2e/store.go b/storage/e2e/store.go index a0a427e0abbff557514b6d4197335cc75c427a69..e647cacab042388b667d383f670c8082c450b591 100644 --- a/storage/e2e/store.go +++ b/storage/e2e/store.go @@ -260,8 +260,8 @@ func (s *Store) unmarshal(b []byte) error { partnerID, err.Error()) } - if !manager.GetPartnerID().Cmp(partnerID){ - jww.FATAL.Panicf("Loaded a manager with the wrong partner " + + if !manager.GetPartnerID().Cmp(partnerID) { + jww.FATAL.Panicf("Loaded a manager with the wrong partner "+ "ID: \n\t loaded: %s \n\t present: %s", partnerID, manager.GetPartnerID()) } diff --git a/storage/rounds/unknownRounds_test.go b/storage/rounds/unknownRounds_test.go index ffc9bdd46a74060948a7a06d724cf2590d203da4..f437e0839f7d37208f2d7b5c826e6a6cfeb7d5b2 100644 --- a/storage/rounds/unknownRounds_test.go +++ b/storage/rounds/unknownRounds_test.go @@ -27,7 +27,7 @@ func TestNewUnknownRoundsStore(t *testing.T) { params: DefaultUnknownRoundsParams(), } - store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) + store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) // Compare manually created object with NewUnknownRoundsStore if !reflect.DeepEqual(expectedStore, store) { @@ -60,7 +60,7 @@ func TestNewUnknownRoundsStore(t *testing.T) { // Full test func TestUnknownRoundsStore_Iterate(t *testing.T) { kv := versioned.NewKV(make(ekv.Memstore)) - store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) + store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) // Return true only for rounds that are even mockChecker := func(rid id.Round) bool { @@ -116,7 +116,7 @@ func TestUnknownRoundsStore_Iterate(t *testing.T) { // Iterate over map until all rounds have checks incremented over // maxCheck for i := 0; i < defaultMaxCheck+1; i++ { - _ = store.Iterate(mockChecker,[]id.Round{}) + _ = store.Iterate(mockChecker, []id.Round{}) }