git.delta.rocks / unique-network / refs/commits / f15380e36126

difftreelog

CORE-302 Move test to separate file

Trubnikov Sergey2022-04-18parent: #0dc93c7.patch.diff
in: master

2 files changed

modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {17import {
18 collectionIdFromAddress,
19 collectionIdToAddress, 18 collectionIdToAddress,
20 contractHelpers,
21 createEthAccount, 19 createEthAccount,
22 createEthAccountWithBalance, 20 createEthAccountWithBalance,
23 deployFlipper, 21 deployFlipper,
28 usingWeb3,26 usingWeb3,
29} from './util/helpers';27} from './util/helpers';
30import {expect} from 'chai';28import {expect} from 'chai';
31import {createCollectionExpectSuccess, createItemExpectSuccess, getCreatedCollectionCount, getDetailedCollectionInfo, UNIQUE} from '../util/helpers';29import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../util/helpers';
32import nonFungibleAbi from './nonFungibleAbi.json';30import nonFungibleAbi from './nonFungibleAbi.json';
33import privateKey from '../substrate/privateKey';31import privateKey from '../substrate/privateKey';
34import {Contract} from 'web3-eth-contract';32import {Contract} from 'web3-eth-contract';
125 });123 });
126});124});
127
128describe('Create collection from EVM', () => {
129 itWeb3('Create collection', async ({api, web3}) => {
130 const owner = await createEthAccountWithBalance(api, web3);
131 const helpers = contractHelpers(web3, owner);
132 const collectionName = 'CollectionEVM';
133 const description = 'Some description';
134 const tokenPrefix = 'token prefix';
135
136 const collectionCountBefore = await getCreatedCollectionCount(api);
137 const result = await helpers.methods
138 .create721Collection(collectionName, description, tokenPrefix)
139 .send();
140 const collectionCountAfter = await getCreatedCollectionCount(api);
141
142 const collectionId = collectionIdFromAddress(result.events[0].raw.topics[2]);
143 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
144 expect(collectionId).to.be.eq(collectionCountAfter);
145
146 const collection = (await getDetailedCollectionInfo(api, collectionId))!;
147 expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);
148 expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);
149 expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);
150 });
151});
152125
addedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/createCollection.test.ts
@@ -0,0 +1,45 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {expect} from 'chai';
+import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';
+import {collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';
+
+describe('Create collection from EVM', () => {
+  itWeb3('Create collection', async ({api, web3}) => {
+    const owner = await createEthAccountWithBalance(api, web3);
+    const helpers = contractHelpers(web3, owner);
+    const collectionName = 'CollectionEVM';
+    const description = 'Some description';
+    const tokenPrefix = 'token prefix';
+  
+    const collectionCountBefore = await getCreatedCollectionCount(api);
+    const result = await helpers.methods
+      .create721Collection(collectionName, description, tokenPrefix)
+      .send();
+    const collectionCountAfter = await getCreatedCollectionCount(api);
+  
+    const collectionId = collectionIdFromAddress(result.events[0].raw.topics[2]);
+    expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
+    expect(collectionId).to.be.eq(collectionCountAfter);
+      
+    const collection = (await getDetailedCollectionInfo(api, collectionId))!;
+    expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);
+    expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);
+    expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);
+    expect(collection.schemaVersion.type).to.be.eq('ImageURL');
+  });
+});
\ No newline at end of file