Skip to content

Commit

Permalink
Fix UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Sep 12, 2023
1 parent 8a8e0eb commit a51fb04
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions registration/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestInsertAndGetProof(t *testing.T) {
tempdir := t.TempDir()
db, err := newDatabase(tempdir, []byte{})
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, db.Close()) })

require.NoError(t, db.SaveProof(context.Background(), shared.NIP{Epoch: 1}, [][]byte{}))
proof, err := db.GetProof(context.Background(), "1")
Expand Down
2 changes: 1 addition & 1 deletion registration/registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestRecoveringRoundInProgress(t *testing.T) {

roundCfg := server.RoundConfig{
EpochDuration: time.Hour,
PhaseShift: time.Second / 2,
PhaseShift: time.Second,
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
1 change: 1 addition & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ func TestLoadSubmits(t *testing.T) {
cfg.Round.EpochDuration = time.Minute * 2
cfg.Round.PhaseShift = time.Minute
cfg.RawRPCListener = randomHost
cfg.RawRESTListener = randomHost
cfg, err := server.SetupConfig(cfg)
req.NoError(err)

Expand Down
7 changes: 6 additions & 1 deletion service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package service_test
import (
"bytes"
"context"
"errors"
"os"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -217,7 +219,10 @@ func TestRecoverFinishedRound(t *testing.T) {
}, time.Second, time.Millisecond)

req.Equal(uint(9876), proof.Epoch)
req.NoDirExists(filepath.Join(datadir, "rounds", "9876"))
req.Eventually(func() bool {
_, err := os.Lstat(filepath.Join(datadir, "rounds", "9876"))
return errors.Is(err, os.ErrNotExist)
}, time.Second, 10*time.Millisecond)

cancel()
req.NoError(eg.Wait())
Expand Down
1 change: 1 addition & 0 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func Load(filename string, v any) error {
if err != nil {
return fmt.Errorf("loading file: %w", err)
}
defer f.Close()

_, err = xdr.Unmarshal(f, v)
if err != nil {
Expand Down

0 comments on commit a51fb04

Please sign in to comment.