Skip to content

test(order): cover mapInputItemToOfferItem branch behavior - #970

Closed
devorun wants to merge 1 commit into
ProjectOpenSea:mainfrom
devorun:test/map-input-item-to-offer-item
Closed

devorun wants to merge 1 commit into
ProjectOpenSea:mainfrom
devorun:test/map-input-item-to-offer-item

Conversation

@devorun

@devorun devorun commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

mapInputItemToOfferItem is the single normalizer every createOrder input item passes through on its way to a Seaport OfferItem, fanning a CreateInputItem out into the fully-populated { itemType, token, identifierOrCriteria, startAmount, endAmount } shape and applying the amount defaults each variant relies on.

It was previously only exercised indirectly through the hardhat-network-backed create-order specs. This adds fast, isolated unit tests in test/utils/order.spec.ts that pin its branch-by-branch behavior:

  • basic ERC721 items (both amounts default to 1)
  • basic ERC1155 items (endAmount defaults to the start amount; ascending amounts preserved)
  • criteria items given an explicit merkle root
  • criteria items whose root is derived from identifiers
  • currency items: token → ERC20, no token / zero-address → native, and descending end amounts preserved

Testing

  • hardhat test (all order util specs pass, 19 total)

Add unit tests for mapInputItemToOfferItem, the normalizer every
createOrder input item passes through on its way to a Seaport OfferItem.
It was previously only exercised indirectly through the hardhat-backed
create-order specs, so these fast, isolated units pin its per-variant
behavior: basic ERC721/ERC1155 items, criteria items (explicit root and
identifiers-derived merkle root), the amount defaults each variant
applies, and native vs ERC20 currency items.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.86%. Comparing base (f618d19) to head (c172d2a).
⚠️ Report is 364 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #970      +/-   ##
==========================================
+ Coverage   98.27%   98.86%   +0.59%     
==========================================
  Files          35       45      +10     
  Lines       14526    17775    +3249     
  Branches      660      913     +253     
==========================================
+ Hits        14276    17574    +3298     
+ Misses        245      194      -51     
- Partials        5        7       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ryanio

ryanio commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Taken, thanks. I checked all ten assertions against mapInputItemToOfferItem branch by branch and they match, including the zero-address-is-native case and the endAmount defaults.

Landing in #972, which stacks several contributions because four of them collided in test/utils/order.spec.ts. Yours needed a small conflict resolution against the salt-tag tests from #963 and nothing else. Your commit is in there authored by you. Closing in favor of that.

@ryanio ryanio closed this Aug 22, 2026
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.

3 participants