difftreelog
CORE-386 Fix error case
in: master
3 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -105,7 +105,7 @@
.confirm_sponsorship(caller.as_sub())
.map_err(dispatch_to_evm::<T>)?
{
- return Err("Caller is not set as sponsor".into());
+ return Err("caller is not set as sponsor".into());
}
save(self)
}
@@ -136,7 +136,7 @@
}
_ => {
return Err(Error::Revert(format!(
- "Unknown integer limit \"{}\"",
+ "unknown integer limit \"{}\"",
limit
)))
}
@@ -163,7 +163,7 @@
}
_ => {
return Err(Error::Revert(format!(
- "Unknown boolean limit \"{}\"",
+ "unknown boolean limit \"{}\"",
limit
)))
}
@@ -244,11 +244,11 @@
collections: Vec<address>,
) -> Result<void> {
if collections.is_empty() {
- return Err("No addresses provided".into());
+ return Err("no addresses provided".into());
}
if collections.len() >= OwnerRestrictedSet::bound() {
return Err(Error::Revert(format!(
- "Out of bound: {} >= {}",
+ "out of bound: {} >= {}",
collections.len(),
OwnerRestrictedSet::bound()
)));
@@ -261,7 +261,7 @@
let mut bv = OwnerRestrictedSet::new();
for i in collections {
bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {
- Error::Revert("Can't convert address into collection id".into())
+ Error::Revert("can't convert address into collection id".into())
})?)
.map_err(|e| Error::Revert(format!("{:?}", e)))?;
}
@@ -286,7 +286,7 @@
access: Some(match mode {
0 => AccessMode::Normal,
1 => AccessMode::AllowList,
- _ => return Err("Not supported access mode".into()),
+ _ => return Err("not supported access mode".into()),
}),
..Default::default()
};
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -233,7 +233,7 @@
const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
- await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+ await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
@@ -302,7 +302,7 @@
const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;
expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
- await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+ await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
await sponsorCollection.methods.confirmCollectionSponsorship().send();
collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
tests/src/eth/createCollection.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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {expect} from 'chai';19import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';20import {21 evmCollectionHelpers,22 collectionIdToAddress,23 createEthAccount,24 createEthAccountWithBalance,25 evmCollection,26 itWeb3,27 getCollectionAddressFromResult,28} from './util/helpers';2930describe('Create collection from EVM', () => {31 // itWeb3('Create collection', async ({api, web3, privateKeyWrapper}) => {32 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);33 // const collectionHelper = evmCollectionHelpers(web3, owner);34 // const collectionName = 'CollectionEVM';35 // const description = 'Some description';36 // const tokenPrefix = 'token prefix';37 38 // const collectionCountBefore = await getCreatedCollectionCount(api);39 // const result = await collectionHelper.methods40 // .createNonfungibleCollection(collectionName, description, tokenPrefix)41 // .send();42 // const collectionCountAfter = await getCreatedCollectionCount(api);43 44 // const {collectionId, collection} = await getCollectionAddressFromResult(api, result);45 // expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);46 // expect(collectionId).to.be.eq(collectionCountAfter);47 // expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);48 // expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);49 // expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);50 // });5152 // itWeb3('Check collection address exist', async ({api, web3, privateKeyWrapper}) => {53 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);54 // const collectionHelpers = evmCollectionHelpers(web3, owner);55 56 // const expectedCollectionId = await getCreatedCollectionCount(api) + 1;57 // const expectedCollectionAddress = collectionIdToAddress(expectedCollectionId);58 // expect(await collectionHelpers.methods59 // .isCollectionExist(expectedCollectionAddress)60 // .call()).to.be.false;6162 // await collectionHelpers.methods63 // .createNonfungibleCollection('A', 'A', 'A')64 // .send();65 66 // expect(await collectionHelpers.methods67 // .isCollectionExist(expectedCollectionAddress)68 // .call()).to.be.true;69 // });70 71 itWeb3('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {72 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);73 const collectionHelpers = evmCollectionHelpers(web3, owner);74 let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();75 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);76 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);77 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);78 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();79 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;80 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;81 const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;82 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));83 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');84 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);85 await sponsorCollection.methods.confirmCollectionSponsorship().send();86 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;87 expect(collectionSub.sponsorship.isConfirmed).to.be.true;88 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));89 });9091 itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {92 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);93 const collectionHelpers = evmCollectionHelpers(web3, owner);94 const result = await collectionHelpers.methods.createNonfungibleCollection('Const collection', '5', '5').send();95 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);96 const limits = {97 accountTokenOwnershipLimit: 1000,98 sponsoredDataSize: 1024,99 sponsoredDataRateLimit: 30,100 tokenLimit: 1000000,101 sponsorTransferTimeout: 6,102 sponsorApproveTimeout: 6,103 ownerCanTransfer: false,104 ownerCanDestroy: false,105 transfersEnabled: false,106 };107108 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);109 await collectionEvm.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();110 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();111 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();112 await collectionEvm.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();113 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();114 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();115 await collectionEvm.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();116 await collectionEvm.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();117 await collectionEvm.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();118 119 const collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;120 expect(collectionSub.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit);121 expect(collectionSub.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize);122 expect(collectionSub.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.be.eq(limits.sponsoredDataRateLimit);123 expect(collectionSub.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit);124 expect(collectionSub.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout);125 expect(collectionSub.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout);126 expect(collectionSub.limits.ownerCanTransfer.toHuman()).to.be.eq(limits.ownerCanTransfer);127 expect(collectionSub.limits.ownerCanDestroy.toHuman()).to.be.eq(limits.ownerCanDestroy);128 expect(collectionSub.limits.transfersEnabled.toHuman()).to.be.eq(limits.transfersEnabled);129 });130131 itWeb3('Collection address exist', async ({api, web3, privateKeyWrapper}) => {132 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);133 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';134 const collectionHelpers = evmCollectionHelpers(web3, owner);135 expect(await collectionHelpers.methods136 .isCollectionExist(collectionAddressForNonexistentCollection).call())137 .to.be.false;138 139 const result = await collectionHelpers.methods.createNonfungibleCollection('Collection address exist', '7', '7').send();140 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);141 expect(await collectionHelpers.methods142 .isCollectionExist(collectionIdAddress).call())143 .to.be.true;144 });145});146147describe('(!negative tests!) Create collection from EVM', () => {148 itWeb3('(!negative test!) Create collection (bad lengths)', async ({api, web3, privateKeyWrapper}) => {149 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);150 const helper = evmCollectionHelpers(web3, owner);151 {152 const MAX_NAME_LENGHT = 64;153 const collectionName = 'A'.repeat(MAX_NAME_LENGHT + 1);154 const description = 'A';155 const tokenPrefix = 'A';156 157 await expect(helper.methods158 .createNonfungibleCollection(collectionName, description, tokenPrefix)159 .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGHT);160 161 }162 { 163 const MAX_DESCRIPTION_LENGHT = 256;164 const collectionName = 'A';165 const description = 'A'.repeat(MAX_DESCRIPTION_LENGHT + 1);166 const tokenPrefix = 'A';167 await expect(helper.methods168 .createNonfungibleCollection(collectionName, description, tokenPrefix)169 .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGHT);170 }171 { 172 const MAX_TOKEN_PREFIX_LENGHT = 16;173 const collectionName = 'A';174 const description = 'A';175 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGHT + 1);176 await expect(helper.methods177 .createNonfungibleCollection(collectionName, description, tokenPrefix)178 .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGHT);179 }180 });181 182 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {183 const owner = await createEthAccount(web3);184 const helper = evmCollectionHelpers(web3, owner);185 const collectionName = 'A';186 const description = 'A';187 const tokenPrefix = 'A';188 189 await expect(helper.methods190 .createNonfungibleCollection(collectionName, description, tokenPrefix)191 .call()).to.be.rejectedWith('NotSufficientFounds');192 });193194 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {195 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);196 const notOwner = await createEthAccount(web3);197 const collectionHelpers = evmCollectionHelpers(web3, owner);198 const result = await collectionHelpers.methods.createNonfungibleCollection('A', 'A', 'A').send();199 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);200 const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress);201 const EXPECTED_ERROR = 'NoPermission';202 {203 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);204 await expect(contractEvmFromNotOwner.methods205 .setCollectionSponsor(sponsor)206 .call()).to.be.rejectedWith(EXPECTED_ERROR);207 208 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);209 await expect(sponsorCollection.methods210 .confirmCollectionSponsorship()211 .call()).to.be.rejectedWith('Caller is not set as sponsor');212 }213 {214 await expect(contractEvmFromNotOwner.methods215 .setCollectionLimit('account_token_ownership_limit', '1000')216 .call()).to.be.rejectedWith(EXPECTED_ERROR);217 }218 });219220 itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {221 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);222 const collectionHelpers = evmCollectionHelpers(web3, owner);223 const result = await collectionHelpers.methods.createNonfungibleCollection('Schema collection', 'A', 'A').send();224 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);225 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);226 await expect(collectionEvm.methods227 .setCollectionLimit('badLimit', 'true')228 .call()).to.be.rejectedWith('Unknown boolean limit "badLimit"');229 });230});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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {expect} from 'chai';19import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';20import {21 evmCollectionHelpers,22 collectionIdToAddress,23 createEthAccount,24 createEthAccountWithBalance,25 evmCollection,26 itWeb3,27 getCollectionAddressFromResult,28} from './util/helpers';2930describe('Create collection from EVM', () => {31 // itWeb3('Create collection', async ({api, web3, privateKeyWrapper}) => {32 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);33 // const collectionHelper = evmCollectionHelpers(web3, owner);34 // const collectionName = 'CollectionEVM';35 // const description = 'Some description';36 // const tokenPrefix = 'token prefix';37 38 // const collectionCountBefore = await getCreatedCollectionCount(api);39 // const result = await collectionHelper.methods40 // .createNonfungibleCollection(collectionName, description, tokenPrefix)41 // .send();42 // const collectionCountAfter = await getCreatedCollectionCount(api);43 44 // const {collectionId, collection} = await getCollectionAddressFromResult(api, result);45 // expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);46 // expect(collectionId).to.be.eq(collectionCountAfter);47 // expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);48 // expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);49 // expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);50 // });5152 // itWeb3('Check collection address exist', async ({api, web3, privateKeyWrapper}) => {53 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);54 // const collectionHelpers = evmCollectionHelpers(web3, owner);55 56 // const expectedCollectionId = await getCreatedCollectionCount(api) + 1;57 // const expectedCollectionAddress = collectionIdToAddress(expectedCollectionId);58 // expect(await collectionHelpers.methods59 // .isCollectionExist(expectedCollectionAddress)60 // .call()).to.be.false;6162 // await collectionHelpers.methods63 // .createNonfungibleCollection('A', 'A', 'A')64 // .send();65 66 // expect(await collectionHelpers.methods67 // .isCollectionExist(expectedCollectionAddress)68 // .call()).to.be.true;69 // });70 71 itWeb3('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {72 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);73 const collectionHelpers = evmCollectionHelpers(web3, owner);74 let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();75 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);76 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);77 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);78 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();79 let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;80 expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;81 const ss58Format = (api.registry.getChainProperties())!.toJSON().ss58Format;82 expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));83 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');84 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);85 await sponsorCollection.methods.confirmCollectionSponsorship().send();86 collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;87 expect(collectionSub.sponsorship.isConfirmed).to.be.true;88 expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));89 });9091 itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {92 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);93 const collectionHelpers = evmCollectionHelpers(web3, owner);94 const result = await collectionHelpers.methods.createNonfungibleCollection('Const collection', '5', '5').send();95 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);96 const limits = {97 accountTokenOwnershipLimit: 1000,98 sponsoredDataSize: 1024,99 sponsoredDataRateLimit: 30,100 tokenLimit: 1000000,101 sponsorTransferTimeout: 6,102 sponsorApproveTimeout: 6,103 ownerCanTransfer: false,104 ownerCanDestroy: false,105 transfersEnabled: false,106 };107108 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);109 await collectionEvm.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();110 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();111 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();112 await collectionEvm.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();113 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();114 await collectionEvm.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();115 await collectionEvm.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();116 await collectionEvm.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();117 await collectionEvm.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();118 119 const collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;120 expect(collectionSub.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.eq(limits.accountTokenOwnershipLimit);121 expect(collectionSub.limits.sponsoredDataSize.unwrap().toNumber()).to.be.eq(limits.sponsoredDataSize);122 expect(collectionSub.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.be.eq(limits.sponsoredDataRateLimit);123 expect(collectionSub.limits.tokenLimit.unwrap().toNumber()).to.be.eq(limits.tokenLimit);124 expect(collectionSub.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorTransferTimeout);125 expect(collectionSub.limits.sponsorApproveTimeout.unwrap().toNumber()).to.be.eq(limits.sponsorApproveTimeout);126 expect(collectionSub.limits.ownerCanTransfer.toHuman()).to.be.eq(limits.ownerCanTransfer);127 expect(collectionSub.limits.ownerCanDestroy.toHuman()).to.be.eq(limits.ownerCanDestroy);128 expect(collectionSub.limits.transfersEnabled.toHuman()).to.be.eq(limits.transfersEnabled);129 });130131 itWeb3('Collection address exist', async ({api, web3, privateKeyWrapper}) => {132 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);133 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';134 const collectionHelpers = evmCollectionHelpers(web3, owner);135 expect(await collectionHelpers.methods136 .isCollectionExist(collectionAddressForNonexistentCollection).call())137 .to.be.false;138 139 const result = await collectionHelpers.methods.createNonfungibleCollection('Collection address exist', '7', '7').send();140 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);141 expect(await collectionHelpers.methods142 .isCollectionExist(collectionIdAddress).call())143 .to.be.true;144 });145});146147describe('(!negative tests!) Create collection from EVM', () => {148 itWeb3('(!negative test!) Create collection (bad lengths)', async ({api, web3, privateKeyWrapper}) => {149 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);150 const helper = evmCollectionHelpers(web3, owner);151 {152 const MAX_NAME_LENGHT = 64;153 const collectionName = 'A'.repeat(MAX_NAME_LENGHT + 1);154 const description = 'A';155 const tokenPrefix = 'A';156 157 await expect(helper.methods158 .createNonfungibleCollection(collectionName, description, tokenPrefix)159 .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGHT);160 161 }162 { 163 const MAX_DESCRIPTION_LENGHT = 256;164 const collectionName = 'A';165 const description = 'A'.repeat(MAX_DESCRIPTION_LENGHT + 1);166 const tokenPrefix = 'A';167 await expect(helper.methods168 .createNonfungibleCollection(collectionName, description, tokenPrefix)169 .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGHT);170 }171 { 172 const MAX_TOKEN_PREFIX_LENGHT = 16;173 const collectionName = 'A';174 const description = 'A';175 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGHT + 1);176 await expect(helper.methods177 .createNonfungibleCollection(collectionName, description, tokenPrefix)178 .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGHT);179 }180 });181 182 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {183 const owner = await createEthAccount(web3);184 const helper = evmCollectionHelpers(web3, owner);185 const collectionName = 'A';186 const description = 'A';187 const tokenPrefix = 'A';188 189 await expect(helper.methods190 .createNonfungibleCollection(collectionName, description, tokenPrefix)191 .call()).to.be.rejectedWith('NotSufficientFounds');192 });193194 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {195 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);196 const notOwner = await createEthAccount(web3);197 const collectionHelpers = evmCollectionHelpers(web3, owner);198 const result = await collectionHelpers.methods.createNonfungibleCollection('A', 'A', 'A').send();199 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);200 const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress);201 const EXPECTED_ERROR = 'NoPermission';202 {203 const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);204 await expect(contractEvmFromNotOwner.methods205 .setCollectionSponsor(sponsor)206 .call()).to.be.rejectedWith(EXPECTED_ERROR);207 208 const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);209 await expect(sponsorCollection.methods210 .confirmCollectionSponsorship()211 .call()).to.be.rejectedWith('caller is not set as sponsor');212 }213 {214 await expect(contractEvmFromNotOwner.methods215 .setCollectionLimit('account_token_ownership_limit', '1000')216 .call()).to.be.rejectedWith(EXPECTED_ERROR);217 }218 });219220 itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {221 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);222 const collectionHelpers = evmCollectionHelpers(web3, owner);223 const result = await collectionHelpers.methods.createNonfungibleCollection('Schema collection', 'A', 'A').send();224 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);225 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);226 await expect(collectionEvm.methods227 .setCollectionLimit('badLimit', 'true')228 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');229 });230});