Skip to content

Commit

Permalink
fix decoding test on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored and mvdan committed Dec 3, 2020
1 parent 5fe5af6 commit eb51193
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion btc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"encoding/hex"
"fmt"
"io/ioutil"
"runtime"
"strings"
"testing"
)

Expand All @@ -16,8 +18,14 @@ func TestBlockMessageDecoding(t *testing.T) {
if err != nil {
t.Fatal(err)
}
var hexString string
if runtime.GOOS == "windows" {
hexString = strings.TrimSuffix(string(hexdata), "\r\n")
} else {
hexString = strings.TrimSuffix(string(hexdata), "\n") // for non-windows
}

data, err := hex.DecodeString(string(hexdata[:len(hexdata)-1]))
data, err := hex.DecodeString(hexString)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit eb51193

Please sign in to comment.