Skip to content

Commit

Permalink
Revert "move invalid carfile tests to separate PR" (#1162)
Browse files Browse the repository at this point in the history
* Revert "move invalid carfile tests to separate PR"

This reverts commit d82ee7b.

* invalid car file produces isLeft; cannot decode throws error

* ok an invalid carfile has isLeft, but what about some random string?

* remove duplicate coverage test
  • Loading branch information
gvelez17 authored Sep 11, 2023
1 parent d82ee7b commit a066900
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/ancillary/__tests__/anchor-request-params-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { bases } from 'multiformats/basics'
import { GenesisFields } from '../../models/metadata.js'
import { asDIDString } from '@ceramicnetwork/codecs'
import { mockRequest } from '../../controllers/__tests__/mock-request.util.js'
import { isRight, type Right } from 'codeco'
import { isRight, isLeft, type Right } from 'codeco'

const FAKE_SIGNED_STREAM_ID = StreamID.fromString(
'k2t6wzhkhabz5h9xxyrc6qoh1mcj6b0ul90xxkoin4t5bns89e3vh0gyyy1exj'
Expand Down Expand Up @@ -67,6 +67,17 @@ const CAR_FILE_REQUEST_EXAMPLE_SIGNED_GENESIS_WITH_CAPCID = mockRequest({
),
})


const CAR_FILE_INVALID = mockRequest({
headers: {
'Content-Type': 'application/vnd.ipld.car',
},
body: bases['base64url'].decode(
'uQ3JlYXRlZEJ5Q2hhdEdQVDRZb3VjYW5Vc2VUaGlzU3RyaW5n'
),
})


const CAR_FILE_FAKE_GENESIS_FIELDS: GenesisFields = {
controllers: [asDIDString('did:pkh:eip155:1:0x926eeb192c18b7be607a7e10c8e7a7e8d9f70742')],
model: StreamID.fromBytes(
Expand Down Expand Up @@ -117,4 +128,9 @@ describe('AnchoRequestParamsParser', () => {
expect(params.capCID).toEqual(FAKE_CAPCID)
})

test('isleft indicates invalid car file', () => {
const validation = parser.parse(CAR_FILE_INVALID as ExpReq)
expect(isLeft(validation)).toBeTruthy()
})

})

0 comments on commit a066900

Please sign in to comment.