git.delta.rocks / unique-network / refs/commits / 483c1f0fdc08

difftreelog

Combine refungible tests

Max Andreev2023-01-13parent: #3c77c1e.patch.diff
in: master

9 files changed

modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
46 expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);46 expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);
47 });47 });
48
49 itSub.ifWithPallets('Burn item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
50 const collection = await helper.rft.mintCollection(alice);
51 const token = await collection.mintToken(alice, 100n);
52
53 await token.burn(alice, 90n);
54 expect(await token.getBalance({Substrate: alice.address})).to.eq(10n);
55
56 await token.burn(alice, 10n);
57 expect(await token.getBalance({Substrate: alice.address})).to.eq(0n);
58 });
59
60 itSub.ifWithPallets('Burn owned portion of item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
61 const collection = await helper.rft.mintCollection(alice);
62 const token = await collection.mintToken(alice, 100n);
63
64 await token.transfer(alice, {Substrate: bob.address}, 1n);
65
66 expect(await token.getBalance({Substrate: alice.address})).to.eq(99n);
67 expect(await token.getBalance({Substrate: bob.address})).to.eq(1n);
68
69 await token.burn(bob, 1n);
70
71 expect(await token.getBalance({Substrate: alice.address})).to.eq(99n);
72 expect(await token.getBalance({Substrate: bob.address})).to.eq(0n);
73 });
74});48});
7549
76describe('integration test: ext. burnItem() with admin permissions:', () => {50describe('integration test: ext. burnItem() with admin permissions:', () => {
105 expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);79 expect(await collection.getBalance({Substrate: alice.address})).to.eq(9n);
106 });80 });
107
108 itSub.ifWithPallets('Burn item in ReFungible collection', [Pallets.ReFungible], async function({helper}) {
109 const collection = await helper.rft.mintCollection(alice);
110 await collection.setLimits(alice, {ownerCanTransfer: true});
111 await collection.addAdmin(alice, {Substrate: bob.address});
112 const token = await collection.mintToken(alice, 100n);
113
114 await token.burnFrom(bob, {Substrate: alice.address}, 100n);
115 expect(await token.doesExist()).to.be.false;
116 });
117});81});
11882
119describe('Negative integration test: ext. burnItem():', () => {83describe('Negative integration test: ext. burnItem():', () => {
140 await expect(token.burn(bob)).to.be.rejectedWith('common.NoPermission');104 await expect(token.burn(bob)).to.be.rejectedWith('common.NoPermission');
141 });105 });
142
143 itSub.ifWithPallets('RFT: cannot burn non-owned token pieces', [Pallets.ReFungible], async ({helper}) => {
144 const collection = await helper.rft.mintCollection(alice);
145 const aliceToken = await collection.mintToken(alice, 10n, {Substrate: alice.address});
146 const bobToken = await collection.mintToken(alice, 10n, {Substrate: bob.address});
147
148 // 1. Cannot burn non-owned token:
149 await expect(bobToken.burn(alice, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
150 await expect(bobToken.burn(alice, 5n)).to.be.rejectedWith('common.TokenValueTooLow');
151 // 2. Cannot burn non-existing token:
152 await expect(helper.rft.burnToken(alice, 99999, 10)).to.be.rejectedWith('common.CollectionNotFound');
153 await expect(helper.rft.burnToken(alice, collection.collectionId, 99999)).to.be.rejectedWith('common.TokenValueTooLow');
154 // 3. Can burn zero amount of owned tokens (EIP-20)
155 await aliceToken.burn(alice, 0n);
156
157 // 4. Storage is not corrupted:
158 expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
159 expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
160
161 // 4.1 Tokens can be transfered:
162 await aliceToken.transfer(alice, {Substrate: bob.address}, 10n);
163 await bobToken.transfer(bob, {Substrate: alice.address}, 10n);
164 expect(await aliceToken.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
165 expect(await bobToken.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
166 });
167106
168 itSub('Transfer a burned token', async ({helper}) => {107 itSub('Transfer a burned token', async ({helper}) => {
169 const collection = await helper.nft.mintCollection(alice);108 const collection = await helper.nft.mintCollection(alice);
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
4343
44 expect(events).to.be.deep.equal([44 expect(events).to.be.deep.equal([
45 {45 {
46 address: COLLECTION_HELPER,46 address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',
47 event: 'CollectionCreated',47 event: 'CollectionCreated',
48 args: {48 args: {
49 owner: owner,49 owner: owner,
modifiedtests/src/nesting/nest.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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import {expect, itSub, Pallets, usingPlaygrounds} from '../util';18import {expect, itSub, usingPlaygrounds} from '../util';
1919
20describe('Integration Test: Composite nesting tests', () => {20describe('Integration Test: Composite nesting tests', () => {
21 let alice: IKeyringPair;21 let alice: IKeyringPair;
289 expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);289 expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);
290 });290 });
291
292 // ---------- Re-Fungible ----------
293
294 itSub.ifWithPallets('ReFungible: allows an Owner to nest/unnest their token', [Pallets.ReFungible], async ({helper}) => {
295 const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}}});
296 const collectionRFT = await helper.rft.mintCollection(alice);
297 const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
298
299 await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
300 await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
301
302 await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
303 await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
304 await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
305
306 // Create an immediately nested token
307 const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
308 expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
309
310 // Create a token to be nested and nest
311 const newToken = await collectionRFT.mintToken(charlie, 5n);
312 await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
313 expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
314 });
315
316 itSub.ifWithPallets('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
317 const collectionNFT = await helper.nft.mintCollection(alice);
318 const collectionRFT = await helper.rft.mintCollection(alice);
319 const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
320
321 await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted:[collectionRFT.collectionId]}});
322 await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
323 await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
324
325 await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
326 await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
327 await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
328
329 // Create an immediately nested token
330 const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
331 expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
332
333 // Create a token to be nested and nest
334 const newToken = await collectionRFT.mintToken(charlie, 5n);
335 await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
336 expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
337 });
338});291});
339292
340describe('Negative Test: Nesting', () => {293describe('Negative Test: Nesting', () => {
581 expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(5n);534 expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(5n);
582 });535 });
583
584 // ---------- Re-Fungible ----------
585
586 itSub.ifWithPallets('ReFungible: disallows to nest token if nesting is disabled', [Pallets.ReFungible], async ({helper}) => {
587 const collectionNFT = await helper.nft.mintCollection(alice);
588 const collectionRFT = await helper.rft.mintCollection(alice);
589 const targetToken = await collectionNFT.mintToken(alice);
590
591 // Try to create an immediately nested token
592 await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
593 .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
594
595 // Try to create a token to be nested and nest
596 const token = await collectionRFT.mintToken(alice, 5n);
597 await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
598 .to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
599 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
600 });
601
602 itSub.ifWithPallets('ReFungible: disallows a non-Owner to nest someone else\'s token', [Pallets.ReFungible], async ({helper}) => {
603 const collectionNFT = await helper.nft.mintCollection(alice);
604 const collectionRFT = await helper.rft.mintCollection(alice);
605 const targetToken = await collectionNFT.mintToken(alice);
606
607 await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}});
608 await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
609 await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
610
611 // Try to create a token to be nested and nest
612 const newToken = await collectionRFT.mintToken(alice);
613 await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
614
615 expect(await targetToken.getChildren()).to.be.length(0);
616 expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
617
618 // Nest some tokens as Alice into Bob's token
619 await newToken.transfer(alice, targetToken.nestingAccount());
620
621 // Try to pull it out
622 await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
623 .to.be.rejectedWith(/common\.ApprovedValueTooLow/);
624 expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
625 });
626
627 itSub.ifWithPallets('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
628 const collectionNFT = await helper.nft.mintCollection(alice);
629 const collectionRFT = await helper.rft.mintCollection(alice);
630 const targetToken = await collectionNFT.mintToken(alice);
631
632 await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted: [collectionRFT.collectionId]}});
633 await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
634 await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
635
636 // Try to create a token to be nested and nest
637 const newToken = await collectionRFT.mintToken(alice);
638 await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
639
640 expect(await targetToken.getChildren()).to.be.length(0);
641 expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
642
643 // Nest some tokens as Alice into Bob's token
644 await newToken.transfer(alice, targetToken.nestingAccount());
645
646 // Try to pull it out
647 await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
648 .to.be.rejectedWith(/common\.ApprovedValueTooLow/);
649 expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
650 });
651
652 itSub.ifWithPallets('ReFungible: disallows to nest token to an unlisted collection', [Pallets.ReFungible], async ({helper}) => {
653 const collectionNFT = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true, restricted: []}}});
654 const collectionRFT = await helper.rft.mintCollection(alice);
655 const targetToken = await collectionNFT.mintToken(alice);
656
657 // Try to create an immediately nested token
658 await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
659 .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
660
661 // Try to create a token to be nested and nest
662 const token = await collectionRFT.mintToken(alice, 5n);
663 await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
664 .to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
665 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
666 });
667});536});
668537
modifiedtests/src/nesting/unnest.test.tsdiffbeforeafterboth
64 expect(await targetToken.getChildren()).to.be.length(0);64 expect(await targetToken.getChildren()).to.be.length(0);
65 });65 });
66
67 itSub.ifWithPallets('ReFungible: allows the owner to successfully unnest a token', [Pallets.ReFungible], async ({helper}) => {
68 const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
69 const targetToken = await collection.mintToken(alice);
70
71 const collectionRFT = await helper.rft.mintCollection(alice);
72
73 // Nest and unnest
74 const token = await collectionRFT.mintToken(alice, 10n, targetToken.nestingAccount());
75 await expect(token.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 9n), 'while unnesting').to.be.fulfilled;
76 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(9n);
77 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
78
79 // Nest and burn
80 await token.transfer(alice, targetToken.nestingAccount(), 5n);
81 await expect(token.burnFrom(alice, targetToken.nestingAccount(), 6n), 'while burning').to.be.fulfilled;
82 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(4n);
83 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
84 expect(await targetToken.getChildren()).to.be.length(0);
85 });
86});66});
8767
88describe('Negative Test: Unnesting', () => {68describe('Negative Test: Unnesting', () => {
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
88 expect((await token.getTop10Owners()).length).to.be.equal(10);88 expect((await token.getTop10Owners()).length).to.be.equal(10);
89 });89 });
90
91 itSub('Transfer token pieces', async ({helper}) => {
92 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
93 const token = await collection.mintToken(alice, 100n);
94
95 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
96 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
97
98 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
99 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
100
101 await expect(token.transfer(alice, {Substrate: bob.address}, 41n))
102 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
103 });
10490
105 itSub('Create multiple tokens', async ({helper}) => {91 itSub('Create multiple tokens', async ({helper}) => {
106 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});92 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
120 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);106 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);
121 });107 });
122
123 itSub('Burn some pieces', async ({helper}) => {
124 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
125 const token = await collection.mintToken(alice, 100n);
126 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
127 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
128 expect(await token.burn(alice, 99n)).to.be.true;
129 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
130 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);
131 });
132
133 itSub('Burn all pieces', async ({helper}) => {
134 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
135 const token = await collection.mintToken(alice, 100n);
136
137 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
138 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
139
140 expect(await token.burn(alice, 100n)).to.be.true;
141 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
142 });
143
144 itSub('Burn some pieces for multiple users', async ({helper}) => {
145 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
146 const token = await collection.mintToken(alice, 100n);
147
148 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
149
150 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
151 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
152
153 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);
154 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);
155
156 expect(await token.burn(alice, 40n)).to.be.true;
157
158 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
159 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
160
161 expect(await token.burn(bob, 59n)).to.be.true;
162
163 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);
164 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
165
166 expect(await token.burn(bob, 1n)).to.be.true;
167
168 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
169 });
170108
171 itSub('Set allowance for token', async ({helper}) => {109 itSub('Set allowance for token', async ({helper}) => {
172 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});110 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
183 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);121 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);
184 });122 });
185
186 itSub('Repartition', async ({helper}) => {
187 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
188 const token = await collection.mintToken(alice, 100n);
189
190 expect(await token.repartition(alice, 200n)).to.be.true;
191 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);
192 expect(await token.getTotalPieces()).to.be.equal(200n);
193
194 expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;
195 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);
196 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);
197
198 await expect(token.repartition(alice, 80n))
199 .to.eventually.be.rejectedWith(/refungible\.RepartitionWhileNotOwningAllPieces/);
200
201 expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;
202 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
203 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);
204
205 expect(await token.repartition(bob, 150n)).to.be.true;
206 await expect(token.transfer(bob, {Substrate: alice.address}, 160n))
207 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);
208 });
209
210 itSub('Repartition with increased amount', async ({helper}) => {
211 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
212 const token = await collection.mintToken(alice, 100n);
213 await token.repartition(alice, 200n);
214 const chainEvents = helper.chainLog.slice(-1)[0].events;
215 const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemCreated');
216 expect(event).to.deep.include({
217 section: 'common',
218 method: 'ItemCreated',
219 index: [66, 2],
220 data: [
221 collection.collectionId,
222 token.tokenId,
223 {substrate: alice.address},
224 100n,
225 ],
226 });
227 });
228
229 itSub('Repartition with decreased amount', async ({helper}) => {
230 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
231 const token = await collection.mintToken(alice, 100n);
232 await token.repartition(alice, 50n);
233 const chainEvents = helper.chainLog.slice(-1)[0].events;
234 const event = chainEvents.find((event: any) => event.section === 'common' && event.method === 'ItemDestroyed');
235 expect(event).to.deep.include({
236 section: 'common',
237 method: 'ItemDestroyed',
238 index: [66, 3],
239 data: [
240 collection.collectionId,
241 token.tokenId,
242 {substrate: alice.address},
243 50n,
244 ],
245 });
246 });
247123
248 itSub('Create new collection with properties', async ({helper}) => {124 itSub('Create new collection with properties', async ({helper}) => {
249 const properties = [{key: 'key1', value: 'val1'}];125 const properties = [{key: 'key1', value: 'val1'}];
255 });131 });
256});132});
257
258describe('Refungible negative tests', () => {
259 let donor: IKeyringPair;
260 let alice: IKeyringPair;
261 let bob: IKeyringPair;
262 let charlie: IKeyringPair;
263
264 before(async function() {
265 await usingPlaygrounds(async (helper, privateKey) => {
266 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
267
268 donor = await privateKey({filename: __filename});
269 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
270 });
271 });
272
273 itSub('Cannot transfer incorrect amount of token pieces', async ({helper}) => {
274 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
275 const tokenAlice = await collection.mintToken(alice, 10n, {Substrate: alice.address});
276 const tokenBob = await collection.mintToken(alice, 10n, {Substrate: bob.address});
277
278 // 1. Alice cannot transfer Bob's token:
279 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
280 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
281 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow');
282 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow');
283
284 // 2. Alice cannot transfer non-existing token:
285 await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');
286 await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');
287
288 // 3. Zero transfer allowed (EIP-20):
289 await tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n);
290
291 expect(await tokenAlice.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);
292 expect(await tokenBob.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);
293 expect(await tokenAlice.getBalance({Substrate: alice.address})).to.eq(10n);
294 expect(await tokenBob.getBalance({Substrate: bob.address})).to.eq(10n);
295 expect(await tokenBob.getBalance({Substrate: charlie.address})).to.eq(0n);
296 });
297});
298133
addedtests/src/sub/refungible/burn.test.tsdiffbeforeafterboth

no changes

addedtests/src/sub/refungible/nesting.test.tsdiffbeforeafterboth

no changes

addedtests/src/sub/refungible/repartition.test.tsdiffbeforeafterboth

no changes

addedtests/src/sub/refungible/transfer.test.tsdiffbeforeafterboth

no changes