packagemetadataimport("math/rand""reflect""testing""github.com/ipfs/go-graphsync/testbridge""github.com/ipld/go-ipld-prime/linking/cid""github.com/ipfs/go-graphsync/testutil")funcTestDecodeEncodeMetadata(t*testing.T){cids:=testutil.GenerateCids(10)initialMetadata:=make(Metadata)for_,k:=rangecids{link:=cidlink.Link{Cid:k}blockPresent:=rand.Int31()%2==0initialMetadata[link]=blockPresent}bridge:=testbridge.NewMockIPLDBridge()encoded,err:=EncodeMetadata(initialMetadata,bridge)iferr!=nil{t.Fatal("Error encoding")}decodedMetadata,err:=DecodeMetadata(encoded,bridge)iferr!=nil{t.Fatal("Error decoding")}if!reflect.DeepEqual(initialMetadata,decodedMetadata){t.Fatal("Metadata changed during encoding and decoding")}}