Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Dec 10, 2022
1 parent 9c8b465 commit 2c78fd7
Showing 1 changed file with 3 additions and 61 deletions.
64 changes: 3 additions & 61 deletions pkg/sharding/ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,63 +72,6 @@ func TestNewLogRanges(t *testing.T) {
}
}

func TestLogRangesFromPath(t *testing.T) {
contents := `
- treeID: 0001
treeLength: 3
encodedPublicKey: c2hhcmRpbmcK
- treeID: 0002
treeLength: 4`
file := filepath.Join(t.TempDir(), "sharding-config")
if err := os.WriteFile(file, []byte(contents), 0o644); err != nil {
t.Fatal(err)
}
expected := Ranges{
{
TreeID: 1,
TreeLength: 3,
EncodedPublicKey: "c2hhcmRpbmcK",
}, {
TreeID: 2,
TreeLength: 4,
},
}

got, err := logRangesFromPath(file)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, got) {
t.Fatalf("expected %v got %v", expected, got)
}
}

func TestLogRangesFromPathJSON(t *testing.T) {
contents := `[{"treeID": 0001, "treeLength": 3, "encodedPublicKey":"c2hhcmRpbmcK"}, {"treeID": 0002, "treeLength": 4}]`
file := filepath.Join(t.TempDir(), "sharding-config")
if err := os.WriteFile(file, []byte(contents), 0o644); err != nil {
t.Fatal(err)
}
expected := Ranges{
{
TreeID: 1,
TreeLength: 3,
EncodedPublicKey: "c2hhcmRpbmcK",
}, {
TreeID: 2,
TreeLength: 4,
},
}

got, err := logRangesFromPath(file)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, got) {
t.Fatalf("expected %v got %v", expected, got)
}
}

func TestLogRanges_ResolveVirtualIndex(t *testing.T) {
lrs := LogRanges{
inactive: []LogRange{
Expand Down Expand Up @@ -397,7 +340,7 @@ func TestLogRanges_AllShards(t *testing.T) {
}
}

func Test_logRangesFromPath(t *testing.T) {
func TestLogRangesFromPath(t *testing.T) {
type args struct {
path string
}
Expand Down Expand Up @@ -472,7 +415,6 @@ func Test_logRangesFromPath(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create temp file: %v", err)
}
defer os.Remove(f.Name())
switch {
case tt.wantJSON:
if err := json.NewEncoder(f).Encode(tt.want); err != nil {
Expand Down Expand Up @@ -506,7 +448,7 @@ func Test_logRangesFromPath(t *testing.T) {
}
}

func Test_updateRange(t *testing.T) {
func TestUpdateRange(t *testing.T) {
type args struct {
ctx context.Context
r LogRange
Expand Down Expand Up @@ -572,7 +514,7 @@ func Test_updateRange(t *testing.T) {
}
}

func TestNewLogRanges1(t *testing.T) {
func TestNewLogRangesWithMock(t *testing.T) {
type args struct {
ctx context.Context
path string
Expand Down

0 comments on commit 2c78fd7

Please sign in to comment.