-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fee extraction tests + refactor #1396
Conversation
🦋 Changeset detectedLatest commit: 9e09226 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5cfdb0d
to
9e09226
Compare
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.
For this file, focused on trying to accomplish the equivalent logic without manual type casting. Also, used map+find to cover cases where asset ids may be on some notes and not others of the same category.
export const extractAltFee = (request: TransactionPlannerRequest): AssetId => { | ||
const outputAsset = request.outputs.map(o => o.value?.assetId).find(Boolean); | ||
if (outputAsset) return outputAsset; |
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.
I quite like this map + find pattern here. I manually confirmed that the logic is equivalent.
import { extractAltFee } from './fees'; | ||
import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb'; | ||
|
||
describe('extractAltFee', () => { |
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.
great unit testing!
Some follow up after #1165
After pairing with @vacekj, noticed a few areas of improvement with type checking + test coverage