git.delta.rocks / unique-network / refs/commits / 2df3f6b6e145

difftreelog

source

primitives/data-structs/src/migration.rs1.8 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617/// Storage migration is not required for this change, as SponsoringRateLimit has same encoding as Option<u32>18#[test]19fn sponsoring_rate_limit_has_same_encoding_as_option_u32() {20	use parity_scale_codec::Encode;2122	use crate::SponsoringRateLimit;2324	fn limit_to_option(limit: SponsoringRateLimit) -> Option<u32> {25		match limit {26			SponsoringRateLimit::SponsoringDisabled => None,27			SponsoringRateLimit::Blocks(v) => Some(v),28		}29	}3031	fn test_to_option(limit: SponsoringRateLimit) {32		let encoded = limit.encode();33		let option = limit_to_option(limit);34		let encoded_option = option.encode();3536		assert_eq!(encoded, encoded_option);37	}3839	test_to_option(SponsoringRateLimit::SponsoringDisabled);40	test_to_option(SponsoringRateLimit::Blocks(10));41}4243#[test]44fn collection_flags_have_same_encoding_as_bool() {45	use parity_scale_codec::Encode;4647	use crate::CollectionFlags;4849	assert_eq!(50		true.encode(),51		CollectionFlags {52			external: true,53			..Default::default()54		}55		.encode()56	);57	assert_eq!(58		false.encode(),59		CollectionFlags {60			external: false,61			..Default::default()62		}63		.encode()64	);65}