diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-09-13 12:56:08 +0200 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-09-13 12:56:08 +0200 |
commit | 4f01edb9230f58ff84b0dd892c931ec8ac9aad55 (patch) | |
tree | 9c1598a3f98203913ac2548883c02a81deb33dc7 /srv/src/pow/store_test.go | |
parent | 5485984e05aebde22819adebfbd5ad51475a6c21 (diff) |
move src out of srv, clean up default.nix and Makefile
Diffstat (limited to 'srv/src/pow/store_test.go')
-rw-r--r-- | srv/src/pow/store_test.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/srv/src/pow/store_test.go b/srv/src/pow/store_test.go deleted file mode 100644 index 324a40c..0000000 --- a/srv/src/pow/store_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package pow - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/tilinna/clock" -) - -func TestStore(t *testing.T) { - clock := clock.NewMock(time.Now().Truncate(time.Hour)) - now := clock.Now() - - s := NewMemoryStore(clock) - defer s.Close() - - seed := []byte{0} - - // mark solved should work - err := s.MarkSolved(seed, now.Add(time.Second)) - assert.NoError(t, err) - - // mark again, should not work - err = s.MarkSolved(seed, now.Add(time.Hour)) - assert.ErrorIs(t, err, ErrSeedSolved) - - // marking a different seed should still work - seed2 := []byte{1} - err = s.MarkSolved(seed2, now.Add(inMemStoreGCPeriod*2)) - assert.NoError(t, err) - err = s.MarkSolved(seed2, now.Add(time.Hour)) - assert.ErrorIs(t, err, ErrSeedSolved) - - now = clock.Add(inMemStoreGCPeriod) - <-s.(*inMemStore).spinLoopCh - - // first one should be markable again, second shouldnt - err = s.MarkSolved(seed, now.Add(time.Second)) - assert.NoError(t, err) - err = s.MarkSolved(seed2, now.Add(time.Hour)) - assert.ErrorIs(t, err, ErrSeedSolved) - - now = clock.Add(inMemStoreGCPeriod) - <-s.(*inMemStore).spinLoopCh - - // now both should be expired - err = s.MarkSolved(seed, now.Add(time.Second)) - assert.NoError(t, err) - err = s.MarkSolved(seed2, now.Add(time.Second)) - assert.NoError(t, err) -} |