-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: x-ar-io-root-transaction-id header #225
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -981,12 +981,19 @@ export class StandaloneSqliteDatabaseWorker { | |
const hash = dataRow?.hash; | ||
const dataRoot = coreRow?.data_root; | ||
|
||
const rootTransactionId = | ||
coreRow?.root_transaction_id !== null && | ||
coreRow?.root_transaction_id !== undefined | ||
Comment on lines
+985
to
+986
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checking for |
||
? toB64Url(coreRow.root_transaction_id) | ||
: undefined; | ||
|
||
return { | ||
hash: hash ? toB64Url(hash) : undefined, | ||
dataRoot: dataRoot ? toB64Url(dataRoot) : undefined, | ||
size: coreRow?.data_size ?? dataRow?.data_size, | ||
contentType, | ||
contentEncoding: coreRow?.content_encoding, | ||
contentType, | ||
rootTransactionId, | ||
isManifest: contentType === MANIFEST_CONTENT_TYPE, | ||
stable: coreRow?.stable === true, | ||
verified: dataRow?.verified === 1, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -672,6 +672,65 @@ st | |
}); | ||
}); | ||
}); | ||
|
||
describe('X-AR-IO-Root-Transaction-Id', () => { | ||
it("shouldn't return root transaction id for transactions", async () => { | ||
app.get( | ||
'/:id', | ||
createDataHandler({ | ||
log, | ||
dataIndex, | ||
dataSource, | ||
blockListValidator, | ||
manifestPathResolver, | ||
}), | ||
); | ||
|
||
return request(app) | ||
.get('/not-a-real-id') | ||
.expect(200) | ||
.then((res: any) => { | ||
assert.equal( | ||
res.headers['x-ar-io-root-transaction-id'], | ||
undefined, | ||
); | ||
}); | ||
}); | ||
|
||
it('should return root transaction id for data items', async () => { | ||
dataIndex.getDataAttributes = () => | ||
Promise.resolve({ | ||
size: 10, | ||
contentType: 'application/octet-stream', | ||
rootTransactionId: 'root-tx', | ||
isManifest: false, | ||
stable: true, | ||
verified: true, | ||
signature: null, | ||
}); | ||
|
||
app.get( | ||
'/:id', | ||
createDataHandler({ | ||
log, | ||
dataIndex, | ||
dataSource, | ||
blockListValidator, | ||
manifestPathResolver, | ||
}), | ||
); | ||
|
||
return request(app) | ||
.get('/not-a-real-id') | ||
.expect(200) | ||
.then((res: any) => { | ||
assert.equal( | ||
res.headers['x-ar-io-root-transaction-id'], | ||
'root-tx', | ||
); | ||
}); | ||
}); | ||
}); | ||
Comment on lines
+676
to
+733
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding more test cases for comprehensive coverage. The new test cases for the X-AR-IO-Root-Transaction-Id header are well-implemented and cover the main scenarios. To further improve the test suite, consider adding the following test cases:
These additional tests would provide more comprehensive coverage and help catch potential edge cases. |
||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to
null AS data_root
for readability