-
Notifications
You must be signed in to change notification settings - Fork 112
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: Add new test case for InvalidAssetValue #520
base: develop
Are you sure you want to change the base?
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.
I see the requirement here that Invalid Asset Value may get triggered due either from asset_qty
or asset_value
.
Please check for both cases.
Use below for passing the rust format & add new commit. |
@rohansen856 While at it you can also check for |
@vatsa287 I have added test for the following cases: let negative_value_entry = AssetInputEntryOf::<Test> {
asset_desc: asset_desc.clone(),
asset_qty: 10, // Valid quantity
asset_type: asset_type.clone(),
asset_value: (0 - 1), // Invalid (negative) asset value
asset_tag: asset_tag.clone(),
asset_meta: asset_meta.clone(),
}; let me know if any other changes or edge case inclusions are necessary. thank you. |
@rohansen856 Negative check is not required since it is handled at by the type itself. |
thanks for the follow up. i will remove the negative check and keep just the |
Goal
This pr solves the issue: #370 , adding new test cases for checking invalid asset values in
pallets/asset/src/tests.rs
.#summary
Context:
creator, author, and capacity establish the initial conditions.
The test then generates unique identifiers for both the "space" and "authorization" using hashing functions to mimic blockchain data integrity practices.
Asset Entry with Invalid Value:
The entry variable represents an asset structure, with asset_value deliberately set to -10 to simulate an invalid value scenario.
This asset entry will be used to test the error handling in the Asset::create function.
Test Execution and Assertions:
Space::create
andSpace::approve
are called to prepare the environment, ensuring the space is created and approved before attempting asset creation.The core test assertion is
assert_err!
, which confirms that callingAsset::create
with the invalid asset value returns the InvalidAssetValue error as expected.