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

test: add integration tests for nft permissions #549

Merged
merged 11 commits into from
Aug 22, 2022

Conversation

Roznovjak
Copy link
Collaborator

No description provided.

@Roznovjak Roznovjak self-assigned this Aug 18, 2022
@mrq1911
Copy link
Member

mrq1911 commented Aug 18, 2022

@github-actions
Copy link

github-actions bot commented Aug 18, 2022

Crate versions that have been updated:

  • runtime-integration-tests: v0.7.3 -> v0.7.4

Runtime version has not been increased.

@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #549 (482d2bb) into master (1ecdde9) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #549   +/-   ##
=======================================
  Coverage   81.22%   81.22%           
=======================================
  Files          19       19           
  Lines        1928     1928           
=======================================
  Hits         1566     1566           
  Misses        362      362           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

integration-tests/src/nft_marketplace.rs Outdated Show resolved Hide resolved
integration-tests/src/nft_marketplace.rs Outdated Show resolved Hide resolved
#[test_case(ClassType::Redeemable, false ; "redeemable class")]
#[test_case(ClassType::Auction, false ; "auction class")]
#[test_case(ClassType::HydraHeads, false ; "hydra heads class")]
fn nft_permissions_should_allow_marketplace_class_creation(class_type: ClassType, is_allowed: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great job with the tests!

Just one thing as stated in one of my other comments, we could make this even more readable by introducing two consts:

const ALLOW: bool = true;
const NOT_ALLOW: bool = false;

And using these in the test_case attributes. By doing this, we could remove the magic booleans. But as you want, I approve the PR anyway. ;)

#[test_case(ClassType::Redeemable; "redeemable class")]
#[test_case(ClassType::Auction; "auction class")]
#[test_case(ClassType::HydraHeads; "hydra heads class")]
fn create_class_should_be_without_deposit_when_created_using_trait(class_type: ClassType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to have tests like this also for the rest of the trait’s functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok. But in this case we are not talking about integration tests because we are just testing one implementation of the traits and there is no interaction with other pallets involved. And testing the implementation of it implies that it will also work when integrated into other pallets. So I would add tests for this directly to NFT pallet in warehouse repo. @dmoka what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my opinion this should be in the basilisk repo in the nft integration test (not in the marketplace).
e.g if someone removes classType or changes permissions in the warehouse and updates tests in the warehouse, we may not catch it. It's the same situations as we had with minting without deposits, warehouse repo was updated and merged and we found problem after we tried to use NFT pallet in LM.

In my opinion this is integration test because it test integration of NFT pallet in basilisk chain with basilisk specific requirements.

Copy link
Contributor

@dmoka dmoka Aug 19, 2022

Choose a reason for hiding this comment

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

The generic core logic that we are testing here is basically this:

/~https://github.com/galacticcouncil/warehouse/blob/85257f53b0da5827c103bf4f739474cc1e83d3f7/nft/src/types.rs#L75

But we are actually testing how this pallet_nft is configured/integrated within Basilisk runtime, because we run this:

<basilisk_runtime::Runtime as pallet_nft::Config>::Permissions::...

... with ClassType enum used in the basilisk runtime pallet_nft config implementation

So I think this is fine as an integration test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just reading @martinfridrich's answer, I agree with that, as it is not only related to marketplace, we could put them into a separate integration test file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm. Ok. But I would prefer to have tests next to implementations. Right now we use structs and trait implementations from warehouse crate and test them in Basilisk repo. And we will need to do the same in Hydra repo. In my opinion the best solution would be to not use generic names for structs and traits (e.g. CreateTypedClassWithoutPermissionCheck). Then we don't need to be afraid of some changes in warehouse repo. But I'm totally fine with what you agreed on.

@martinfridrich
Copy link
Contributor

This tests are not specific to marketplace, I think they should be in separate NFT integration tests

);
}

// Nonfungibles traits
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, now when I'm looking at it you were right. This look more like unit tests, tested code is not using permissions at all. I should look at nft implementation first, sorry.
I think they should be in warehosue as you said, but I'm ok if it's stay here.

@Roznovjak Roznovjak merged commit 7a1bddd into master Aug 22, 2022
@Roznovjak Roznovjak deleted the nft_permissions_integration_tests branch August 22, 2022 07:48
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.

4 participants