-
Notifications
You must be signed in to change notification settings - Fork 6
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
test: pallet api fungibles #278
Conversation
Co-authored-by: Daanvdplas <daanvdplas@live.nl>
…runtime_versioning
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## daan/api #278 +/- ##
============================================
+ Coverage 48.89% 51.03% +2.13%
============================================
Files 47 47
Lines 4532 4701 +169
Branches 4532 4701 +169
============================================
+ Hits 2216 2399 +183
Misses 2254 2254
+ Partials 62 48 -14
|
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 coverage on this! Left a few small improvement comments.
The main reason we have this pallet in-between contracts <> pallet-assets, is so we can control if anything changes. So, I think testing the integrity of our errors, dispatchables, and parameters is crucial to ensure further upgrades don't break anything
So, my recommendation is this:
- Please create a test for
errors
in pallets-assets. This test will simplyassert_eq!()
each error to its encoded index. For exampleassert_eq!(Error::BalanceLow::encode(), 0)
(theencode()
bit will need tweaking). May also be useful to validate the total variants in an enum - Please create a test to verify codec indexes of
Read
. Once again, simpleassert_eq!()
from each entry to its index. So, assertRead::TotalSupply
=index 0
- Please assert every dispatchable
call_index
to numbers, in our pallet and pallet-assets.
If we want to do this after we merge pop-api into main, that is fine. But these tests should hopefully be pretty easy, and are crucial to ensuring our API remains stable.
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.
Not sure if this was supposed to be reviewed.
ca71ec6
to
497b2f7
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.
LGTM!
// Approves a value to spend that is equal to the current allowance. | ||
assert_eq!( | ||
Fungibles::approve(signed(owner), token, spender, value / 2), | ||
Ok(Some(WeightInfo::approve(0, 0)).into()) |
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.
See here for test that the weight is properly returned
pallet_assets_...
like inpop-api/integrations-tests