Skip to content

Commit

Permalink
fix: remove repetitive auditing
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev committed May 24, 2024
1 parent 26f1b02 commit 73d3299
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/model/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ class QuotesModel {
// if we got here rules passed, so we can forward the quote on to the recipient dfsp
const childSpan = span.getChild('qs_quote_forwardQuoteUpdateResend')
try {
await childSpan.audit({ headers, params: { quoteId }, payload: quoteUpdate }, EventSdk.AuditEventAction.start)
histTimer({ success: true, queryName: 'quote_handleQuoteUpdateResend' })
await this.forwardQuoteUpdate(headers, quoteId, quoteUpdate, childSpan)
} catch (err) {
Expand Down
9 changes: 3 additions & 6 deletions test/unit/model/quotes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ describe('QuotesModel', () => {
})

it('forward quote update', async () => {
expect.assertions(5)
expect.assertions(4)

mockChildSpan.isFinished = false

Expand All @@ -1725,13 +1725,12 @@ describe('QuotesModel', () => {
.toBe(undefined)

expect(mockSpan.getChild).toBeCalled()
expect(mockChildSpan.audit).toBeCalled()
const args = [mockData.headers, mockData.quoteId, mockData.quoteUpdate, mockChildSpan]
expect(quotesModel.forwardQuoteUpdate).toBeCalledWith(...args)
expect(mockChildSpan.finish).toBeCalled()
})
it('handle fspiopError when forward quote fails', async () => {
expect.assertions(4)
expect.assertions(3)

mockChildSpan.isFinished = true
const fspiopError = ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.DESTINATION_FSP_ERROR)
Expand All @@ -1741,13 +1740,12 @@ describe('QuotesModel', () => {
.resolves
.toBe(undefined)

expect(mockChildSpan.audit).toBeCalled()
const args = [mockData.headers['fspiop-source'], mockData.quoteId, fspiopError, mockData.headers, mockChildSpan]
expect(quotesModel.handleException).toBeCalledWith(...args)
expect(mockChildSpan.finish).not.toBeCalled()
})
it('handle custom error without stack when forward quote fails', async () => {
expect.assertions(4)
expect.assertions(3)

mockChildSpan.isFinished = true
const customErrorNoStack = new Error('Custom error')
Expand All @@ -1758,7 +1756,6 @@ describe('QuotesModel', () => {
.resolves
.toBe(undefined)

expect(mockChildSpan.audit).toBeCalled()
const args = [mockData.headers['fspiop-source'], mockData.quoteId, customErrorNoStack, mockData.headers, mockChildSpan]
expect(quotesModel.handleException).toBeCalledWith(...args)
expect(mockChildSpan.finish).not.toBeCalled()
Expand Down

0 comments on commit 73d3299

Please sign in to comment.