difftreelog
fix skip tests that use substrate addresses
in: master
1 file changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {IKeyringPair} from '@polkadot/types/types';17import {UNIQUE} from '../util/helpers';18import {19 recordEthFee,20} from './util/helpers';21import {usingEthPlaygrounds, itEth, expect} from './util/playgrounds';2223describe('Add collection admins', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = privateKey('//Alice');29 });30 });3132 itEth('Add admin by owner', async ({helper}) => {33 const owner = await helper.eth.createAccountWithBalance(donor);34 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');35 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);3637 const newAdmin = helper.eth.createAccount();3839 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();40 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);41 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())42 .to.be.eq(newAdmin.toLocaleLowerCase());43 });4445 itEth('Add substrate admin by owner', async ({helper}) => {46 const owner = await helper.eth.createAccountWithBalance(donor);47 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');48 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);4950 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);51 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();5253 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);54 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())55 .to.be.eq(newAdmin.address.toLocaleLowerCase());56 });5758 //FIXME:59 itEth('Verify owner or admin', async ({helper}) => {60 const owner = await helper.eth.createAccountWithBalance(donor);61 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');6263 const newAdmin = helper.eth.createAccount();64 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);65 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;66 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();67 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;68 });6970 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {71 const owner = await helper.eth.createAccountWithBalance(donor);72 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');7374 const admin = await helper.eth.createAccountWithBalance(donor);75 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);76 await collectionEvm.methods.addCollectionAdmin(admin).send();7778 const user = helper.eth.createAccount();79 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))80 .to.be.rejectedWith('NoPermission');8182 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);83 expect(adminList.length).to.be.eq(1);84 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())85 .to.be.eq(admin.toLocaleLowerCase());86 });8788 itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {89 const owner = await helper.eth.createAccountWithBalance(donor);90 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');9192 const notAdmin = await helper.eth.createAccountWithBalance(donor);93 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);9495 const user = helper.eth.createAccount();96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))97 .to.be.rejectedWith('NoPermission');9899 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);100 expect(adminList.length).to.be.eq(0);101 });102103 itEth('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {104 const owner = await helper.eth.createAccountWithBalance(donor);105 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');106107 const admin = await helper.eth.createAccountWithBalance(donor);108 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);109 await collectionEvm.methods.addCollectionAdmin(admin).send();110111 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);112 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))113 .to.be.rejectedWith('NoPermission');114115 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);116 expect(adminList.length).to.be.eq(1);117 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())118 .to.be.eq(admin.toLocaleLowerCase());119 });120121 itEth('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {122 const owner = await helper.eth.createAccountWithBalance(donor);123 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');124125 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);126 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);127 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);128 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))129 .to.be.rejectedWith('NoPermission');130131 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);132 expect(adminList.length).to.be.eq(0);133 });134});135136describe('Remove collection admins', () => {137 let donor: IKeyringPair;138139 before(async function() {140 await usingEthPlaygrounds(async (_helper, privateKey) => {141 donor = privateKey('//Alice');142 });143 });144145 itEth('Remove admin by owner', async ({helper}) => {146 const owner = await helper.eth.createAccountWithBalance(donor);147 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');148149 const newAdmin = helper.eth.createAccount();150 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);151 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();152153 {154 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);155 expect(adminList.length).to.be.eq(1);156 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())157 .to.be.eq(newAdmin.toLocaleLowerCase());158 }159160 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();161 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);162 expect(adminList.length).to.be.eq(0);163 });164165 itEth('Remove substrate admin by owner', async ({helper}) => {166 const owner = await helper.eth.createAccountWithBalance(donor);167 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');168169 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);170 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);171 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();172 {173 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);174 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())175 .to.be.eq(newAdmin.address.toLocaleLowerCase());176 }177178 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();179 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);180 expect(adminList.length).to.be.eq(0);181 });182183 itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {184 const owner = await helper.eth.createAccountWithBalance(donor);185 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');186187 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);188189 const admin0 = await helper.eth.createAccountWithBalance(donor);190 await collectionEvm.methods.addCollectionAdmin(admin0).send();191 const admin1 = await helper.eth.createAccountWithBalance(donor);192 await collectionEvm.methods.addCollectionAdmin(admin1).send();193194 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))195 .to.be.rejectedWith('NoPermission');196 {197 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);198 expect(adminList.length).to.be.eq(2);199 expect(adminList.toString().toLocaleLowerCase())200 .to.be.deep.contains(admin0.toLocaleLowerCase())201 .to.be.deep.contains(admin1.toLocaleLowerCase());202 }203 });204205 itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {206 const owner = await helper.eth.createAccountWithBalance(donor);207 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');208209 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);210211 const admin = await helper.eth.createAccountWithBalance(donor);212 await collectionEvm.methods.addCollectionAdmin(admin).send();213 const notAdmin = helper.eth.createAccount();214215 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))216 .to.be.rejectedWith('NoPermission');217 {218 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);219 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())220 .to.be.eq(admin.toLocaleLowerCase());221 expect(adminList.length).to.be.eq(1);222 }223 });224225 itEth('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {226 const owner = await helper.eth.createAccountWithBalance(donor);227 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');228229 const [adminSub] = await helper.arrange.createAccounts([10n], donor);230 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);231 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();232 const adminEth = await helper.eth.createAccountWithBalance(donor);233 await collectionEvm.methods.addCollectionAdmin(adminEth).send();234235 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))236 .to.be.rejectedWith('NoPermission');237238 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);239 expect(adminList.length).to.be.eq(2);240 expect(adminList.toString().toLocaleLowerCase())241 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())242 .to.be.deep.contains(adminEth.toLocaleLowerCase());243 });244245 itEth('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {246 const owner = await helper.eth.createAccountWithBalance(donor);247 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');248249 const [adminSub] = await helper.arrange.createAccounts([10n], donor);250 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);251 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();252 const notAdminEth = await helper.eth.createAccountWithBalance(donor);253254 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))255 .to.be.rejectedWith('NoPermission');256257 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);258 expect(adminList.length).to.be.eq(1);259 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())260 .to.be.eq(adminSub.address.toLocaleLowerCase());261 });262});263264describe('Change owner tests', () => {265 let donor: IKeyringPair;266267 before(async function() {268 await usingEthPlaygrounds(async (_helper, privateKey) => {269 donor = privateKey('//Alice');270 });271 });272273 itEth('Change owner', async ({helper}) => {274 const owner = await helper.eth.createAccountWithBalance(donor);275 const newOwner = await helper.eth.createAccountWithBalance(donor);276 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');277 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);278279 await collectionEvm.methods.setOwner(newOwner).send();280281 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;282 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;283 });284285 itEth('change owner call fee', async ({helper}) => {286 const owner = await helper.eth.createAccountWithBalance(donor);287 const newOwner = await helper.eth.createAccountWithBalance(donor);288 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);290291 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwner(newOwner).send());292 expect(cost < BigInt(0.2 * Number(UNIQUE)));293 expect(cost > 0);294 });295296 //FIXME297 itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {298 const owner = await helper.eth.createAccountWithBalance(donor);299 const newOwner = await helper.eth.createAccountWithBalance(donor);300 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');301 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);302303 await expect(collectionEvm.methods.setOwner(newOwner).send({from: newOwner})).to.be.rejected;304 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;305 });306});307308describe('Change substrate owner tests', () => {309 let donor: IKeyringPair;310311 before(async function() {312 await usingEthPlaygrounds(async (_helper, privateKey) => {313 donor = privateKey('//Alice');314 });315 });316317 //FIXME318 itEth('Change owner', async ({helper}) => {319 const owner = await helper.eth.createAccountWithBalance(donor);320 const [newOwner] = await helper.arrange.createAccounts([10n], donor);321 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');322 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);323324 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;325 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;326327 await collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send();328329 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;330 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;331 });332333 itEth('change owner call fee', async ({helper}) => {334 const owner = await helper.eth.createAccountWithBalance(donor);335 const [newOwner] = await helper.arrange.createAccounts([10n], donor);336 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');337 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);338339 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());340 expect(cost < BigInt(0.2 * Number(UNIQUE)));341 expect(cost > 0);342 });343344 //FIXME345 itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {346 const owner = await helper.eth.createAccountWithBalance(donor);347 const otherReceiver = await helper.eth.createAccountWithBalance(donor);348 const [newOwner] = await helper.arrange.createAccounts([10n], donor);349 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');350 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);351352 await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;353 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;354 });355});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {IKeyringPair} from '@polkadot/types/types';17import {UNIQUE} from '../util/helpers';18import {19 recordEthFee,20} from './util/helpers';21import {usingEthPlaygrounds, itEth, expect} from './util/playgrounds';2223describe('Add collection admins', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = privateKey('//Alice');29 });30 });3132 itEth('Add admin by owner', async ({helper}) => {33 const owner = await helper.eth.createAccountWithBalance(donor);34 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');35 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);3637 const newAdmin = helper.eth.createAccount();3839 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();40 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);41 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())42 .to.be.eq(newAdmin.toLocaleLowerCase());43 });4445 itEth.skip('Add substrate admin by owner', async ({helper}) => {46 const owner = await helper.eth.createAccountWithBalance(donor);47 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');48 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);4950 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);51 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();5253 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);54 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())55 .to.be.eq(newAdmin.address.toLocaleLowerCase());56 });5758 //FIXME:59 itEth('Verify owner or admin', async ({helper}) => {60 const owner = await helper.eth.createAccountWithBalance(donor);61 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');6263 const newAdmin = helper.eth.createAccount();64 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);65 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;66 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();67 expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;68 });6970 itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {71 const owner = await helper.eth.createAccountWithBalance(donor);72 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');7374 const admin = await helper.eth.createAccountWithBalance(donor);75 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);76 await collectionEvm.methods.addCollectionAdmin(admin).send();7778 const user = helper.eth.createAccount();79 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))80 .to.be.rejectedWith('NoPermission');8182 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);83 expect(adminList.length).to.be.eq(1);84 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())85 .to.be.eq(admin.toLocaleLowerCase());86 });8788 itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {89 const owner = await helper.eth.createAccountWithBalance(donor);90 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');9192 const notAdmin = await helper.eth.createAccountWithBalance(donor);93 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);9495 const user = helper.eth.createAccount();96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))97 .to.be.rejectedWith('NoPermission');9899 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);100 expect(adminList.length).to.be.eq(0);101 });102103 itEth.skip('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {104 const owner = await helper.eth.createAccountWithBalance(donor);105 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');106107 const admin = await helper.eth.createAccountWithBalance(donor);108 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);109 await collectionEvm.methods.addCollectionAdmin(admin).send();110111 const [notAdmin] = await helper.arrange.createAccounts([10n], donor);112 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))113 .to.be.rejectedWith('NoPermission');114115 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);116 expect(adminList.length).to.be.eq(1);117 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())118 .to.be.eq(admin.toLocaleLowerCase());119 });120121 itEth.skip('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {122 const owner = await helper.eth.createAccountWithBalance(donor);123 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');124125 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);126 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);127 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);128 await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))129 .to.be.rejectedWith('NoPermission');130131 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);132 expect(adminList.length).to.be.eq(0);133 });134});135136describe('Remove collection admins', () => {137 let donor: IKeyringPair;138139 before(async function() {140 await usingEthPlaygrounds(async (_helper, privateKey) => {141 donor = privateKey('//Alice');142 });143 });144145 itEth('Remove admin by owner', async ({helper}) => {146 const owner = await helper.eth.createAccountWithBalance(donor);147 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');148149 const newAdmin = helper.eth.createAccount();150 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);151 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();152153 {154 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);155 expect(adminList.length).to.be.eq(1);156 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())157 .to.be.eq(newAdmin.toLocaleLowerCase());158 }159160 await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();161 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);162 expect(adminList.length).to.be.eq(0);163 });164165 itEth.skip('Remove substrate admin by owner', async ({helper}) => {166 const owner = await helper.eth.createAccountWithBalance(donor);167 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');168169 const [newAdmin] = await helper.arrange.createAccounts([10n], donor);170 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);171 await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();172 {173 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);174 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())175 .to.be.eq(newAdmin.address.toLocaleLowerCase());176 }177178 await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();179 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);180 expect(adminList.length).to.be.eq(0);181 });182183 itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {184 const owner = await helper.eth.createAccountWithBalance(donor);185 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');186187 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);188189 const admin0 = await helper.eth.createAccountWithBalance(donor);190 await collectionEvm.methods.addCollectionAdmin(admin0).send();191 const admin1 = await helper.eth.createAccountWithBalance(donor);192 await collectionEvm.methods.addCollectionAdmin(admin1).send();193194 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))195 .to.be.rejectedWith('NoPermission');196 {197 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);198 expect(adminList.length).to.be.eq(2);199 expect(adminList.toString().toLocaleLowerCase())200 .to.be.deep.contains(admin0.toLocaleLowerCase())201 .to.be.deep.contains(admin1.toLocaleLowerCase());202 }203 });204205 itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {206 const owner = await helper.eth.createAccountWithBalance(donor);207 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');208209 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);210211 const admin = await helper.eth.createAccountWithBalance(donor);212 await collectionEvm.methods.addCollectionAdmin(admin).send();213 const notAdmin = helper.eth.createAccount();214215 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))216 .to.be.rejectedWith('NoPermission');217 {218 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);219 expect(adminList[0].asEthereum.toString().toLocaleLowerCase())220 .to.be.eq(admin.toLocaleLowerCase());221 expect(adminList.length).to.be.eq(1);222 }223 });224225 itEth.skip('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {226 const owner = await helper.eth.createAccountWithBalance(donor);227 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');228229 const [adminSub] = await helper.arrange.createAccounts([10n], donor);230 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);231 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();232 const adminEth = await helper.eth.createAccountWithBalance(donor);233 await collectionEvm.methods.addCollectionAdmin(adminEth).send();234235 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))236 .to.be.rejectedWith('NoPermission');237238 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);239 expect(adminList.length).to.be.eq(2);240 expect(adminList.toString().toLocaleLowerCase())241 .to.be.deep.contains(adminSub.address.toLocaleLowerCase())242 .to.be.deep.contains(adminEth.toLocaleLowerCase());243 });244245 itEth.skip('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {246 const owner = await helper.eth.createAccountWithBalance(donor);247 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');248249 const [adminSub] = await helper.arrange.createAccounts([10n], donor);250 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);251 await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();252 const notAdminEth = await helper.eth.createAccountWithBalance(donor);253254 await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))255 .to.be.rejectedWith('NoPermission');256257 const adminList = await helper.api!.rpc.unique.adminlist(collectionId);258 expect(adminList.length).to.be.eq(1);259 expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())260 .to.be.eq(adminSub.address.toLocaleLowerCase());261 });262});263264describe('Change owner tests', () => {265 let donor: IKeyringPair;266267 before(async function() {268 await usingEthPlaygrounds(async (_helper, privateKey) => {269 donor = privateKey('//Alice');270 });271 });272273 itEth('Change owner', async ({helper}) => {274 const owner = await helper.eth.createAccountWithBalance(donor);275 const newOwner = await helper.eth.createAccountWithBalance(donor);276 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');277 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);278279 await collectionEvm.methods.setOwner(newOwner).send();280281 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;282 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;283 });284285 itEth('change owner call fee', async ({helper}) => {286 const owner = await helper.eth.createAccountWithBalance(donor);287 const newOwner = await helper.eth.createAccountWithBalance(donor);288 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);290291 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwner(newOwner).send());292 expect(cost < BigInt(0.2 * Number(UNIQUE)));293 expect(cost > 0);294 });295296 //FIXME297 itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {298 const owner = await helper.eth.createAccountWithBalance(donor);299 const newOwner = await helper.eth.createAccountWithBalance(donor);300 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');301 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);302303 await expect(collectionEvm.methods.setOwner(newOwner).send({from: newOwner})).to.be.rejected;304 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;305 });306});307308describe('Change substrate owner tests', () => {309 let donor: IKeyringPair;310311 before(async function() {312 await usingEthPlaygrounds(async (_helper, privateKey) => {313 donor = privateKey('//Alice');314 });315 });316317 //FIXME318 itEth.skip('Change owner', async ({helper}) => {319 const owner = await helper.eth.createAccountWithBalance(donor);320 const [newOwner] = await helper.arrange.createAccounts([10n], donor);321 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');322 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);323324 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;325 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;326327 await collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send();328329 expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;330 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;331 });332333 itEth.skip('change owner call fee', async ({helper}) => {334 const owner = await helper.eth.createAccountWithBalance(donor);335 const [newOwner] = await helper.arrange.createAccounts([10n], donor);336 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');337 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);338339 const cost = await recordEthFee(helper.api!, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());340 expect(cost < BigInt(0.2 * Number(UNIQUE)));341 expect(cost > 0);342 });343344 //FIXME345 itEth.skip('(!negative tests!) call setOwner by non owner', async ({helper}) => {346 const owner = await helper.eth.createAccountWithBalance(donor);347 const otherReceiver = await helper.eth.createAccountWithBalance(donor);348 const [newOwner] = await helper.arrange.createAccounts([10n], donor);349 const {collectionAddress} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');350 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);351352 await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;353 expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;354 });355});