From 2742cd8867070cc81f694e294acf5c06ffd20ba8 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Sun, 30 Oct 2022 08:19:30 +0100 Subject: [PATCH] fix Go tests - merkletree: fix broken test case - fixtures: fix compatibility with Bazel --- cmd/radiance/car/create/create.go | 2 ++ fixtures/shreds.go | 2 +- pkg/merkletree/merkletree_test.go | 10 +++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/radiance/car/create/create.go b/cmd/radiance/car/create/create.go index 0b74d71..148a0ba 100644 --- a/cmd/radiance/car/create/create.go +++ b/cmd/radiance/car/create/create.go @@ -1,3 +1,5 @@ +//go:build rocksdb + package create import ( diff --git a/fixtures/shreds.go b/fixtures/shreds.go index 8a016b5..c15ff00 100644 --- a/fixtures/shreds.go +++ b/fixtures/shreds.go @@ -29,7 +29,7 @@ func shreds(t testing.TB, network string, slot uint64, shredType rune) [][]byte }) var shreds [][]byte for _, entry := range entries { - if !entry.Type().IsRegular() { + if entry.Type().IsDir() { continue } name := entry.Name() diff --git a/pkg/merkletree/merkletree_test.go b/pkg/merkletree/merkletree_test.go index d3d508b..0348988 100644 --- a/pkg/merkletree/merkletree_test.go +++ b/pkg/merkletree/merkletree_test.go @@ -14,7 +14,7 @@ func TestHashNodes(t *testing.T) { }{ "Empty": { leaves: nil, - root: "0000000000000000000000000000000000000000000000000000000000000000", + root: "", }, "One": { leaves: [][]byte{[]byte("test")}, @@ -38,7 +38,11 @@ func TestHashNodes(t *testing.T) { for _, node := range actual.Nodes { t.Log(hex.EncodeToString(node[:])) } - assert.Equal(t, tc.root, hex.EncodeToString(actualRoot[:])) + if tc.root == "" { + assert.Nil(t, actualRoot) + } else { + assert.Equal(t, tc.root, hex.EncodeToString(actualRoot[:])) + } }) } } @@ -47,5 +51,5 @@ func TestHashNodes_One(t *testing.T) { input := []byte("test") actual := HashNodes([][]byte{input}) expected := HashLeaf(input) - assert.Equal(t, expected, actual.GetRoot()) + assert.Equal(t, expected, *actual.GetRoot()) }