Skip to content

Commit

Permalink
log model stream id (#1176)
Browse files Browse the repository at this point in the history
* add logging of model cid string and tests to cover

* Update src/ancillary/__tests__/anchor-request-params-parser.test.ts

Co-authored-by: Spencer T Brody <[email protected]>

---------

Co-authored-by: Spencer T Brody <[email protected]>
  • Loading branch information
gvelez17 and stbrody authored Oct 24, 2023
1 parent 057158e commit 4efdcc3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/ancillary/__tests__/anchor-request-params-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const TIMESTAMP_ISO = '2023-01-25T17:32:42.971Z'

const FAKE_CACAO='test' // the p.domain of the cacao in our test blob

const FAKE_MODEL='kjzl6hvfrbw6c5ws6n17gx7zgb6veprsbb0b2m1x7x026rorhhu0mtuqz4d5zjn'

const LEGACY_REQUEST_EXAMPLE = mockRequest({
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -66,6 +68,15 @@ const CAR_FILE_REQUEST_EXAMPLE_SIGNED_GENESIS_WITH_CACAO = mockRequest({
),
})

const CAR_FILE_REQUEST_EXAMPLE_WITH_MODEL = mockRequest({
headers: {
'Content-Type': 'application/vnd.ipld.car',
},
body: bases['base64url'].decode(
'uOqJlcm9vdHOB2CpYJQABcRIgQtL_mq5jv6WdKws8V3DwrUhSUnms7JUdb0aT_3sFXDFndmVyc2lvbgGqAQFxEiBC0v-armO_pZ0rCzxXcPCtSFJSeazslR1vRpP_ewVcMaNjdGlw2CpYJgABhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-aHN0cmVhbUlkWCjOAQMBhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-aXRpbWVzdGFtcHgYMjAyMy0xMC0yM1QxNjo0MzowOS43MTlaugIBhQESIFXEyGyqkZ6hvYy558-KIMaMkhW5OEvuCqxXzx3z5_a-omdwYXlsb2FkWCQBcRIgtJJfzDZ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WV0aG9keGlkaWQ6a2V5Ono2TWtnaHZHSExvYkxFZGoxYmdSTGhTNExQR0pBdmJNQTF0bjJ6Y1J5cW1ZVTVMQyN6Nk1rZ2h2R0hMb2JMRWRqMWJnUkxoUzRMUEdKQXZiTUExdG4yemNSeXFtWVU1TENmaGVhZGVypGNzZXBlbW9kZWxlbW9kZWxYKM4BAgGFARIgI_-XRam_FzV3nlPWMV3YjqwzrNP3leux4_Fjpjd_sDNmdW5pcXVlTCkRWqdoKgigCq5F02tjb250cm9sbGVyc4F4OGRpZDprZXk6ejZNa3N3bXg2QjhCa3FhMUJ6a3NvdmNjWUhOZGtxc3U5R0hHUmJjMW1ucWg5UlJ4'
),
})


const CAR_FILE_INVALID = mockRequest({
headers: {
Expand Down Expand Up @@ -125,6 +136,16 @@ describe('AnchoRequestParamsParser', () => {

const params: RequestAnchorParams = (validation as Right<RequestAnchorParams>).right
expect(params.cacaoDomain).toEqual(FAKE_CACAO)
expect((params as RequestAnchorParamsV2).genesisFields.model).toBeUndefined()
})


test('parses CAR file with model properly', () => {
const validation = parser.parse(CAR_FILE_REQUEST_EXAMPLE_WITH_MODEL as ExpReq)
expect(isRight(validation)).toEqual(true)

const params: RequestAnchorParams = (validation as Right<RequestAnchorParams>).right
expect((params as RequestAnchorParamsV2).genesisFields.model.toString()).toEqual(FAKE_MODEL)
})

test('isleft indicates invalid car file', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/request-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class RequestService {
did,
schema: genesisFields?.schema,
family: genesisFields?.family,
model: genesisFields?.model,
model: genesisFields?.model?.toString() ?? '',
stream: request.streamId,
origin: request.origin,
cacao: 'cacaoDomain' in params ? params.cacaoDomain : '',
Expand Down

0 comments on commit 4efdcc3

Please sign in to comment.