MCPcopy Create free account
hub / github.com/WICG/webpackage / TestMapIsDeterministic

Function TestMapIsDeterministic

go/internal/cbor/deterministic_test.go:235–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

233}
234
235func TestMapIsDeterministic(t *testing.T) {
236 hello := multiappend([]byte{toCborHeader(TypeBytes, 5)}, []byte("hello"))
237 hello2 := multiappend([]byte{toCborHeader(TypeBytes, 6)}, []byte("hello2"))
238 testMap := multiappend([]byte{toCborHeader(TypeMap, 2)}, hello, uint24, hello2, uint4294967295)
239 cborSequenceMap := multiappend(testMap, testMap)
240
241 for _, testCase := range [][]byte{testMap, cborSequenceMap} {
242 if err := Deterministic(testCase); err != nil {
243 t.Error("Deterministically encoded CBOR map should not return false for deterministicy.")
244 }
245 }
246}
247
248func TestMapWithDuplicateKeysIsNotDeterministic(t *testing.T) {
249 hello := multiappend([]byte{toCborHeader(TypeBytes, 5)}, []byte("hello"))

Callers

nothing calls this directly

Calls 3

multiappendFunction · 0.85
toCborHeaderFunction · 0.85
DeterministicFunction · 0.85

Tested by

no test coverage detected