For my pallet I have defined a StorageMap in the storage that stores a tuple.
#[pallet::storage]
pub(super) type NameOf<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, (Nickname<T>, BalanceOf<T>)>;
Using a custom struct:
#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen, PartialEq, RuntimeDebug)]
#[scale_info(skip_type_params(T))]
#[codec(mel_bound())]
pub struct Nickname<T: Config> {
pub first: BoundedVec<u8, T::MaxLength>,
pub last: Option<BoundedVec<u8, T::MaxLength>>,
}
I have found a problem when trying to do one of the unit tests. I want to check if value stored that is suppose to be None
is None
:
assert_eq!(<NameOf<Test>>::get(2), None);
But I am getting this error:
binary operation `==` cannot be applied to type `std::option::Option<(pallet::Nickname<Test>, u64)>`
If I only get the value of my struct to compare it (even that the unwrap() will panic):
assert_eq!(<NameOf<Test>>::get(2).unwrap().0, None);
I still get the same error, even that I have the PartialEq
trait in the struct.
binary operation `==` cannot be applied to type `pallet::Nickname<Test>`
If I just print the value I can see is None:
println!("{:?}", <NameOf<Test>>::get(2));
None
How can I make this assert_eq
?