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

Function TestLongArrayIsDeterministic

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

Source from the content-addressed store, hash-verified

196}
197
198func TestLongArrayIsDeterministic(t *testing.T) {
199 const numOfItems = 24
200 longArr := make([]byte, 2 /*=num of startBytes*/ +len(uint45)*numOfItems)
201 longArr[0] = toCborHeader(TypeArray, 24) // ARR (4) + ONE_BYTE (24)
202 longArr[1] = byte(numOfItems)
203
204 // Fill in the byte array with 24 times uint45 bytes.
205 for i := 2; i < len(longArr); i += len(uint45) {
206 for j := 0; j < len(uint45); j++ {
207 longArr[i+j] = uint45[j]
208 }
209 }
210
211 cborSequenceArray := multiappend(longArr, longArr)
212
213 for _, testCase := range [][]byte{longArr, cborSequenceArray} {
214 if err := Deterministic(testCase); err != nil {
215 t.Error("Deterministically encoded CBOR array should not return false for deterministicy.")
216 }
217 }
218}
219
220func TestArraysNumberOfItemsIsWrong(t *testing.T) {
221 // There is one item too little. The additional information claims that there are 5 but there are only 4.

Callers

nothing calls this directly

Calls 3

toCborHeaderFunction · 0.85
multiappendFunction · 0.85
DeterministicFunction · 0.85

Tested by

no test coverage detected