difftreelog
fix tests and weights
in: master
16 files changed
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/erc.rs
+++ b/pallets/balances-adapter/src/erc.rs
@@ -1,6 +1,7 @@
-use crate::{Config, NativeFungibleHandle};
+use crate::{Config, NativeFungibleHandle, SelfWeightOf};
use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
use frame_support::traits::{Currency, ExistenceRequirement};
+use pallet_balances::WeightInfo;
use pallet_common::{
erc::{CommonEvmHandler, CrossAccountId, PrecompileHandle, PrecompileResult},
eth::CrossAddress,
@@ -73,7 +74,7 @@
Ok(total.into())
}
- // #[weight(<SelfWeightOf<T>>::transfer())]
+ #[weight(<SelfWeightOf<T>>::transfer())]
fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
@@ -93,7 +94,7 @@
Ok(true)
}
- // #[weight(<SelfWeightOf<T>>::transfer_from())]
+ #[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_from(
&mut self,
caller: Caller,
@@ -138,7 +139,7 @@
Ok(balance.into())
}
- // #[weight(<SelfWeightOf<T>>::transfer())]
+ #[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
@@ -158,7 +159,7 @@
Ok(true)
}
- // #[weight(<SelfWeightOf<T>>::transfer_from())]
+ #[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_from_cross(
&mut self,
caller: Caller,
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.tsdiffbeforeafterboth1// 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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from './util';19import {ICollectionPermissions} from './util/playgrounds/types';2021describe('Integration Test ext. Allow list tests', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let charlie: IKeyringPair;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 const donor = await privateKey({url: import.meta.url});29 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);30 });31 });3233 describe('Positive', () => {34 itSub('Owner can add address to allow list', async ({helper}) => {35 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});36 // allow list does not need to be enabled to add someone in advance37 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});38 const allowList = await helper.nft.getAllowList(collectionId);39 expect(allowList).to.deep.contain({Substrate: bob.address});40 });4142 itSub('Admin can add address to allow list', async ({helper}) => {43 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});44 await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});4546 // allow list does not need to be enabled to add someone in advance47 await helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});48 const allowList = await helper.nft.getAllowList(collectionId);49 expect(allowList).to.deep.contain({Substrate: charlie.address});50 });5152 itSub('If address is already added to allow list, nothing happens', async ({helper}) => {53 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});54 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});55 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});56 const allowList = await helper.nft.getAllowList(collectionId);57 expect(allowList).to.deep.contain({Substrate: bob.address});58 });59 });6061 describe('Negative', () => {62 itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {63 const collectionId = (1<<32) - 1;64 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))65 .to.be.rejectedWith(/common\.CollectionNotFound/);66 });6768 itSub('Nobody can add address to allow list of destroyed collection', async ({helper}) => {69 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});70 await helper.collection.burn(alice, collectionId);71 await expect(helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address}))72 .to.be.rejectedWith(/common\.CollectionNotFound/);73 });7475 itSub('Non-privileged user cannot add address to allow list', async ({helper}) => {76 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});77 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))78 .to.be.rejectedWith(/common\.NoPermission/);79 });80 });81});8283describe('Integration Test ext. Remove from Allow List', () => {84 let alice: IKeyringPair;85 let bob: IKeyringPair;86 let charlie: IKeyringPair;8788 before(async () => {89 await usingPlaygrounds(async (helper, privateKey) => {90 const donor = await privateKey({url: import.meta.url});91 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);92 });93 });9495 describe('Positive', () => {96 itSub('Owner can remove address from allow list', async ({helper}) => {97 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});98 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});99100 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});101102 const allowList = await helper.nft.getAllowList(collectionId);103104 expect(allowList).to.not.deep.contain({Substrate: bob.address});105 });106107 itSub('Admin can remove address from allow list', async ({helper}) => {108 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});109 await helper.nft.addAdmin(alice, collectionId, {Substrate: charlie.address});110 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});111 await helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: bob.address});112113 const allowList = await helper.nft.getAllowList(collectionId);114 expect(allowList).to.not.deep.contain({Substrate: bob.address});115 });116117 itSub('If address is already removed from allow list, nothing happens', async ({helper}) => {118 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});119 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});120 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});121 const allowListBefore = await helper.nft.getAllowList(collectionId);122 expect(allowListBefore).to.not.deep.contain({Substrate: bob.address});123124 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});125126 const allowListAfter = await helper.nft.getAllowList(collectionId);127 expect(allowListAfter).to.not.deep.contain({Substrate: bob.address});128 });129 });130131 describe('Negative', () => {132 itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {133 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});134 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});135 await expect(helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: charlie.address}))136 .to.be.rejectedWith(/common\.NoPermission/);137138 const allowList = await helper.nft.getAllowList(collectionId);139 expect(allowList).to.deep.contain({Substrate: charlie.address});140 });141142 itSub('Nobody can remove address from allow list of non-existing collection', async ({helper}) => {143 const collectionId = (1<<32) - 1;144 await expect(helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address}))145 .to.be.rejectedWith(/common\.CollectionNotFound/);146 });147148 itSub('Nobody can remove address from allow list of deleted collection', async ({helper}) => {149 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});150 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});151 await helper.collection.burn(alice, collectionId);152153 await expect(helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address}))154 .to.be.rejectedWith(/common\.CollectionNotFound/);155 });156 });157});158159describe('Integration Test ext. Transfer if included in Allow List', () => {160 let alice: IKeyringPair;161 let bob: IKeyringPair;162 let charlie: IKeyringPair;163164 before(async () => {165 await usingPlaygrounds(async (helper, privateKey) => {166 const donor = await privateKey({url: import.meta.url});167 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);168 });169 });170171 describe('Positive', () => {172 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {173 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});174 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});175 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});176 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});177 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});178 await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});179 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);180 expect(owner.Substrate).to.be.equal(charlie.address);181 });182183 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transferFrom.', async ({helper}) => {184 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});185 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});186 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});187 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});188 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});189 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});190191 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});192 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);193 expect(owner.Substrate).to.be.equal(charlie.address);194 });195196 itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer', async ({helper}) => {197 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});198 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});199 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});200 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});201 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});202203 await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});204 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);205 expect(owner.Substrate).to.be.equal(charlie.address);206 });207208 itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transferFrom', async ({helper}) => {209 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});210 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});211 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});212 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});213 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});214 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});215216 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});217 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);218 expect(owner.Substrate).to.be.equal(charlie.address);219 });220 });221222 describe('Negative', () => {223 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {224 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});225 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});226 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});227 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});228229 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))230 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);231 });232233 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {234 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});235 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});236 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});237 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});238 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});239 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});240 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});241242 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))243 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);244 });245246 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred to a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {247 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});248 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});249 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});250 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});251252 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))253 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);254 });255256 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred to a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {257 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});258 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});259 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});260 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});261 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});262263 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});264 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});265266 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))267 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);268 });269270 itSub('If Public Access mode is set to AllowList, tokens can\'t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)', async ({helper}) => {271 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});272 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});273 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});274 await expect(helper.nft.burnToken(bob, collectionId, tokenId))275 .to.be.rejectedWith(/common\.NoPermission/);276 });277278 itSub('If Public Access mode is set to AllowList, token transfers can\'t be Approved by a non-allowlisted address (see Approve method)', async ({helper}) => {279 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});280 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});281 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});282 await expect(helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}))283 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);284 });285 });286});287288describe('Integration Test ext. Mint if included in Allow List', () => {289 let alice: IKeyringPair;290 let bob: IKeyringPair;291292 before(async () => {293 await usingPlaygrounds(async (helper, privateKey) => {294 const donor = await privateKey({url: import.meta.url});295 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);296 });297 });298299 const permissionSet: ICollectionPermissions[] = [300 {access: 'Normal', mintMode: false},301 {access: 'Normal', mintMode: true},302 {access: 'AllowList', mintMode: false},303 {access: 'AllowList', mintMode: true},304 ];305306 const testPermissionSuite = (permissions: ICollectionPermissions) => {307 const allowlistedMintingShouldFail = !permissions.mintMode!;308309 const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;310311 const allowlistedMintingTest = () => itSub(312 `With the condtions above, tokens can${allowlistedMintingShouldFail'\'t'''} be created by allow-listed addresses`,313 async ({helper}) => {314 const collection = await helper.nft.mintCollection(alice, {});315 await collection.setPermissions(alice, permissions);316 await collection.addToAllowList(alice, {Substrate: bob.address});317318 if (allowlistedMintingShouldFail)319 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.be.rejectedWith(appropriateRejectionMessage);320 else321 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.not.be.rejected;322 },323 );324325326 describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, () => {327 describe('Positive', () => {328 itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {329 const collection = await helper.nft.mintCollection(alice, {});330 await collection.setPermissions(alice, permissions);331 await expect(collection.mintToken(alice, {Substrate: alice.address})).to.not.be.rejected;332 });333334 itSub('With the condtions above, tokens can be created by admin', async ({helper}) => {335 const collection = await helper.nft.mintCollection(alice, {});336 await collection.setPermissions(alice, permissions);337 await collection.addAdmin(alice, {Substrate: bob.address});338 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.not.be.rejected;339 });340341 if (!allowlistedMintingShouldFail) allowlistedMintingTest();342 });343344 describe('Negative', () => {345 itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {346 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});347 await collection.setPermissions(alice, permissions);348 await expect(collection.mintToken(bob, {Substrate: bob.address}))349 .to.be.rejectedWith(appropriateRejectionMessage);350 });351352 if (allowlistedMintingShouldFail) allowlistedMintingTest();353 });354 });355 };356357 for (const permissions of permissionSet) {358 testPermissionSuite(permissions);359 }360});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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from './util';19import {ICollectionPermissions, NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';2021describe('Integration Test ext. Allow list tests', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let charlie: IKeyringPair;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 const donor = await privateKey({url: import.meta.url});29 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);30 });31 });3233 describe('Positive', () => {34 itSub('Owner can add address to allow list', async ({helper}) => {35 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});36 // allow list does not need to be enabled to add someone in advance37 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});38 const allowList = await helper.nft.getAllowList(collectionId);39 expect(allowList).to.deep.contain({Substrate: bob.address});40 });4142 itSub('Admin can add address to allow list', async ({helper}) => {43 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});44 await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});4546 // allow list does not need to be enabled to add someone in advance47 await helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});48 const allowList = await helper.nft.getAllowList(collectionId);49 expect(allowList).to.deep.contain({Substrate: charlie.address});50 });5152 itSub('If address is already added to allow list, nothing happens', async ({helper}) => {53 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});54 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});55 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});56 const allowList = await helper.nft.getAllowList(collectionId);57 expect(allowList).to.deep.contain({Substrate: bob.address});58 });59 });6061 describe('Negative', () => {62 itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {63 const collectionId = NON_EXISTENT_COLLECTION_ID;64 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))65 .to.be.rejectedWith(/common\.CollectionNotFound/);66 });6768 itSub('Nobody can add address to allow list of destroyed collection', async ({helper}) => {69 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});70 await helper.collection.burn(alice, collectionId);71 await expect(helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address}))72 .to.be.rejectedWith(/common\.CollectionNotFound/);73 });7475 itSub('Non-privileged user cannot add address to allow list', async ({helper}) => {76 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});77 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))78 .to.be.rejectedWith(/common\.NoPermission/);79 });80 });81});8283describe('Integration Test ext. Remove from Allow List', () => {84 let alice: IKeyringPair;85 let bob: IKeyringPair;86 let charlie: IKeyringPair;8788 before(async () => {89 await usingPlaygrounds(async (helper, privateKey) => {90 const donor = await privateKey({url: import.meta.url});91 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);92 });93 });9495 describe('Positive', () => {96 itSub('Owner can remove address from allow list', async ({helper}) => {97 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});98 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});99100 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});101102 const allowList = await helper.nft.getAllowList(collectionId);103104 expect(allowList).to.not.deep.contain({Substrate: bob.address});105 });106107 itSub('Admin can remove address from allow list', async ({helper}) => {108 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});109 await helper.nft.addAdmin(alice, collectionId, {Substrate: charlie.address});110 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});111 await helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: bob.address});112113 const allowList = await helper.nft.getAllowList(collectionId);114 expect(allowList).to.not.deep.contain({Substrate: bob.address});115 });116117 itSub('If address is already removed from allow list, nothing happens', async ({helper}) => {118 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});119 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});120 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});121 const allowListBefore = await helper.nft.getAllowList(collectionId);122 expect(allowListBefore).to.not.deep.contain({Substrate: bob.address});123124 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});125126 const allowListAfter = await helper.nft.getAllowList(collectionId);127 expect(allowListAfter).to.not.deep.contain({Substrate: bob.address});128 });129 });130131 describe('Negative', () => {132 itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {133 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});134 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});135 await expect(helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: charlie.address}))136 .to.be.rejectedWith(/common\.NoPermission/);137138 const allowList = await helper.nft.getAllowList(collectionId);139 expect(allowList).to.deep.contain({Substrate: charlie.address});140 });141142 itSub('Nobody can remove address from allow list of non-existing collection', async ({helper}) => {143 const collectionId = NON_EXISTENT_COLLECTION_ID;144 await expect(helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address}))145 .to.be.rejectedWith(/common\.CollectionNotFound/);146 });147148 itSub('Nobody can remove address from allow list of deleted collection', async ({helper}) => {149 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});150 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});151 await helper.collection.burn(alice, collectionId);152153 await expect(helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address}))154 .to.be.rejectedWith(/common\.CollectionNotFound/);155 });156 });157});158159describe('Integration Test ext. Transfer if included in Allow List', () => {160 let alice: IKeyringPair;161 let bob: IKeyringPair;162 let charlie: IKeyringPair;163164 before(async () => {165 await usingPlaygrounds(async (helper, privateKey) => {166 const donor = await privateKey({url: import.meta.url});167 [alice, bob, charlie] = await helper.arrange.createAccounts([30n, 10n, 10n], donor);168 });169 });170171 describe('Positive', () => {172 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {173 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});174 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});175 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});176 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});177 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});178 await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});179 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);180 expect(owner.Substrate).to.be.equal(charlie.address);181 });182183 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transferFrom.', async ({helper}) => {184 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});185 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});186 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});187 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});188 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});189 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});190191 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});192 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);193 expect(owner.Substrate).to.be.equal(charlie.address);194 });195196 itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer', async ({helper}) => {197 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});198 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});199 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});200 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});201 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});202203 await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});204 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);205 expect(owner.Substrate).to.be.equal(charlie.address);206 });207208 itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transferFrom', async ({helper}) => {209 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});210 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});211 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});212 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});213 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});214 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});215216 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});217 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);218 expect(owner.Substrate).to.be.equal(charlie.address);219 });220 });221222 describe('Negative', () => {223 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {224 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});225 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});226 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});227 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});228229 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))230 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);231 });232233 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {234 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});235 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});236 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});237 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});238 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});239 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});240 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});241242 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))243 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);244 });245246 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred to a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {247 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});248 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});249 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});250 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});251252 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))253 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);254 });255256 itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred to a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {257 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});258 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});259 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});260 await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});261 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});262263 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});264 await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});265266 await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address}))267 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);268 });269270 itSub('If Public Access mode is set to AllowList, tokens can\'t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)', async ({helper}) => {271 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});272 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});273 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});274 await expect(helper.nft.burnToken(bob, collectionId, tokenId))275 .to.be.rejectedWith(/common\.NoPermission/);276 });277278 itSub('If Public Access mode is set to AllowList, token transfers can\'t be Approved by a non-allowlisted address (see Approve method)', async ({helper}) => {279 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});280 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});281 await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});282 await expect(helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}))283 .to.be.rejectedWith(/common\.AddressNotInAllowlist/);284 });285 });286});287288describe('Integration Test ext. Mint if included in Allow List', () => {289 let alice: IKeyringPair;290 let bob: IKeyringPair;291292 before(async () => {293 await usingPlaygrounds(async (helper, privateKey) => {294 const donor = await privateKey({url: import.meta.url});295 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);296 });297 });298299 const permissionSet: ICollectionPermissions[] = [300 {access: 'Normal', mintMode: false},301 {access: 'Normal', mintMode: true},302 {access: 'AllowList', mintMode: false},303 {access: 'AllowList', mintMode: true},304 ];305306 const testPermissionSuite = (permissions: ICollectionPermissions) => {307 const allowlistedMintingShouldFail = !permissions.mintMode!;308309 const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;310311 const allowlistedMintingTest = () => itSub(312 `With the condtions above, tokens can${allowlistedMintingShouldFail'\'t'''} be created by allow-listed addresses`,313 async ({helper}) => {314 const collection = await helper.nft.mintCollection(alice, {});315 await collection.setPermissions(alice, permissions);316 await collection.addToAllowList(alice, {Substrate: bob.address});317318 if (allowlistedMintingShouldFail)319 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.be.rejectedWith(appropriateRejectionMessage);320 else321 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.not.be.rejected;322 },323 );324325326 describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, () => {327 describe('Positive', () => {328 itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {329 const collection = await helper.nft.mintCollection(alice, {});330 await collection.setPermissions(alice, permissions);331 await expect(collection.mintToken(alice, {Substrate: alice.address})).to.not.be.rejected;332 });333334 itSub('With the condtions above, tokens can be created by admin', async ({helper}) => {335 const collection = await helper.nft.mintCollection(alice, {});336 await collection.setPermissions(alice, permissions);337 await collection.addAdmin(alice, {Substrate: bob.address});338 await expect(collection.mintToken(bob, {Substrate: bob.address})).to.not.be.rejected;339 });340341 if (!allowlistedMintingShouldFail) allowlistedMintingTest();342 });343344 describe('Negative', () => {345 itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {346 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});347 await collection.setPermissions(alice, permissions);348 await expect(collection.mintToken(bob, {Substrate: bob.address}))349 .to.be.rejectedWith(appropriateRejectionMessage);350 });351352 if (allowlistedMintingShouldFail) allowlistedMintingTest();353 });354 });355 };356357 for (const permissions of permissionSet) {358 testPermissionSuite(permissions);359 }360});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;