difftreelog
fix tests and weights
in: master
16 files changed
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth1use crate::{Config, NativeFungibleHandle};2use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};3use frame_support::traits::{Currency, ExistenceRequirement};4use pallet_common::{5 erc::{CommonEvmHandler, CrossAccountId, PrecompileHandle, PrecompileResult},6 eth::CrossAddress,7};8use pallet_evm_coder_substrate::{9 call, dispatch_to_evm,10 execution::{PreDispatch, Result},11 frontier_contract, WithRecorder, SubstrateRecorder,12};13use sp_core::{U256, Get};14use sp_std::vec::Vec;1516frontier_contract! {17 macro_rules! NativeFungibleHandle_result {...}18 impl<T: Config> Contract for NativeFungibleHandle<T> {...}19}2021#[derive(ToLog)]22pub enum ERC20Events {23 Transfer {24 #[indexed]25 from: Address,26 #[indexed]27 to: Address,28 value: U256,29 },30 Approval {31 #[indexed]32 owner: Address,33 #[indexed]34 spender: Address,35 value: U256,36 },37}3839#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]40impl<T: Config> NativeFungibleHandle<T> {41 fn allowance(&self, _owner: Address, _spender: Address) -> Result<U256> {42 Ok(U256::zero())43 }4445 // #[weight(<SelfWeightOf<T>>::approve())]46 fn approve(&mut self, _caller: Caller, _spender: Address, _amount: U256) -> Result<bool> {47 // self.consume_store_reads(1)?;48 Err("Approve not supported".into())49 }5051 fn balance_of(&self, owner: Address) -> Result<U256> {52 // self.consume_store_reads(1)?;53 let owner = T::CrossAccountId::from_eth(owner);54 let balance = <T as Config>::Currency::free_balance(owner.as_sub());55 Ok(balance.into())56 }5758 fn decimals(&self) -> Result<u8> {59 Ok(T::Decimals::get())60 }6162 fn name(&self) -> Result<String> {63 Ok(T::Name::get())64 }6566 fn symbol(&self) -> Result<String> {67 Ok(T::Symbol::get())68 }6970 fn total_supply(&self) -> Result<U256> {71 // self.consume_store_reads(1)?;72 let total = <T as Config>::Currency::total_issuance();73 Ok(total.into())74 }7576 // #[weight(<SelfWeightOf<T>>::transfer())]77 fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {78 let caller = T::CrossAccountId::from_eth(caller);79 let to = T::CrossAccountId::from_eth(to);80 let amount = amount.try_into().map_err(|_| "amount overflow")?;81 // let budget = self82 // .recorder83 // .weight_calls_budget(<StructureWeight<T>>::find_parent());8485 // <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;86 <T as Config>::Currency::transfer(87 caller.as_sub(),88 to.as_sub(),89 amount,90 ExistenceRequirement::KeepAlive,91 )92 .map_err(dispatch_to_evm::<T>)?;93 Ok(true)94 }9596 // #[weight(<SelfWeightOf<T>>::transfer_from())]97 fn transfer_from(98 &mut self,99 caller: Caller,100 from: Address,101 to: Address,102 amount: U256,103 ) -> Result<bool> {104 let caller = T::CrossAccountId::from_eth(caller);105 let from = T::CrossAccountId::from_eth(from);106 let to = T::CrossAccountId::from_eth(to);107 let amount = amount.try_into().map_err(|_| "amount overflow")?;108109 if from != caller {110 return Err("no permission".into());111 }112 // let budget = self113 // .recorder114 // .weight_calls_budget(<StructureWeight<T>>::find_parent());115116 // <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)117 // .map_err(dispatch_to_evm::<T>)?;118 <T as Config>::Currency::transfer(119 caller.as_sub(),120 to.as_sub(),121 amount,122 ExistenceRequirement::KeepAlive,123 )124 .map_err(dispatch_to_evm::<T>)?;125 Ok(true)126 }127}128129#[solidity_interface(name = ERC20UniqueExtensions, enum(derive(PreDispatch)), enum_attr(weight))]130impl<T: Config> NativeFungibleHandle<T>131where132 T::AccountId: From<[u8; 32]>,133{134 fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {135 // self.consume_store_reads(1)?;136 let owner = owner.into_sub_cross_account::<T>()?;137 let balance = <T as Config>::Currency::free_balance(owner.as_sub());138 Ok(balance.into())139 }140141 // #[weight(<SelfWeightOf<T>>::transfer())]142 fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {143 let caller = T::CrossAccountId::from_eth(caller);144 let to = to.into_sub_cross_account::<T>()?;145 let amount = amount.try_into().map_err(|_| "amount overflow")?;146 // let budget = self147 // .recorder148 // .weight_calls_budget(<StructureWeight<T>>::find_parent());149150 // <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;151 <T as Config>::Currency::transfer(152 caller.as_sub(),153 to.as_sub(),154 amount,155 ExistenceRequirement::KeepAlive,156 )157 .map_err(dispatch_to_evm::<T>)?;158 Ok(true)159 }160161 // #[weight(<SelfWeightOf<T>>::transfer_from())]162 fn transfer_from_cross(163 &mut self,164 caller: Caller,165 from: CrossAddress,166 to: CrossAddress,167 amount: U256,168 ) -> Result<bool> {169 let caller = T::CrossAccountId::from_eth(caller);170 let from = from.into_sub_cross_account::<T>()?;171 let to = to.into_sub_cross_account::<T>()?;172 let amount = amount.try_into().map_err(|_| "amount overflow")?;173174 if from != caller {175 return Err("no permission".into());176 }177178 // let budget = self179 // .recorder180 // .weight_calls_budget(<StructureWeight<T>>::find_parent());181182 // <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)183 // .map_err(dispatch_to_evm::<T>)?;184 <T as Config>::Currency::transfer(185 caller.as_sub(),186 to.as_sub(),187 amount,188 ExistenceRequirement::KeepAlive,189 )190 .map_err(dispatch_to_evm::<T>)?;191 Ok(true)192 }193}194195#[solidity_interface(196 name = UniqueNativeFungible,197 is(ERC20, ERC20UniqueExtensions),198 enum(derive(PreDispatch))199)]200impl<T: Config> NativeFungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}201202generate_stubgen!(gen_impl, UniqueNativeFungibleCall<()>, true);203generate_stubgen!(gen_iface, UniqueNativeFungibleCall<()>, false);204205impl<T: Config> CommonEvmHandler for NativeFungibleHandle<T>206where207 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,208{209 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNativeFungible.raw");210211 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {212 call::<T, UniqueNativeFungibleCall<T>, _, _>(handle, self)213 }214}1use crate::{Config, NativeFungibleHandle, SelfWeightOf};2use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};3use frame_support::traits::{Currency, ExistenceRequirement};4use pallet_balances::WeightInfo;5use pallet_common::{6 erc::{CommonEvmHandler, CrossAccountId, PrecompileHandle, PrecompileResult},7 eth::CrossAddress,8};9use pallet_evm_coder_substrate::{10 call, dispatch_to_evm,11 execution::{PreDispatch, Result},12 frontier_contract, WithRecorder, SubstrateRecorder,13};14use sp_core::{U256, Get};15use sp_std::vec::Vec;1617frontier_contract! {18 macro_rules! NativeFungibleHandle_result {...}19 impl<T: Config> Contract for NativeFungibleHandle<T> {...}20}2122#[derive(ToLog)]23pub enum ERC20Events {24 Transfer {25 #[indexed]26 from: Address,27 #[indexed]28 to: Address,29 value: U256,30 },31 Approval {32 #[indexed]33 owner: Address,34 #[indexed]35 spender: Address,36 value: U256,37 },38}3940#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]41impl<T: Config> NativeFungibleHandle<T> {42 fn allowance(&self, _owner: Address, _spender: Address) -> Result<U256> {43 Ok(U256::zero())44 }4546 // #[weight(<SelfWeightOf<T>>::approve())]47 fn approve(&mut self, _caller: Caller, _spender: Address, _amount: U256) -> Result<bool> {48 // self.consume_store_reads(1)?;49 Err("Approve not supported".into())50 }5152 fn balance_of(&self, owner: Address) -> Result<U256> {53 // self.consume_store_reads(1)?;54 let owner = T::CrossAccountId::from_eth(owner);55 let balance = <T as Config>::Currency::free_balance(owner.as_sub());56 Ok(balance.into())57 }5859 fn decimals(&self) -> Result<u8> {60 Ok(T::Decimals::get())61 }6263 fn name(&self) -> Result<String> {64 Ok(T::Name::get())65 }6667 fn symbol(&self) -> Result<String> {68 Ok(T::Symbol::get())69 }7071 fn total_supply(&self) -> Result<U256> {72 // self.consume_store_reads(1)?;73 let total = <T as Config>::Currency::total_issuance();74 Ok(total.into())75 }7677 #[weight(<SelfWeightOf<T>>::transfer())]78 fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {79 let caller = T::CrossAccountId::from_eth(caller);80 let to = T::CrossAccountId::from_eth(to);81 let amount = amount.try_into().map_err(|_| "amount overflow")?;82 // let budget = self83 // .recorder84 // .weight_calls_budget(<StructureWeight<T>>::find_parent());8586 // <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;87 <T as Config>::Currency::transfer(88 caller.as_sub(),89 to.as_sub(),90 amount,91 ExistenceRequirement::KeepAlive,92 )93 .map_err(dispatch_to_evm::<T>)?;94 Ok(true)95 }9697 #[weight(<SelfWeightOf<T>>::transfer())]98 fn transfer_from(99 &mut self,100 caller: Caller,101 from: Address,102 to: Address,103 amount: U256,104 ) -> Result<bool> {105 let caller = T::CrossAccountId::from_eth(caller);106 let from = T::CrossAccountId::from_eth(from);107 let to = T::CrossAccountId::from_eth(to);108 let amount = amount.try_into().map_err(|_| "amount overflow")?;109110 if from != caller {111 return Err("no permission".into());112 }113 // let budget = self114 // .recorder115 // .weight_calls_budget(<StructureWeight<T>>::find_parent());116117 // <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)118 // .map_err(dispatch_to_evm::<T>)?;119 <T as Config>::Currency::transfer(120 caller.as_sub(),121 to.as_sub(),122 amount,123 ExistenceRequirement::KeepAlive,124 )125 .map_err(dispatch_to_evm::<T>)?;126 Ok(true)127 }128}129130#[solidity_interface(name = ERC20UniqueExtensions, enum(derive(PreDispatch)), enum_attr(weight))]131impl<T: Config> NativeFungibleHandle<T>132where133 T::AccountId: From<[u8; 32]>,134{135 fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {136 // self.consume_store_reads(1)?;137 let owner = owner.into_sub_cross_account::<T>()?;138 let balance = <T as Config>::Currency::free_balance(owner.as_sub());139 Ok(balance.into())140 }141142 #[weight(<SelfWeightOf<T>>::transfer())]143 fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {144 let caller = T::CrossAccountId::from_eth(caller);145 let to = to.into_sub_cross_account::<T>()?;146 let amount = amount.try_into().map_err(|_| "amount overflow")?;147 // let budget = self148 // .recorder149 // .weight_calls_budget(<StructureWeight<T>>::find_parent());150151 // <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;152 <T as Config>::Currency::transfer(153 caller.as_sub(),154 to.as_sub(),155 amount,156 ExistenceRequirement::KeepAlive,157 )158 .map_err(dispatch_to_evm::<T>)?;159 Ok(true)160 }161162 #[weight(<SelfWeightOf<T>>::transfer())]163 fn transfer_from_cross(164 &mut self,165 caller: Caller,166 from: CrossAddress,167 to: CrossAddress,168 amount: U256,169 ) -> Result<bool> {170 let caller = T::CrossAccountId::from_eth(caller);171 let from = from.into_sub_cross_account::<T>()?;172 let to = to.into_sub_cross_account::<T>()?;173 let amount = amount.try_into().map_err(|_| "amount overflow")?;174175 if from != caller {176 return Err("no permission".into());177 }178179 // let budget = self180 // .recorder181 // .weight_calls_budget(<StructureWeight<T>>::find_parent());182183 // <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)184 // .map_err(dispatch_to_evm::<T>)?;185 <T as Config>::Currency::transfer(186 caller.as_sub(),187 to.as_sub(),188 amount,189 ExistenceRequirement::KeepAlive,190 )191 .map_err(dispatch_to_evm::<T>)?;192 Ok(true)193 }194}195196#[solidity_interface(197 name = UniqueNativeFungible,198 is(ERC20, ERC20UniqueExtensions),199 enum(derive(PreDispatch))200)]201impl<T: Config> NativeFungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}202203generate_stubgen!(gen_impl, UniqueNativeFungibleCall<()>, true);204generate_stubgen!(gen_iface, UniqueNativeFungibleCall<()>, false);205206impl<T: Config> CommonEvmHandler for NativeFungibleHandle<T>207where208 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,209{210 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNativeFungible.raw");211212 fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {213 call::<T, UniqueNativeFungibleCall<T>, _, _>(handle, self)214 }215}pallets/balances-adapter/src/lib.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/lib.rs
+++ b/pallets/balances-adapter/src/lib.rs
@@ -11,6 +11,8 @@
pub mod common;
pub mod erc;
+pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
+
pub struct NativeFungibleHandle<T: Config>(SubstrateRecorder<T>);
impl<T: Config> NativeFungibleHandle<T> {
pub fn new() -> NativeFungibleHandle<T> {
@@ -34,6 +36,7 @@
pub mod pallet {
use alloc::string::String;
use frame_support::{traits::Get, sp_runtime::DispatchResult};
+ use pallet_balances::WeightInfo;
use sp_core::U256;
#[pallet::config]
@@ -49,6 +52,8 @@
type Decimals: Get<u8>;
type Name: Get<String>;
type Symbol: Get<String>;
+
+ type WeightInfo: WeightInfo;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -94,6 +94,7 @@
type Decimals = Decimals;
type Name = Name;
type Symbol = Symbol;
+ type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
}
parameter_types! {
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
let donor: IKeyringPair;
@@ -82,7 +83,7 @@
itSub("Can't add collection admin of not existing collection.", async ({helper}) => {
const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);
tests/src/allowLists.test.tsdiffbeforeafterboth--- a/tests/src/allowLists.test.ts
+++ b/tests/src/allowLists.test.ts
@@ -16,7 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util';
-import {ICollectionPermissions} from './util/playgrounds/types';
+import {ICollectionPermissions, NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test ext. Allow list tests', () => {
let alice: IKeyringPair;
@@ -60,7 +60,7 @@
describe('Negative', () => {
itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {
- const collectionId = (1<<32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))
.to.be.rejectedWith(/common\.CollectionNotFound/);
});
@@ -140,7 +140,7 @@
});
itSub('Nobody can remove address from allow list of non-existing collection', async ({helper}) => {
- const collectionId = (1<<32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address}))
.to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
let alice: IKeyringPair;
@@ -127,7 +128,7 @@
});
itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
const changeOwnerTx = () => helper.collection.changeOwner(bob, collectionId, bob.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub, Pallets} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
async function setSponsorHelper(collection: any, signer: IKeyringPair, sponsorAddress: string) {
await collection.setSponsor(signer, sponsorAddress);
@@ -198,7 +199,7 @@
});
itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
const confirmSponsorshipTx = () => helper.collection.confirmSponsorship(bob, collectionId);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -48,5 +48,3 @@
field: CollectionLimitField,
value: OptionUint,
}
-
-export const NON_EXISTENT_COLLECTION_ID = 4_294_967_295;
\ No newline at end of file
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
let alice: IKeyringPair;
@@ -68,7 +69,7 @@
});
itSub('Can\'t remove collection admin from not existing collection', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.removeAdmin(alice, collectionId, {Substrate: bob.address}))
.to.be.rejectedWith(/common\.CollectionNotFound/);
tests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionSponsor.test.ts
+++ b/tests/src/removeCollectionSponsor.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('integration test: ext. removeCollectionSponsor():', () => {
let donor: IKeyringPair;
@@ -91,7 +92,7 @@
});
itSub('(!negative test!) Remove sponsor for a collection that never existed', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.removeSponsor(alice, collectionId)).to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/setCollectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -17,6 +17,7 @@
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
const accountTokenOwnershipLimit = 0;
const sponsoredDataSize = 0;
@@ -110,7 +111,7 @@
});
itSub('execute setCollectionLimits for not exists collection', async ({helper}) => {
- const nonExistentCollectionId = (1 << 32) - 1;
+ const nonExistentCollectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.setLimits(
alice,
nonExistentCollectionId,
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect, Pallets} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('integration test: ext. setCollectionSponsor():', () => {
let alice: IKeyringPair;
@@ -105,7 +106,7 @@
});
itSub('(!negative test!) Add sponsor to a collection that never existed', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.setSponsor(alice, collectionId, bob.address))
.to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/setPermissions.test.tsdiffbeforeafterboth--- a/tests/src/setPermissions.test.ts
+++ b/tests/src/setPermissions.test.ts
@@ -16,6 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test: Set Permissions', () => {
let alice: IKeyringPair;
@@ -85,7 +86,7 @@
});
itSub('fails on not existing collection', async ({helper}) => {
- const collectionId = (1 << 32) - 1;
+ const collectionId = NON_EXISTENT_COLLECTION_ID;
await expect(helper.collection.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true}))
.to.be.rejectedWith(/common\.CollectionNotFound/);
});
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -17,7 +17,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itEth, usingEthPlaygrounds} from './eth/util';
import {itSub, Pallets, usingPlaygrounds, expect} from './util';
-import {NON_EXISTENT_COLLECTION_ID} from './eth/util/playgrounds/types';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
let donor: IKeyringPair;
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -16,7 +16,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, Pallets, usingPlaygrounds, expect} from './util';
-import {NON_EXISTENT_COLLECTION_ID} from './eth/util/playgrounds/types';
+import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
let alice: IKeyringPair;
tests/src/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -3,6 +3,8 @@
import {IKeyringPair} from '@polkadot/types/types';
+export const NON_EXISTENT_COLLECTION_ID = 4_294_967_295;
+
export interface IEvent {
section: string;
method: string;