Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

encoding/mvt: remove use of crypto/md5 to compare marshalling in tests #118

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions encoding/mvt/marshal_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package mvt

import (
"crypto/md5"
"encoding/hex"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -542,17 +541,13 @@ func TestMarshal_ID(t *testing.T) {

func TestStableMarshalling(t *testing.T) {
layers := NewLayers(loadGeoJSON(t, maptile.New(17896, 24449, 16)))
values := make(map[string]bool)

firstData, _ := Marshal(layers)
for i := 0; i < 100; i++ {
marshal, _ := Marshal(layers)
checksum := md5.Sum(marshal)
sum := hex.EncodeToString(checksum[:])
values[sum] = true
}

if len(values) != 1 {
t.Errorf("multiple values (%d) for marshalled bytes", len(values))
data, _ := Marshal(layers)
if !bytes.Equal(data, firstData) {
t.Errorf("a marshal had different bytes")
}
}
}

Expand Down