git.delta.rocks / unique-network / refs/commits / 76d8b567eabc

difftreelog

Fix Refungible balance tests

Greg Zaitsev2021-11-22parent: #d8ceb96.patch.diff
in: master

2 files changed

modifiedpallets/nft/src/mock.rsdiffbeforeafterboth
10use pallet_transaction_payment::{CurrencyAdapter};10use pallet_transaction_payment::{CurrencyAdapter};
11use frame_system as system;11use frame_system as system;
12use pallet_evm::AddressMapping;12use pallet_evm::AddressMapping;
13use crate::{EvmBackwardsAddressMapping, CrossAccountId};13use pallet_common::account::{EvmBackwardsAddressMapping, CrossAccountId};
14use codec::{Encode, Decode};14use codec::{Encode, Decode};
15use scale_info::TypeInfo;15use scale_info::TypeInfo;
1616
158}158}
159159
160impl pallet_template::Config for Test {160impl pallet_template::Config for Test {
161 type Event = ();
162 type WeightInfo = ();161 type WeightInfo = ();
163 type CollectionCreationPrice = CollectionCreationPrice;
164 type Currency = pallet_balances::Pallet<Test>;
165 type TreasuryAccountId = TreasuryAccountId;
166 type EvmAddressMapping = TestEvmAddressMapping;
167 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;
168 type CrossAccountId = TestCrossAccountId;
169}162}
170163
171// Build genesis storage according to the mock runtime.164// Build genesis storage according to the mock runtime.
modifiedpallets/nft/src/tests.rsdiffbeforeafterboth
--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -1,7 +1,7 @@
 // Tests to be written here
 use super::*;
 use crate::mock::*;
-use crate::{AccessMode, CollectionMode, Ownership, CreateItemData};
+use crate::{AccessMode, CollectionMode, CreateItemData};
 use nft_data_structs::{
 	CreateNftData, CreateFungibleData, CreateReFungibleData, CollectionId, TokenId,
 	MAX_DECIMAL_POINTS,
@@ -178,15 +178,10 @@
 		let data = default_re_fungible_data();
 		create_test_item(collection_id, &data.clone().into());
 		let item = TemplateModule::refungible_item_id(collection_id, 1).unwrap();
+		let balance = TemplateModule::balance(collection_id, 1, account(1));
 		assert_eq!(item.const_data, data.const_data.into_inner());
 		assert_eq!(item.variable_data, data.variable_data.into_inner());
-		assert_eq!(
-			item.owner[0],
-			Ownership {
-				owner: account(1),
-				fraction: 1023
-			}
-		);
+		assert_eq!(balance, 1023);
 	});
 }
 
@@ -215,15 +210,10 @@
 		));
 		for (index, data) in items_data.into_iter().enumerate() {
 			let item = TemplateModule::refungible_item_id(1, (index + 1) as TokenId).unwrap();
+			let balance = TemplateModule::balance(1, 1, account(1));
 			assert_eq!(item.const_data.to_vec(), data.const_data.into_inner());
 			assert_eq!(item.variable_data.to_vec(), data.variable_data.into_inner());
-			assert_eq!(
-				item.owner[0],
-				Ownership {
-					owner: account(1),
-					fraction: 1023
-				}
-			);
+			assert_eq!(balance, 1023);
 		}
 	});
 }
@@ -318,28 +308,19 @@
 		let origin2 = Origin::signed(2);
 		{
 			let item = TemplateModule::refungible_item_id(collection_id, 1).unwrap();
+			let balance = TemplateModule::balance(collection_id, 1, account(1));
 			assert_eq!(item.const_data, data.const_data.into_inner());
 			assert_eq!(item.variable_data, data.variable_data.into_inner());
-			assert_eq!(
-				item.owner[0],
-				Ownership {
-					owner: account(1),
-					fraction: 1023
-				}
-			);
+			assert_eq!(balance, 1023);
 		}
 		assert_eq!(TemplateModule::balance_count(1, 1), 1023);
 		assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
 
 		// change owner scenario
 		assert_ok!(TemplateModule::transfer(origin1, account(2), 1, 1, 1023));
-		assert_eq!(
-			TemplateModule::refungible_item_id(1, 1).unwrap().owner[0],
-			Ownership {
-				owner: account(2),
-				fraction: 1023
-			}
-		);
+
+		let balance2 = TemplateModule::balance(collection_id, 1, account(2));
+		assert_eq!(balance2, 1023);
 		assert_eq!(TemplateModule::balance_count(1, 1), 0);
 		assert_eq!(TemplateModule::balance_count(1, 2), 1023);
 		// assert_eq!(TemplateModule::address_tokens(1, 1), []);
@@ -355,20 +336,10 @@
 		));
 		{
 			let item = TemplateModule::refungible_item_id(1, 1).unwrap();
-			assert_eq!(
-				item.owner[0],
-				Ownership {
-					owner: account(2),
-					fraction: 523
-				}
-			);
-			assert_eq!(
-				item.owner[1],
-				Ownership {
-					owner: account(3),
-					fraction: 500
-				}
-			);
+			let balance2 = TemplateModule::balance(collection_id, 1, account(2));
+			let balance3 = TemplateModule::balance(collection_id, 1, account(3));
+			assert_eq!(balance2, 523);
+			assert_eq!(balance3, 500);
 		}
 		assert_eq!(TemplateModule::balance_count(1, 2), 523);
 		assert_eq!(TemplateModule::balance_count(1, 3), 500);
@@ -379,20 +350,10 @@
 		assert_ok!(TemplateModule::transfer(origin2, account(3), 1, 1, 200));
 		{
 			let item = TemplateModule::refungible_item_id(1, 1).unwrap();
-			assert_eq!(
-				item.owner[0],
-				Ownership {
-					owner: account(2),
-					fraction: 323
-				}
-			);
-			assert_eq!(
-				item.owner[1],
-				Ownership {
-					owner: account(3),
-					fraction: 700
-				}
-			);
+			let balance2 = TemplateModule::balance(collection_id, 1, account(2));
+			let balance3 = TemplateModule::balance(collection_id, 1, account(3));
+			assert_eq!(balance2, 323);
+			assert_eq!(balance3, 700);
 		}
 		assert_eq!(TemplateModule::balance_count(1, 2), 323);
 		assert_eq!(TemplateModule::balance_count(1, 3), 700);