diff --git a/go.mod b/go.mod index c5b3f3b2b6c2218299e6187362b3ebcc64364aca..cb12a1912af2fd850c13bc7c4c96a200eb9b459f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( gitlab.com/elixxir/comms v0.0.0-20201006010513-3353fb46569a gitlab.com/elixxir/crypto v0.0.0-20201006010428-67a8782d097e gitlab.com/elixxir/ekv v0.1.3 - gitlab.com/elixxir/primitives v0.0.0-20201006010327-c2f93eb587e3 + gitlab.com/elixxir/primitives v0.0.0-20201007182231-b9aef2de8219 gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6 gitlab.com/xx_network/crypto v0.0.0-20200812183430-c77a5281c686 gitlab.com/xx_network/primitives v0.0.0-20200915204206-eb0287ed0031 diff --git a/go.sum b/go.sum index bc3daf358dcb89578dbcb0231ccae9a6fce7d341..8cc0d6f662861956a3745ff8fcc0ceabf0fecfa3 100644 --- a/go.sum +++ b/go.sum @@ -369,6 +369,8 @@ gitlab.com/elixxir/primitives v0.0.0-20201005231810-020916f67bd6 h1:ZE7ee4VIr7j4 gitlab.com/elixxir/primitives v0.0.0-20201005231810-020916f67bd6/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE= gitlab.com/elixxir/primitives v0.0.0-20201006010327-c2f93eb587e3 h1:nQG+LWzYfXiDT+4xPQ2U9sHUM6J51zmL220aSjIEvx4= gitlab.com/elixxir/primitives v0.0.0-20201006010327-c2f93eb587e3/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE= +gitlab.com/elixxir/primitives v0.0.0-20201007182231-b9aef2de8219 h1:/5r1oFeLCv3XohMoHOflZjZdoGQC82v/rjeSkK7a/PU= +gitlab.com/elixxir/primitives v0.0.0-20201007182231-b9aef2de8219/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2YKnw5c+LJCE= gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba h1:7nozLSNBX0CfP53DDiDNLJx9obhYGfGf5na0/c9rMso= gitlab.com/xx_network/comms v0.0.0-20200806235452-3a82720833ba/go.mod h1:idLzPGYig57XE7xuU93OlIF9s6NgSJj7OArQvsd5DjY= diff --git a/storage/utility/knownRounds_test.go b/storage/utility/knownRounds_test.go index b3d620392e8f3c4604ba60b605a8af42634db2e5..624079da5afe7fb6de5e5c2fa4fd751760db74d0 100644 --- a/storage/utility/knownRounds_test.go +++ b/storage/utility/knownRounds_test.go @@ -33,46 +33,42 @@ func TestNewKnownRounds(t *testing.T) { } } -// // Tests happy path of LoadKnownRounds. -// func TestLoadKnownRounds(t *testing.T) { -// // Set up expected value -// size := 10 -// rootKv := versioned.NewKV(make(ekv.Memstore)) -// expectedKR := &KnownRounds{ -// rounds: knownRounds.NewKnownRound(size), -// kv: rootKv.Prefix(knownRoundsPrefix), -// key: "testKey", -// } +// Tests happy path of LoadKnownRounds. +func TestLoadKnownRounds(t *testing.T) { + // Set up expected value + size := 10 + rootKv := versioned.NewKV(make(ekv.Memstore)) + expectedKR := &KnownRounds{ + rounds: knownRounds.NewKnownRound(size), + kv: rootKv.Prefix(knownRoundsPrefix), + key: "testKey", + } -// // Check rounds in the buffer and save the key value store -// expectedKR.rounds.Check(id.Round(0)) -// for i := 0; i < (size * 64); i++ { -// if i%7 == 0 { -// t.Errorf("%+v", -// expectedKR.rounds) -// expectedKR.rounds.Check(id.Round(i)) -// } -// } -// err := expectedKR.save() -// if err != nil { -// t.Fatalf("Error saving KnownRounds: %v", err) -// } + // Check rounds in the buffer and save the key value store + expectedKR.rounds.Check(id.Round(0)) + for i := 0; i < (size * 64); i++ { + if i%7 == 0 { + expectedKR.rounds.Check(id.Round(i)) + } + } + err := expectedKR.save() + if err != nil { + t.Fatalf("Error saving KnownRounds: %v", err) + } -// // *63 here instead of *64 because the calculation on the initializer -// // in primitives is weird, and we need the exact size for DeepEqual -// kr, err := LoadKnownRounds(rootKv, expectedKR.key, size*63) -// if err != nil { -// t.Errorf("LoadKnownRounds() returned an error."+ -// "\n\texpected: %v\n\treceived: %+v", nil, err) -// } + kr, err := LoadKnownRounds(rootKv, expectedKR.key, size) + if err != nil { + t.Errorf("LoadKnownRounds() returned an error."+ + "\n\texpected: %v\n\treceived: %+v", nil, err) + } -// if !reflect.DeepEqual(expectedKR, kr) { -// t.Errorf("LoadKnownRounds() returned an incorrect KnownRounds."+ -// "\n\texpected: %+v\n\treceived: %+v", expectedKR, kr) -// t.Errorf("%+v != \n%+v", -// expectedKR.rounds, kr.rounds) -// } -// } + if !reflect.DeepEqual(expectedKR, kr) { + t.Errorf("LoadKnownRounds() returned an incorrect KnownRounds."+ + "\n\texpected: %+v\n\treceived: %+v", expectedKR, kr) + t.Errorf("%+v != \n%+v", + expectedKR.rounds, kr.rounds) + } +} // Tests happy path of KnownRounds.save(). func TestKnownRounds_save(t *testing.T) {