Skip to content
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

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Fee extraction tests + refactor #1396

merged 1 commit into from
Jul 2, 2024

Conversation

grod220
Copy link
Collaborator

@grod220 grod220 commented Jul 2, 2024

Some follow up after #1165

After pairing with @vacekj, noticed a few areas of improvement with type checking + test coverage

Copy link

changeset-bot bot commented Jul 2, 2024

🦋 Changeset detected

Latest commit: 9e09226

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@penumbra-zone/services Minor
@penumbra-zone/wasm Patch
@penumbra-zone/perspective Patch
@penumbra-zone/query Patch
@penumbra-zone/storage Patch
minifront Patch

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

@grod220 grod220 force-pushed the fee-extraction-tests branch from 5cfdb0d to 9e09226 Compare July 2, 2024 13:25
Copy link
Collaborator Author

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.

@grod220 grod220 requested a review from TalDerei July 2, 2024 13:32
@grod220 grod220 self-assigned this Jul 2, 2024
Comment on lines +6 to +8
export const extractAltFee = (request: TransactionPlannerRequest): AssetId => {
const outputAsset = request.outputs.map(o => o.value?.assetId).find(Boolean);
if (outputAsset) return outputAsset;
Copy link
Contributor

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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great unit testing!

@grod220 grod220 merged commit 2f1c39f into main Jul 2, 2024
6 checks passed
@grod220 grod220 deleted the fee-extraction-tests branch July 2, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants