git.delta.rocks / unique-network / refs/commits / 2efa82474035

difftreelog

test(refungible) check createMultipleItemsEx accepts properties for RFT

Yaroslav Bolyukin2022-08-08parent: #d4149b5.patch.diff
in: master

1 file changed

modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
1616
17import {expect} from 'chai';17import {expect} from 'chai';
18import usingApi, {executeTransaction} from './substrate/substrate-api';18import usingApi, {executeTransaction} from './substrate/substrate-api';
19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, getBalance, getLastTokenId} from './util/helpers';19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, getBalance, getLastTokenId, getTokenProperties} from './util/helpers';
2020
21describe('Integration Test: createMultipleItemsEx', () => {21describe.only('Integration Test: createMultipleItemsEx', () => {
22 it('can initialize multiple NFT with different owners', async () => {22 it('can initialize multiple NFT with different owners', async () => {
23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
24 await usingApi(async (api, privateKeyWrapper) => {24 await usingApi(async (api, privateKeyWrapper) => {
147 });147 });
148148
149 it('can initialize an RFT with multiple owners', async () => {149 it('can initialize an RFT with multiple owners', async () => {
150 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
151 await usingApi(async (api, privateKeyWrapper) => {150 await usingApi(async (api, privateKeyWrapper) => {
152 const alice = privateKeyWrapper('//Alice');151 const alice = privateKeyWrapper('//Alice');
153 const bob = privateKeyWrapper('//Bob');152 const bob = privateKeyWrapper('//Bob');
153 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
154 await executeTransaction(
155 api,
156 alice,
157 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'data', permission: {tokenOwner: true}}]),
158 );
154159
155 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {160 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {
156 RefungibleMultipleOwners: {161 RefungibleMultipleOwners: {
157 users: new Map([162 users: new Map([
158 [JSON.stringify({Substrate: alice.address}), 1],163 [JSON.stringify({Substrate: alice.address}), 1],
159 [JSON.stringify({Substrate: bob.address}), 2],164 [JSON.stringify({Substrate: bob.address}), 2],
160 ]),165 ]),
166 properties: [
167 {key: 'data', value: 'testValue'},
168 ],
161 },169 },
162 }));170 }));
163171
166174
167 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);175 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);
168 expect(await getBalance(api, collection, bob.address, 1)).to.be.equal(2n);176 expect(await getBalance(api, collection, bob.address, 1)).to.be.equal(2n);
177 expect((await getTokenProperties(api, collection, 1, ['data']))[0].value).to.be.equal('testValue');
169 });178 });
170 });179 });
171180
172 it('can initialize multiple RFTs with the same owner', async () => {181 it('can initialize multiple RFTs with the same owner', async () => {
182 await usingApi(async (api, privateKeyWrapper) => {
183 const alice = privateKeyWrapper('//Alice');
173 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});184 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
174 await usingApi(async (api, privateKeyWrapper) => {185 await executeTransaction(
186 api,
187 alice,
188 api.tx.unique.setTokenPropertyPermissions(collection, [{key: 'data', permission: {tokenOwner: true}}]),
175 const alice = privateKeyWrapper('//Alice');189 );
176190
177 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {191 await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {
178 RefungibleMultipleItems: [192 RefungibleMultipleItems: [
179 {user: {Substrate: alice.address}, pieces: 1},193 {
194 user: {Substrate: alice.address}, pieces: 1,
195 properties: [
196 {key: 'data', value: 'testValue1'},
197 ],
198 },
180 {user: {Substrate: alice.address}, pieces: 3},199 {
200 user: {Substrate: alice.address}, pieces: 3,
201 properties: [
202 {key: 'data', value: 'testValue2'},
203 ],
204 },
181 ],205 ],
182 }));206 }));
186210
187 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);211 expect(await getBalance(api, collection, alice.address, 1)).to.be.equal(1n);
188 expect(await getBalance(api, collection, alice.address, 2)).to.be.equal(3n);212 expect(await getBalance(api, collection, alice.address, 2)).to.be.equal(3n);
213 expect((await getTokenProperties(api, collection, 1, ['data']))[0].value).to.be.equal('testValue1');
214 expect((await getTokenProperties(api, collection, 2, ['data']))[0].value).to.be.equal('testValue2');
189 });215 });
190 });216 });
191});217});
192218