Skip to content

Commit

Permalink
fixed type error: used value overflow instead of negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
rohansen856 committed Nov 7, 2024
1 parent 46a7b22 commit b0043b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pallets/asset/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::{borrow::Borrow, u32};

use super::*;
use crate::mock::*;
use codec::Encode;
Expand Down Expand Up @@ -2842,6 +2844,7 @@ fn asset_vc_status_change_with_wrong_asset_id_should_fail() {

/// Test case for validating that asset creation fails when provided with invalid asset values.
/// It covers both cases where the failure may result from an invalid `asset_value` or `asset_qty`.
#[test]
fn asset_create_should_fail_for_invalid_asset_value() {
// Define the creator and author identities, along with the capacity for the "space"
let creator = DID_00;
Expand Down Expand Up @@ -2881,8 +2884,8 @@ fn asset_create_should_fail_for_invalid_asset_value() {
let invalid_value_entry = AssetInputEntryOf::<Test> {
asset_desc: asset_desc.clone(),
asset_qty: 10, // Valid quantity
asset_type,
asset_value: -10, // Invalid asset value
asset_type: asset_type.clone(),
asset_value: u32::MAX+1, // Invalid asset value(u32 overflow)
asset_tag: asset_tag.clone(),
asset_meta: asset_meta.clone(),
};
Expand All @@ -2895,15 +2898,15 @@ fn asset_create_should_fail_for_invalid_asset_value() {
DoubleOrigin(author.clone(), creator.clone()).into(),
invalid_value_entry,
digest,
authorization_id,
authorization_id.clone(),
),
Error::<Test>::InvalidAssetValue // Expecting error due to invalid asset value
);

// Case 2: Attempt to create an asset with an invalid asset quantity
let invalid_qty_entry = AssetInputEntryOf::<Test> {
asset_desc,
asset_qty: -5, // Invalid quantity
asset_qty: u64::MAX+1, // Invalid quantity
asset_type,
asset_value: 10, // Valid asset value
asset_tag,
Expand Down

0 comments on commit b0043b5

Please sign in to comment.