libs/log: format []byte as hexidecimal string (uppercased) (#5960)

Closes: #5806 

Co-authored-by: Lanie Hei <heixx011@umn.edu>
This commit is contained in:
Anton Kaliaev
2021-01-25 16:25:29 +04:00
committed by GitHub
co-authored by Lanie Hei
parent 7e0436c6e6
commit d76add65a6
12 changed files with 130 additions and 39 deletions
+8 -1
View File
@@ -3,6 +3,7 @@ package bytes
import (
"encoding/json"
"fmt"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
@@ -24,7 +25,6 @@ func TestMarshal(t *testing.T) {
// Test that the hex encoding works.
func TestJSONMarshal(t *testing.T) {
type TestStruct struct {
B1 []byte
B2 HexBytes
@@ -64,3 +64,10 @@ func TestJSONMarshal(t *testing.T) {
})
}
}
func TestHexBytes_String(t *testing.T) {
hs := HexBytes([]byte("test me"))
if _, err := strconv.ParseInt(hs.String(), 16, 64); err != nil {
t.Fatal(err)
}
}