-
Notifications
You must be signed in to change notification settings - Fork 121
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
pallet-asset: Added new test-case for DistributionLimitExceeded. #522
pallet-asset: Added new test-case for DistributionLimitExceeded. #522
Conversation
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.
This might fail with asset_id
is not found.
@ritankarsaha You have to update the constant which defines the max allowed value for the test to evaluate against. You can find the mock value for the constant set |
@vatsa287 parameter_types! {
pub const MaxEncodedValueLength: u32 = 1_024;
pub const MaxAssetDistribution: u32 = u32::MAX;
} to parameter_types! {
pub const MaxEncodedValueLength: u32 = 1_024;
pub const MaxAssetDistribution: u32 = 25;
} Is this implementation correct ? |
@vatsa287 Could you give me an insight on why is it failing on |
-use crate::mock::*;
-use crate::{types::AssetIssuanceEntry, Error};
+use crate::{mock::*, types::AssetIssuanceEntry, Error}; Above changes is needed as per fmt. Run |
@vatsa287 I have made the following changes:- From use super::*;
use crate::mock::*;
use crate::{types::AssetIssuanceEntry, Error}; To use super::*;
use crate::{mock::*, types::AssetIssuanceEntry, Error}; I hope this is correct, however on running the command |
@vatsa287 For the clippy test fail, error: unused import: `assert_noop`
--> pallets/asset/src/tests.rs:5:33
|
5 | use frame_support::{assert_err, assert_noop, assert_ok, BoundedVec};
| ^^^^^^^^^^^
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
error: could not compile `pallet-asset` (lib test) due to 1 previous error
warning: build failed, waiting for other jobs to finish... I am removing the unused import assert_noop, I guess this is the error which is failing the clippy test For the test failing should i need to consider anything else? |
Instead of waiting for CI always since it takes a bit of time, you can run the required tests at your local setup. |
@vatsa287 fixed the changes and pushed a new commit into the PR. Tests also have successfully ran locally. |
@vatsa287 ran the |
@vatsa287 is this implementation correct? The CI tests for this have also passed locally. |
pallets/asset/src/tests.rs
Outdated
let exceeding_digest = | ||
<Test as frame_system::Config>::Hashing::hash(&exceeding_entry.encode()[..]); | ||
|
||
assert_noop!( |
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.
Change to assert_err!
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.
Resolved this error @vatsa287
and the test case passed.
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
This PR fixes issue #379 .
This issue has been structured similarly to the
asset_create_should_succeed
test.This test will ensure that an asset can be issued successfully and will include coverage for reaching and exceeding the
MaxAssetDistribution
limit.The test sets up a space, approves it, and creates an asset similarly to the
asset_create_should_succeed
test.The loop issues the asset up to the
MaxAssetDistribution
limit (set to 25 for testing). Each iteration simulates issuing the asset to a different recipient.After the limit is reached, the test tries to issue the asset to one more recipient, which should trigger the
DistributionLimitExceeded
error. This ensures that the pallet's logic correctly handles and enforces the distribution limit.This implementation checks that the asset issuance process is valid up to the
MaxAssetDistribution
limit and correctly throws an error when thelimit
is exceeded.