diff --git a/api/results.go b/api/results.go index 2c87dd27a4a98ceecfbe8e5704bd9984d4a7814b..885458fe2974d22b16592ba9e3f3ce2f5d4154a2 100644 --- a/api/results.go +++ b/api/results.go @@ -8,8 +8,9 @@ package api import ( "fmt" + "time" + jww "github.com/spf13/jwalterweatherman" - "gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/network/gateway" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/comms/network" @@ -17,7 +18,6 @@ import ( "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/primitives/id" - "time" ) // Enum of possible round results to pass back @@ -186,7 +186,7 @@ func (c *Client) getHistoricalRounds(msg *pb.HistoricalRounds, // Find a gateway to request about the roundRequests gwHost, err := gateway.Get(instance.GetPartialNdf().Get(), comms, c.rng.GetStream()) if err != nil { - globals.Log.FATAL.Panicf("Failed to track network, NDF has corrupt "+ + jww.FATAL.Panicf("Failed to track network, NDF has corrupt "+ "data: %s", err) } diff --git a/api/utils_test.go b/api/utils_test.go index 74360610803c2107181f87efa0f29363d6da3f80..31e09e2d4f5b87a16e434ef1c6eef58423a903b3 100644 --- a/api/utils_test.go +++ b/api/utils_test.go @@ -8,8 +8,10 @@ package api import ( + "testing" + "github.com/pkg/errors" - "gitlab.com/elixxir/client/globals" + jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/interfaces/params" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/comms/network" @@ -21,7 +23,6 @@ import ( "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/utils" - "testing" ) func newTestingClient(face interface{}) (*Client, error) { @@ -29,7 +30,7 @@ func newTestingClient(face interface{}) (*Client, error) { case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", face) + jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", face) } def := getNDF(face) @@ -50,7 +51,7 @@ func newTestingClient(face interface{}) (*Client, error) { cert, err := utils.ReadFile(testkeys.GetNodeCertPath()) if err != nil { - globals.Log.FATAL.Panicf("Failed to create new test Instance: %v", err) + jww.FATAL.Panicf("Failed to create new test Instance: %v", err) } commsManager.AddHost(&id.Permissioning, "", cert, connect.GetDefaultHostParams()) @@ -74,7 +75,7 @@ func getNDF(face interface{}) *ndf.NetworkDefinition { case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", face) + jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", face) } cert, _ := utils.ReadFile(testkeys.GetNodeCertPath()) diff --git a/api/version_vars.go b/api/version_vars.go index 157aee200d3d2502207ae1ed7dbcb66a20db02ba..dc333c8a688faddebc96c5de0f589d9137801308 100644 --- a/api/version_vars.go +++ b/api/version_vars.go @@ -1,36 +1,43 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2020-08-10 10:46:23.193662 -0700 PDT m=+0.042594188 +// 2021-03-10 14:16:47.093264 -0800 PST m=+0.046129936 package api -const GITVERSION = `4ddf4b3 Merge branch 'XX-2471/XXPrimitives' into 'release'` -const SEMVER = "1.4.0" +const GITVERSION = `2096d6ae Merge branch 'Anne/v2' into 'release'` +const SEMVER = "2.0.0" const DEPENDENCIES = `module gitlab.com/elixxir/client go 1.13 require ( github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 - github.com/golang/protobuf v1.4.2 + github.com/golang/protobuf v1.4.3 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect - github.com/pelletier/go-toml v1.6.0 // indirect + github.com/magiconair/properties v1.8.4 // indirect + github.com/mitchellh/mapstructure v1.4.0 // indirect + github.com/pelletier/go-toml v1.8.1 // indirect github.com/pkg/errors v0.9.1 github.com/smartystreets/assertions v1.0.1 // indirect - github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/afero v1.5.1 // indirect github.com/spf13/cast v1.3.1 // indirect - github.com/spf13/cobra v1.0.0 + github.com/spf13/cobra v1.1.1 github.com/spf13/jwalterweatherman v1.1.0 - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.6.2 - gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656 - gitlab.com/elixxir/crypto v0.0.0-20200806211835-b8ce4472f399 - gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 - gitlab.com/elixxir/primitives v0.0.0-20200805174810-86b366d1dd2d - gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba - gitlab.com/xx_network/crypto v0.0.0-20200806235322-ede3c15881ce - gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da - golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de - gopkg.in/ini.v1 v1.52.0 // indirect + github.com/spf13/viper v1.7.1 + gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 + gitlab.com/elixxir/comms v0.0.4-0.20210310191636-1bca0ddac665 + gitlab.com/elixxir/crypto v0.0.7-0.20210309193114-8a6225c667e2 + gitlab.com/elixxir/ekv v0.1.4 + gitlab.com/elixxir/primitives v0.0.3-0.20210309193003-ef42ebb4800b + gitlab.com/xx_network/comms v0.0.4-0.20210309192940-6b7fb39b4d01 + gitlab.com/xx_network/crypto v0.0.5-0.20210309192854-cf32117afb96 + gitlab.com/xx_network/primitives v0.0.4-0.20210309173740-eb8cd411334a + golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad + golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect + golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect + google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect + google.golang.org/grpc v1.34.0 // indirect + google.golang.org/protobuf v1.25.0 + gopkg.in/ini.v1 v1.62.0 // indirect ) replace google.golang.org/grpc => github.com/grpc/grpc-go v1.27.1 diff --git a/globals/log.go b/globals/log.go deleted file mode 100644 index cbcdce07b2ed6a47f49bdf5368508b75e65c3ccf..0000000000000000000000000000000000000000 --- a/globals/log.go +++ /dev/null @@ -1,55 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -import ( - jww "github.com/spf13/jwalterweatherman" - "io" - "io/ioutil" - "log" - "os" -) - -// Log is logging everything to this notepad so that the CUI can replace it -// with its own notepad and get logging statements from the client -var Log = jww.NewNotepad(jww.LevelInfo, jww.LevelInfo, os.Stdout, - ioutil.Discard, "CLIENT", log.Ldate|log.Ltime) - -// InitLog initializes logging thresholds and the log path. -// verbose turns on debug logging, setting the log path to nil -// uses std out. -func InitLog(verbose bool, logPath string) *jww.Notepad { - logLevel := jww.LevelInfo - logFlags := (log.Ldate | log.Ltime) - stdOut := io.Writer(os.Stdout) - logFile := ioutil.Discard - - // If the verbose flag is set, print all logs and - // print microseconds as well - if verbose { - logLevel = jww.LevelDebug - logFlags = (log.Ldate | log.Ltime | log.Lmicroseconds) - } - // If the logpath is empty or not set to - (stdout), - // set up the log file and do not log to stdout - if logPath != "" && logPath != "-" { - // Create log file, overwrites if existing - lF, err := os.OpenFile(logPath, - os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - Log.WARN.Println("Invalid or missing log path," + - " stdout used.") - } else { - logFile = io.Writer(lF) - stdOut = ioutil.Discard - } - } - - return jww.NewNotepad(logLevel, logLevel, stdOut, logFile, - "CLIENT", logFlags) -} diff --git a/globals/statusEvents.go b/globals/statusEvents.go deleted file mode 100644 index fdf8d6ff99f6ac0c5cbc155eebe1a9c645c0ab8f..0000000000000000000000000000000000000000 --- a/globals/statusEvents.go +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -//Identity -const REG_KEYGEN = 1 //Generating Cryptographic Keys -const REG_PRECAN = 2 //Doing a Precanned Identity (Not Secure) -const REG_UID_GEN = 3 //Generating User ID -const REG_PERM = 4 //Validating User Identity With Permissioning Server -const REG_NODE = 5 //Registering with Nodes -const REG_FAIL = 6 //Failed to Register with Nodes -const REG_SECURE_STORE = 7 //Creating Local Secure Session -const REG_SAVE = 8 //Storing Session -//UDB registration -const UDB_REG_PUSHKEY = 9 //Pushing Cryptographic Material to the User Discovery Bot -const UDB_REG_PUSHUSER = 10 //Registering User with the User Discovery Bot -//UDB Search -const UDB_SEARCH_LOOK = 11 //Searching for User in User Discovery -const UDB_SEARCH_GETKEY = 12 //Getting Keying Material From User Discovery -const UDB_SEARCH_BUILD_CREDS = 13 //Building secure end to end relationship diff --git a/globals/storage.go b/globals/storage.go deleted file mode 100644 index 63f5b2b360b7842cbbb435cf5495568b80c48549..0000000000000000000000000000000000000000 --- a/globals/storage.go +++ /dev/null @@ -1,203 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -import ( - "os" - "sync" -) - -const ( - NoSave uint8 = iota - LocationA - LocationB -) - -type Storage interface { - SetLocation(string, string) error - GetLocation() (string, string) - SaveA([]byte) error - SaveB([]byte) error - LoadA() []byte - LoadB() []byte - IsEmpty() bool -} - -type DefaultStorage struct { - locationA string - locationB string - sync.Mutex -} - -func (ds *DefaultStorage) SetLocation(locationA, locationB string) error { - ds.Lock() - ds.locationA = locationA - ds.locationB = locationB - ds.Unlock() - return nil -} - -func (ds *DefaultStorage) GetLocation() (string, string) { - ds.Lock() - defer ds.Unlock() - return ds.locationA, ds.locationB -} - -func (ds *DefaultStorage) IsEmpty() bool { - _, err := os.Stat(ds.locationA) - firstEmpty := err != nil && os.IsNotExist(err) - _, err = os.Stat(ds.locationB) - secondEmpty := err != nil && os.IsNotExist(err) - return firstEmpty && secondEmpty -} - -func (ds *DefaultStorage) SaveA(data []byte) error { - return dsSaveHelper(ds.locationA, data) -} - -func (ds *DefaultStorage) LoadA() []byte { - return dsLoadHelper(ds.locationA) -} - -func (ds *DefaultStorage) SaveB(data []byte) error { - return dsSaveHelper(ds.locationB, data) -} - -func (ds *DefaultStorage) LoadB() []byte { - return dsLoadHelper(ds.locationB) -} - -type RamStorage struct { - DataA []byte - DataB []byte -} - -func (rs *RamStorage) SetLocation(string, string) error { - return nil -} - -func (rs *RamStorage) GetLocation() (string, string) { - return "", "" -} - -func (rs *RamStorage) SaveA(data []byte) error { - rs.DataA = make([]byte, len(data)) - copy(rs.DataA, data) - return nil -} - -func (rs *RamStorage) SaveB(data []byte) error { - rs.DataB = make([]byte, len(data)) - copy(rs.DataB, data) - return nil -} - -func (rs *RamStorage) LoadA() []byte { - b := make([]byte, len(rs.DataA)) - copy(b, rs.DataA) - - return b -} - -func (rs *RamStorage) LoadB() []byte { - b := make([]byte, len(rs.DataB)) - copy(b, rs.DataB) - - return b -} - -func (rs *RamStorage) IsEmpty() bool { - return (rs.DataA == nil || len(rs.DataA) == 0) && (rs.DataB == nil || len(rs.DataB) == 0) -} - -func dsLoadHelper(loc string) []byte { - // Check if the file exists, return nil if it does not - finfo, err1 := os.Stat(loc) - - if err1 != nil { - Log.ERROR.Printf("Default Storage Load: Unknown Error Occurred on"+ - " file check: \n %v", err1.Error()) - return nil - } - - b := make([]byte, finfo.Size()) - - // Open the file, return nil if it cannot be opened - f, err2 := os.Open(loc) - - defer func() { - if f != nil { - f.Close() - } else { - Log.WARN.Println("Could not close file, file is nil") - } - }() - - if err2 != nil { - Log.ERROR.Printf("Default Storage Load: Unknown Error Occurred on"+ - " file open: \n %v", err2.Error()) - return nil - } - - // Read the data from the file, return nil if read fails - _, err3 := f.Read(b) - - if err3 != nil { - Log.ERROR.Printf("Default Storage Load: Unknown Error Occurred on"+ - " file read: \n %v", err3.Error()) - return nil - } - - return b - -} - -func dsSaveHelper(loc string, data []byte) error { - //check if the file exists, delete if it does - _, err1 := os.Stat(loc) - - if err1 == nil { - errRmv := os.Remove(loc) - if errRmv != nil { - Log.WARN.Printf("Could not remove Storage File B: %s", errRmv) - } - } else if !os.IsNotExist(err1) { - Log.ERROR.Printf("Default Storage Save: Unknown Error Occurred on"+ - " file check: \n %v", - err1.Error()) - return err1 - } - - //create new file - f, err2 := os.Create(loc) - - defer func() { - if f != nil { - f.Close() - } else { - Log.WARN.Println("Could not close file, file is nil") - } - }() - - if err2 != nil { - Log.ERROR.Printf("Default Storage Save: Unknown Error Occurred on"+ - " file creation: \n %v", err2.Error()) - return err2 - } - - //Save to file - _, err3 := f.Write(data) - - if err3 != nil { - Log.ERROR.Printf("Default Storage Save: Unknown Error Occurred on"+ - " file write: \n %v", err3.Error()) - return err3 - } - - return nil -} diff --git a/globals/storage_test.go b/globals/storage_test.go deleted file mode 100644 index f7bd60f34ce90f1a474faf83b0918cb7a4b9eae3..0000000000000000000000000000000000000000 --- a/globals/storage_test.go +++ /dev/null @@ -1,145 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -import ( - "os" - "reflect" - "testing" -) - -func TestInitStorage(t *testing.T) { - TestDataA := []byte{12, 14, 54} - TestDataB := []byte{69, 42, 32} - TestSaveLocA := "testStorageA.data" - TestSaveLocB := "testStorageB.data" - - // Test DefaultStorage initialization without existing storage - storage := &DefaultStorage{} - //Check that storage is empty prior to any Save calls - if !storage.IsEmpty() { - t.Errorf("ds.IsEmpty failed to detect an empty storage") - } - - storage.SetLocation(TestSaveLocA, TestSaveLocB) - - // Test DS saveA - err := storage.SaveA(TestDataA) - if err != nil { - t.Errorf("ds.Save failed to create a save file A at: %v", - TestSaveLocA) - } - // Check that save file was made - if !exists(TestSaveLocA) { - t.Errorf("ds.Save failed to create a save file A at: %v", - TestSaveLocA) - } - //Check that the storage is not empty after a saveA call - if storage.IsEmpty() { - t.Errorf("ds.IsEmpty failed to detect a non-empty storage") - } - - // Test DS loadA - actualData := storage.LoadA() - if reflect.DeepEqual(actualData, TestDataA) != true { - t.Errorf("ds.Load failed to load expected data on A. Expected:%v Actual:%v", - TestDataA, actualData) - } - - // Test DS saveB - err = storage.SaveB(TestDataB) - if err != nil { - t.Errorf("ds.Save failed to create a save file B at: %v", - TestSaveLocB) - } - // Check that save file was made - if !exists(TestSaveLocB) { - t.Errorf("ds.Save failed to create a save file B at: %v", - TestSaveLocB) - } - - // Test DS loadA - actualData = storage.LoadB() - if reflect.DeepEqual(actualData, TestDataB) != true { - t.Errorf("ds.Load failed to load expected data on B. Expected:%v Actual:%v", - TestDataB, actualData) - } - - // Test RamStorage - store := RamStorage{} - actualData = nil - // Test A - store.SaveA(TestDataA) - actualData = store.LoadA() - if reflect.DeepEqual(actualData, TestDataA) != true { - t.Errorf("rs.Load failed to load expected data A. Expected:%v Actual:%v", - TestDataA, actualData) - } - //Test B - store.SaveB(TestDataB) - actualData = store.LoadB() - if reflect.DeepEqual(actualData, TestDataB) != true { - t.Errorf("rs.Load failed to load expected data B. Expected:%v Actual:%v", - TestDataB, actualData) - } - os.Remove(TestSaveLocA) - os.Remove(TestSaveLocB) -} - -// exists returns whether the given file or directory exists or not -func exists(path string) bool { - _, err := os.Stat(path) - if err == nil { - return true - } - if os.IsNotExist(err) { - return false - } - return true -} - -func TestDefaultStorage_GetLocation(t *testing.T) { - locationA := "hi" - locationB := "hi2" - - ds := DefaultStorage{locationA: locationA, locationB: locationB} - - recievedLocA, recievedLocB := ds.GetLocation() - - if recievedLocA != locationA { - t.Errorf("defaultStorage.GetLocation returned incorrect location A. Expected:%v Actual:%v", - locationA, recievedLocA) - } - - if recievedLocB != locationB { - t.Errorf("defaultStorage.GetLocation returned incorrect location B. Expected:%v Actual:%v", - locationB, recievedLocB) - } -} - -func TestRamStorage_GetLocation(t *testing.T) { - - ds := RamStorage{} - - a, b := ds.GetLocation() - - if a != "" && b != "" { - t.Errorf("RamStorage.GetLocation returned incorrect location. Actual: '', ''; Expected:'%v','%v'", - a, b) - } -} - -func Test_dsLoadHelper_LocError(t *testing.T) { - testLoc := "~a/test" - - result := dsLoadHelper(testLoc) - - if result != nil { - t.Errorf("dsLoadHelper() did not error on invalid path.") - } -} diff --git a/globals/terminator.go b/globals/terminator.go deleted file mode 100644 index 0b3155e19db73add793dad56fa45abc43a924724..0000000000000000000000000000000000000000 --- a/globals/terminator.go +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -import ( - "time" -) - -type ThreadTerminator chan chan bool - -func NewThreadTerminator() ThreadTerminator { - t := make(chan chan bool, 1) - return t -} - -func (t ThreadTerminator) Terminate() { - t <- nil -} - -// Try's to kill a thread controlled by a termination channel for the length of -// the timeout, returns its success. pass 0 for no timeout -func (t ThreadTerminator) BlockingTerminate(timeout uint64) bool { - - killNotify := make(chan bool) - defer close(killNotify) - - if timeout != 0 { - timer := time.NewTimer(time.Duration(timeout) * time.Millisecond) - defer timer.Stop() - - t <- killNotify - - select { - case _ = <-killNotify: - return true - case <-timer.C: - return false - } - } else { - _ = <-killNotify - return true - } -} diff --git a/globals/terminator_test.go b/globals/terminator_test.go deleted file mode 100644 index 8d18841de618d2f66407aae3e6fdd96bdc9688f9..0000000000000000000000000000000000000000 --- a/globals/terminator_test.go +++ /dev/null @@ -1,70 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// - -package globals - -import ( - "testing" - "time" -) - -func TestNewThreadTerminator(t *testing.T) { - - term := NewThreadTerminator() - - var success bool - - go func(term ThreadTerminator) { - term <- nil - }(term) - - timer := time.NewTimer(time.Duration(1000) * time.Millisecond) - defer timer.Stop() - - select { - case _ = <-term: - success = true - case <-timer.C: - success = false - } - - if !success { - t.Errorf("NewThreadTerminator: Could not use the ThreadTerminator to" + - " stop a thread") - } - -} - -func TestBlockingTerminate(t *testing.T) { - - term := NewThreadTerminator() - - go func(term ThreadTerminator) { - var killNotify chan<- bool - - q := false - - for !q { - select { - case killNotify = <-term: - q = true - } - - close(term) - - killNotify <- true - - } - }(term) - - success := term.BlockingTerminate(1000) - - if !success { - t.Errorf("BlockingTerminate: Thread did not terminate in time") - } - -} diff --git a/go.mod b/go.mod index 37355524701f9b8ac8dd0bf649ec155c8704cc34..6dd82d33e44876065815e19a1e49cac7c31fa940 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ 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.20210309193245-64181ff10b68 + gitlab.com/elixxir/comms v0.0.4-0.20210310191636-1bca0ddac665 gitlab.com/elixxir/crypto v0.0.7-0.20210309193114-8a6225c667e2 gitlab.com/elixxir/ekv v0.1.4 gitlab.com/elixxir/primitives v0.0.3-0.20210309193003-ef42ebb4800b diff --git a/go.sum b/go.sum index 90015560c810524be64d4ab74e92d2e837fdfbd8..1c1bb72ce0f98f11c4b650da92268747f12fe299 100644 --- a/go.sum +++ b/go.sum @@ -251,8 +251,8 @@ github.com/zeebo/pcg v1.0.0 h1:dt+dx+HvX8g7Un32rY9XWoYnd0NmKmrIzpHF7qiTDj0= github.com/zeebo/pcg v1.0.0/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 h1:Gi6rj4mAlK0BJIk1HIzBVMjWNjIUfstrsXC2VqLYPcA= gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= -gitlab.com/elixxir/comms v0.0.4-0.20210309193245-64181ff10b68 h1:HR45PZyVl+gvksIKoHPCxFndhOpBT6z3rl7vaa3BaAc= -gitlab.com/elixxir/comms v0.0.4-0.20210309193245-64181ff10b68/go.mod h1:96cMuVVlarB+I6nuFKdq4zCagQkbhVK/MUzRk3yOymI= +gitlab.com/elixxir/comms v0.0.4-0.20210310191636-1bca0ddac665 h1:2tWjyhX21DBXeAjiHJTFL/MCpb9L9mg7NE09sS8tb2k= +gitlab.com/elixxir/comms v0.0.4-0.20210310191636-1bca0ddac665/go.mod h1:96cMuVVlarB+I6nuFKdq4zCagQkbhVK/MUzRk3yOymI= 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= diff --git a/keyExchange/utils_test.go b/keyExchange/utils_test.go index 16bd2f4ec7d224ebed1e44b58ecc077b50e01e44..162db4728cec9ddfa0b91d0f0ae3acc6e0c7c522 100644 --- a/keyExchange/utils_test.go +++ b/keyExchange/utils_test.go @@ -8,8 +8,11 @@ package keyExchange import ( + "testing" + "time" + "github.com/golang/protobuf/proto" - "gitlab.com/elixxir/client/globals" + jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/params" @@ -28,8 +31,6 @@ import ( "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/ndf" - "testing" - "time" ) // Generate partner ID for two people, used for smoke tests @@ -108,7 +109,7 @@ func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.Netw case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) + jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } thisSession := storage.InitTestingSession(i) @@ -215,7 +216,7 @@ func InitTestingContextFullExchange(i interface{}) (*storage.Session, *switchboa case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) + jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } thisSession := storage.InitTestingSession(i) diff --git a/network/ephemeral/testutil.go b/network/ephemeral/testutil.go index 94df38ab2700eb1699b28db62ddf8b1d57e57745..fbcc4e3e8d031097f4d9447c0904f537451b3d40 100644 --- a/network/ephemeral/testutil.go +++ b/network/ephemeral/testutil.go @@ -8,7 +8,9 @@ package ephemeral import ( - "gitlab.com/elixxir/client/globals" + "testing" + + jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/params" @@ -22,7 +24,6 @@ import ( "gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/utils" - "testing" ) // testNetworkManager is a test implementation of NetworkManager interface. @@ -83,7 +84,7 @@ func NewTestNetworkManager(i interface{}) interfaces.NetworkManager { case *testing.T, *testing.M, *testing.B: break default: - globals.Log.FATAL.Panicf("initTesting is restricted to testing only."+ + jww.FATAL.Panicf("initTesting is restricted to testing only."+ "Got %T", i) } @@ -91,7 +92,7 @@ func NewTestNetworkManager(i interface{}) interfaces.NetworkManager { cert, err := utils.ReadFile(testkeys.GetNodeCertPath()) if err != nil { - globals.Log.FATAL.Panicf("Failed to create new test Instance: %v", err) + jww.FATAL.Panicf("Failed to create new test Instance: %v", err) } commsManager.AddHost(&id.Permissioning, "", cert, connect.GetDefaultHostParams()) @@ -101,7 +102,7 @@ func NewTestNetworkManager(i interface{}) interfaces.NetworkManager { thisInstance, err := network.NewInstanceTesting(instanceComms, getNDF(), getNDF(), nil, nil, i) if err != nil { - globals.Log.FATAL.Panicf("Failed to create new test Instance: %v", err) + jww.FATAL.Panicf("Failed to create new test Instance: %v", err) } thisManager := &testNetworkManager{instance: thisInstance} diff --git a/storage/e2e/session.go b/storage/e2e/session.go index fbfe0d0bd68b0bad85e97bcf94a5632bb2f7f8a5..76c614861f663ff834e22cc53e7e54c72f58d3ff 100644 --- a/storage/e2e/session.go +++ b/storage/e2e/session.go @@ -10,9 +10,13 @@ package e2e import ( "encoding/json" "fmt" + "math/big" + "sync" + "testing" + "time" + "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" - "gitlab.com/elixxir/client/globals" "gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/crypto/cyclic" @@ -20,10 +24,6 @@ import ( "gitlab.com/elixxir/crypto/hash" "gitlab.com/xx_network/crypto/randomness" "gitlab.com/xx_network/primitives/id" - "math/big" - "sync" - "testing" - "time" ) const currentSessionVersion = 0 @@ -250,7 +250,7 @@ func GetSessionIDFromBaseKeyForTesting(baseKey *cyclic.Int, i interface{}) Sessi case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("GetSessionIDFromBaseKeyForTesting is restricted to testing only. Got %T", i) + jww.FATAL.Panicf("GetSessionIDFromBaseKeyForTesting is restricted to testing only. Got %T", i) } return getSessionIDFromBaseKey(baseKey) } diff --git a/storage/session.go b/storage/session.go index 2eb8652c501d957683f8c72947e3586848c13a11..be1837de7fb32adf9d13549c8f42bfe00683c05f 100644 --- a/storage/session.go +++ b/storage/session.go @@ -10,8 +10,11 @@ package storage import ( + "sync" + "testing" + "github.com/pkg/errors" - "gitlab.com/elixxir/client/globals" + jww "github.com/spf13/jwalterweatherman" userInterface "gitlab.com/elixxir/client/interfaces/user" "gitlab.com/elixxir/client/storage/auth" "gitlab.com/elixxir/client/storage/clientVersion" @@ -32,8 +35,6 @@ import ( "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/ndf" - "sync" - "testing" ) // Number of rounds to store in the CheckedRound buffer @@ -303,7 +304,7 @@ func InitTestingSession(i interface{}) *Session { case *testing.T, *testing.M, *testing.B, *testing.PB: break default: - globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) + jww.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i) } privKey, _ := rsa.LoadPrivateKeyFromPem([]byte("-----BEGIN PRIVATE KEY-----\nMIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC7Dkb6VXFn4cdp\nU0xh6ji0nTDQUyT9DSNW9I3jVwBrWfqMc4ymJuonMZbuqK+cY2l+suS2eugevWZr\ntzujFPBRFp9O14Jl3fFLfvtjZvkrKbUMHDHFehascwzrp3tXNryiRMmCNQV55TfI\nTVCv8CLE0t1ibiyOGM9ZWYB2OjXt59j76lPARYww5qwC46vS6+3Cn2Yt9zkcrGes\nkWEFa2VttHqF910TP+DZk2R5C7koAh6wZYK6NQ4S83YQurdHAT51LKGrbGehFKXq\n6/OAXCU1JLi3kW2PovTb6MZuvxEiRmVAONsOcXKu7zWCmFjuZZwfRt2RhnpcSgzf\nrarmsGM0LZh6JY3MGJ9YdPcVGSz+Vs2E4zWbNW+ZQoqlcGeMKgsIiQ670g0xSjYI\nCqldpt79gaET9PZsoXKEmKUaj6pq1d4qXDk7s63HRQazwVLGBdJQK8qX41eCdR8V\nMKbrCaOkzD5zgnEu0jBBAwdMtcigkMIk1GRv91j7HmqwryOBHryLi6NWBY3tjb4S\no9AppDQB41SH3SwNenAbNO1CXeUqN0hHX6I1bE7OlbjqI7tXdrTllHAJTyVVjenP\nel2ApMXp+LVRdD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\nGyDR+jkryVRyG69QJf5nCXfNewWbFR4ohVtZ78DNVkjvvLYvr4qxYYLK8PI3YMwL\nsQKCAQB9lo7JadzKVio+C18EfNikOzoriQOaIYowNaaGDw3/9KwIhRsKgoTs+K5O\ngt/gUoPRGd3M2z4hn5j4wgeuFi7HC1MdMWwvgat93h7R1YxiyaOoCTxH1klbB/3K\n4fskdQRxuM8McUebebrp0qT5E0xs2l+ABmt30Dtd3iRrQ5BBjnRc4V//sQiwS1aC\nYi5eNYCQ96BSAEo1dxJh5RI/QxF2HEPUuoPM8iXrIJhyg9TEEpbrEJcxeagWk02y\nOMEoUbWbX07OzFVvu+aJaN/GlgiogMQhb6IiNTyMlryFUleF+9OBA8xGHqGWA6nR\nOaRA5ZbdE7g7vxKRV36jT3wvD7W+\n-----END PRIVATE KEY-----\n")) @@ -313,7 +314,7 @@ func InitTestingSession(i interface{}) *Session { uid := id.NewIdFromString("zezima", id.User, i) u, err := user.NewUser(kv, uid, uid, []byte("salt"), []byte("salt"), privKey, privKey, false) if err != nil { - globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy user: %+v", err) + jww.FATAL.Panicf("InitTestingSession failed to create dummy user: %+v", err) } u.SetTransmissionRegistrationValidationSignature([]byte("sig")) u.SetReceptionRegistrationValidationSignature([]byte("sig")) @@ -337,25 +338,25 @@ func InitTestingSession(i interface{}) *Session { "DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7", 16)) cmixStore, err := cmix.NewStore(cmixGrp, kv, cmixGrp.NewInt(2)) if err != nil { - globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) + jww.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) } s.cmix = cmixStore e2eStore, err := e2e.NewStore(cmixGrp, kv, cmixGrp.NewInt(2), uid, fastRNG.NewStreamGenerator(7, 3, csprng.NewSystemRNG)) if err != nil { - globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) + jww.FATAL.Panicf("InitTestingSession failed to create dummy cmix session: %+v", err) } s.e2e = e2eStore s.criticalMessages, err = utility.NewE2eMessageBuffer(s.kv, criticalMessagesKey) if err != nil { - globals.Log.FATAL.Panicf("InitTestingSession failed to create dummy critical messages: %+v", err) + jww.FATAL.Panicf("InitTestingSession failed to create dummy critical messages: %+v", err) } s.garbledMessages, err = utility.NewMeteredCmixMessageBuffer(s.kv, garbledMessagesKey) if err != nil { - globals.Log.FATAL.Panicf("Failed to create garbledMessages buffer: %+v", err) + jww.FATAL.Panicf("Failed to create garbledMessages buffer: %+v", err) } s.conversations = conversation.NewStore(s.kv)