31 lines
944 B
Go
31 lines
944 B
Go
package delivery
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// 1357/AC2: a manifests value of 21 KB encodes and decodes with its manifest byte for byte. The manifest is a copy of
|
|
// mesh-catalog modules/mailu/module.json at origin/main c0880c4dc27194cbb99955579a97f3212c5be93e (20,713 bytes), the
|
|
// largest manifest of the catalogue.
|
|
func TestMailuManifestRoundTripBytesForByte(t *testing.T) {
|
|
raw, err := os.ReadFile("testdata/manifest-mailu.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(raw) != 20713 {
|
|
t.Fatalf("the fixture is %d bytes, the catalogue's is 20713", len(raw))
|
|
}
|
|
data, err := EncodeManifest(Manifest{Module: "mailu", JSON: string(raw)})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := DecodeManifest(data)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.JSON != string(raw) || ManifestDigest([]byte(got.JSON)) != ManifestDigest(raw) || got.Module != "mailu" {
|
|
t.Errorf("the manifest changed on the way: %d bytes", len(got.JSON))
|
|
}
|
|
}
|