diff --git a/auth/state_test.go b/auth/state_test.go index 2cb137bfd6800a074953a0cce5e0705a66174d9e..211e3d6546a77994c9a3e8b18c7c7c8b52acad85 100644 --- a/auth/state_test.go +++ b/auth/state_test.go @@ -8,6 +8,11 @@ package auth import ( + "io" + "math/rand" + "testing" + "time" + "github.com/cloudflare/circl/dh/sidh" "gitlab.com/elixxir/client/auth/store" "gitlab.com/elixxir/client/cmix" @@ -29,10 +34,6 @@ import ( "gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id/ephemeral" - "io" - "math/rand" - "testing" - "time" ) type mockEventManager struct{} @@ -185,7 +186,7 @@ loop: } func makeTestStore(t *testing.T) (*store.Store, *versioned.KV, []*cyclic.Int) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(0)) privKeys := make([]*cyclic.Int, 10) for i := range privKeys { diff --git a/auth/store/confirmation_test.go b/auth/store/confirmation_test.go index a00f5e26f04adcc83903ef5101a055f1d66dcd5b..2bc188cd4429cf1ff27f5166dbbfc1c4457a13d5 100644 --- a/auth/store/confirmation_test.go +++ b/auth/store/confirmation_test.go @@ -8,6 +8,10 @@ package store import ( + "math/rand" + "reflect" + "testing" + "github.com/cloudflare/circl/dh/sidh" "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/client/storage/versioned" @@ -18,16 +22,13 @@ import ( "gitlab.com/elixxir/primitives/format" "gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/primitives/id" - "math/rand" - "reflect" - "testing" ) // Tests that a confirmation for different partners and sentByFingerprints can be // saved and loaded from storage via Store.StoreConfirmation and // Store.LoadConfirmation. func TestStore_StoreConfirmation_LoadConfirmation(t *testing.T) { - s := &Store{kv: versioned.NewKV(make(ekv.Memstore))} + s := &Store{kv: versioned.NewKV(ekv.MakeMemstore())} prng := rand.New(rand.NewSource(42)) grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(2)) @@ -98,7 +99,7 @@ func TestStore_StoreConfirmation_LoadConfirmation(t *testing.T) { // Tests that Store.DeleteConfirmation deletes the correct confirmation from // storage and that it cannot be loaded from storage. func TestStore_deleteConfirmation(t *testing.T) { - s := &Store{kv: versioned.NewKV(make(ekv.Memstore))} + s := &Store{kv: versioned.NewKV(ekv.MakeMemstore())} prng := rand.New(rand.NewSource(42)) grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(2)) diff --git a/auth/store/previousNegotiations_test.go b/auth/store/previousNegotiations_test.go index 2a19dc48ac8e1ec546c550e962a388ccfbfcb6c1..2d8234a45adf372b5883eb7bade2714f6574619a 100644 --- a/auth/store/previousNegotiations_test.go +++ b/auth/store/previousNegotiations_test.go @@ -8,6 +8,10 @@ package store import ( + "math/rand" + "reflect" + "testing" + "github.com/cloudflare/circl/dh/sidh" "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/client/storage/versioned" @@ -19,9 +23,6 @@ import ( "gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/primitives/id" - "math/rand" - "reflect" - "testing" ) // Tests the four possible cases of Store.CheckIfNegotationIsNew: @@ -36,7 +37,7 @@ import ( // Return newFingerprint = false, latest = true. func TestStore_AddIfNew(t *testing.T) { s := &Store{ - kv: versioned.NewKV(make(ekv.Memstore)), + kv: versioned.NewKV(ekv.MakeMemstore()), previousNegotiations: make(map[id.ID]bool), } prng := rand.New(rand.NewSource(42)) @@ -161,7 +162,7 @@ func TestStore_AddIfNew(t *testing.T) { // previousNegotiations in storage and any confirmations in storage. func TestStore_deletePreviousNegotiationPartner(t *testing.T) { s := &Store{ - kv: versioned.NewKV(make(ekv.Memstore)), + kv: versioned.NewKV(ekv.MakeMemstore()), previousNegotiations: make(map[id.ID]bool), } prng := rand.New(rand.NewSource(42)) @@ -257,7 +258,7 @@ func TestStore_deletePreviousNegotiationPartner(t *testing.T) { // via Store.savePreviousNegotiations andStore.newOrLoadPreviousNegotiations. func TestStore_savePreviousNegotiations_newOrLoadPreviousNegotiations(t *testing.T) { s := &Store{ - kv: versioned.NewKV(make(ekv.Memstore)), + kv: versioned.NewKV(ekv.MakeMemstore()), previousNegotiations: make(map[id.ID]bool), } prng := rand.New(rand.NewSource(42)) @@ -291,7 +292,7 @@ func TestStore_savePreviousNegotiations_newOrLoadPreviousNegotiations(t *testing // they do not exist. func TestStore_newOrLoadPreviousNegotiations_noNegotiations(t *testing.T) { s := &Store{ - kv: versioned.NewKV(make(ekv.Memstore)), + kv: versioned.NewKV(ekv.MakeMemstore()), previousNegotiations: make(map[id.ID]bool), } expected := make(map[id.ID]bool) @@ -339,7 +340,7 @@ func Test_marshalPreviousNegotiations_unmarshalPreviousNegotiations(t *testing.T // loaded from storage via Store.saveNegotiationFingerprints and // Store.loadNegotiationFingerprints. func TestStore_saveNegotiationFingerprints_loadNegotiationFingerprints(t *testing.T) { - s := &Store{kv: versioned.NewKV(make(ekv.Memstore))} + s := &Store{kv: versioned.NewKV(ekv.MakeMemstore())} rng := csprng.NewSystemRNG() grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(2)) diff --git a/auth/store/store_test.go b/auth/store/store_test.go index e6b14e7e08a40724668ce252054cc4d7591c4e85..e6391185827b42c8e7b5e096e9b756f8f102f10d 100644 --- a/auth/store/store_test.go +++ b/auth/store/store_test.go @@ -9,6 +9,12 @@ package store import ( "bytes" + "io" + "math/rand" + "reflect" + "sort" + "testing" + "github.com/cloudflare/circl/dh/sidh" "gitlab.com/elixxir/client/cmix/rounds" sidhinterface "gitlab.com/elixxir/client/interfaces/sidh" @@ -26,12 +32,6 @@ import ( "gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" - "io" - "math/rand" - "reflect" - "sort" - "testing" - "time" ) type mockSentRequestHandler struct{} @@ -41,7 +41,7 @@ func (msrh *mockSentRequestHandler) Delete(sr *SentRequest) {} // Happy path. func TestNewOrLoadStore(t *testing.T) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(2)) _, err := NewOrLoadStore(kv, grp, &mockSentRequestHandler{}) @@ -869,7 +869,7 @@ func TestStore_DeleteAllRequests(t *testing.T) { } func makeTestStore(t *testing.T) (*Store, *versioned.KV) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) grp := cyclic.NewGroup(large.NewInt(173), large.NewInt(0)) store, err := NewOrLoadStore(kv, grp, &mockSentRequestHandler{}) diff --git a/backup/backup_test.go b/backup/backup_test.go index 0c93f046b86815ac07428c4b88c5fc43899e1764..eeda3711c16697038f98228e228ee04c441ea627 100644 --- a/backup/backup_test.go +++ b/backup/backup_test.go @@ -439,13 +439,14 @@ func newTestBackup(password string, cb UpdateBackupFn, t *testing.T) *Backup { // Tests that Backup.InitializeBackup returns a new Backup with a copy of the // key and the callback. func Benchmark_InitializeBackup(t *testing.B) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) rngGen := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG) cbChan := make(chan []byte, 2) cb := func(encryptedBackup []byte) { cbChan <- encryptedBackup } expectedPassword := "MySuperSecurePassword" for i := 0; i < t.N; i++ { - _, err := InitializeBackup(expectedPassword, cb, &Container{}, + _, err := InitializeBackup(expectedPassword, cb, + &messenger.Container{}, newMockE2e(t), newMockSession(t), newMockUserDiscovery(), kv, rngGen) if err != nil { diff --git a/backup/jsonStorage_test.go b/backup/jsonStorage_test.go index d0207d910d76ffd73b5dfa1ff623996bf14c916b..352f6d2d6e595fe8a6fe49da48deda570cee647c 100644 --- a/backup/jsonStorage_test.go +++ b/backup/jsonStorage_test.go @@ -1,13 +1,14 @@ package backup import ( + "testing" + "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/ekv" - "testing" ) func Test_storeJson_loadJson(t *testing.T) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) json := "{'data': {'one': 1}}" err := storeJson(json, kv) diff --git a/backup/keyStorage_test.go b/backup/keyStorage_test.go index 939ca2c632fbf8d5ce41af81b158be0a3be7d4aa..95e7a08915f4255dfc742277cf47b72a5e97b470 100644 --- a/backup/keyStorage_test.go +++ b/backup/keyStorage_test.go @@ -8,16 +8,17 @@ package backup import ( + "testing" + "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/primitives/netTime" - "testing" ) // Tests that savePassword saves the password to storage by loading it and // comparing it to the original. func Test_savePassword(t *testing.T) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) expectedPassword := "MySuperSecurePassword" // Save the password @@ -42,7 +43,7 @@ func Test_savePassword(t *testing.T) { // Tests that loadPassword restores the original password saved to stage and // compares it to the original. func Test_loadPassword(t *testing.T) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) expectedPassword := "MySuperSecurePassword" // Save the password @@ -71,7 +72,7 @@ func Test_loadPassword(t *testing.T) { // Tests that deletePassword deletes the password from storage by trying to recover a // deleted password. func Test_deletePassword(t *testing.T) { - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) expectedPassword := "MySuperSecurePassword" // Save the password diff --git a/cmix/check_test.go b/cmix/check_test.go index 515b468cbb83b6127c2af09ac85f3f9fc9508181..5ab2aaf943aac5645d224e07d2e7bca3620caf21 100644 --- a/cmix/check_test.go +++ b/cmix/check_test.go @@ -1,13 +1,14 @@ package cmix import ( + "testing" + bloom "gitlab.com/elixxir/bloomfilter" "gitlab.com/elixxir/client/cmix/identity/receptionID/store" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/primitives/id" - "testing" ) // TestChecker tests the basic operation for Checker @@ -34,7 +35,7 @@ func TestChecker(t *testing.T) { } // Init a kv and a checked rounds structure - kv := versioned.NewKV(ekv.Memstore{}) + kv := versioned.NewKV(ekv.MakeMemstore()) cr, err := store.NewCheckedRounds(5, kv) if err != nil { t.Errorf("Failed to create checked rounds store: %+v", err) diff --git a/cmix/cmixMessageBuffer_test.go b/cmix/cmixMessageBuffer_test.go index 162a69baca54da69c84d4aba5cd170b597115cae..1a9189a689726d2a4eec07a1d629d622e66b4d10 100644 --- a/cmix/cmixMessageBuffer_test.go +++ b/cmix/cmixMessageBuffer_test.go @@ -9,22 +9,23 @@ package cmix import ( "bytes" + "math/rand" + "reflect" + "testing" + "gitlab.com/elixxir/client/storage/utility" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/ekv" "gitlab.com/elixxir/primitives/format" "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/netTime" - "math/rand" - "reflect" - "testing" ) // Test happy path of cmixMessageHandler.SaveMessage. func Test_cmixMessageHandler_SaveMessage(t *testing.T) { // Set up test values cmh := &cmixMessageHandler{} - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) testMsgs, ids, _ := makeTestCmixMessages(10) for i := range testMsgs { @@ -59,7 +60,7 @@ func Test_cmixMessageHandler_SaveMessage(t *testing.T) { func Test_cmixMessageHandler_LoadMessage(t *testing.T) { // Set up test values cmh := &cmixMessageHandler{} - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) testMsgs, ids, _ := makeTestCmixMessages(10) for i := range testMsgs { @@ -94,7 +95,7 @@ func Test_cmixMessageBuffer_Smoke(t *testing.T) { testMsgs, ids, _ := makeTestCmixMessages(2) // Create new buffer - kv := versioned.NewKV(make(ekv.Memstore)) + kv := versioned.NewKV(ekv.MakeMemstore()) cmb, err := NewOrLoadCmixMessageBuffer(kv, "testKey") if err != nil { t.Errorf("Failed to make new cmixMessageHandler: %+v", err) diff --git a/cmix/critical_test.go b/cmix/critical_test.go index 5f99738584f45a97a10094f4007d788055f64242..4126c57714955cbf446c4fab02c532eb0b159fd7 100644 --- a/cmix/critical_test.go +++ b/cmix/critical_test.go @@ -1,19 +1,20 @@ package cmix import ( + "testing" + "time" + "gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/ekv" "gitlab.com/elixxir/primitives/format" "gitlab.com/xx_network/primitives/id" - "testing" - "time" ) // TestCritical tests the basic functions of the critical messaging system func TestCritical(t *testing.T) { // Init mock structures & start thread - kv := versioned.NewKV(ekv.Memstore{}) + kv := versioned.NewKV(ekv.MakeMemstore()) mr := &mockRoundEventRegistrar{ statusReturn: true, } diff --git a/cmix/utils_test.go b/cmix/utils_test.go index 6fffb13db3f47dee64d71e89f6e254050d0318c0..533fe100b7b3490ca96d870be30a0bccb13acb95 100644 --- a/cmix/utils_test.go +++ b/cmix/utils_test.go @@ -7,6 +7,9 @@ package cmix import ( + "testing" + "time" + "github.com/pkg/errors" "gitlab.com/elixxir/client/cmix/gateway" "gitlab.com/elixxir/client/cmix/nodes" @@ -30,8 +33,7 @@ import ( "gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/ndf" - "testing" - "time" + "gitlab.com/xx_network/primitives/netTime" ) // mockManagerComms @@ -210,7 +212,7 @@ func mockFailCriticalSender(msg format.Message, recipient *id.ID, } func newTestClient(t *testing.T) (*client, error) { - kv := versioned.NewKV(ekv.Memstore{}) + kv := versioned.NewKV(ekv.MakeMemstore()) myID := id.NewIdFromString("zezima", id.User, t) comms, err := commClient.NewClientComms(myID, nil, nil, nil) if err != nil {