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

difftreelog

test fix burnFrom tests

Yaroslav Bolyukin2021-10-19parent: #ccd8d86.patch.diff
in: master

2 files changed

modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
38 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);38 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
3939
40 await usingApi(async (api) => {40 await usingApi(async (api) => {
41 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);41 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
42 const events = await submitTransactionAsync(alice, tx);42 const events = await submitTransactionAsync(alice, tx);
43 const result = getGenericResult(events);43 const result = getGenericResult(events);
44 // Get the item44 // Get the item
79 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);79 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
8080
81 await usingApi(async (api) => {81 await usingApi(async (api) => {
82 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);82 const tx = api.tx.nft.burnItem(collectionId, tokenId, 100);
83 const events = await submitTransactionAsync(alice, tx);83 const events = await submitTransactionAsync(alice, tx);
84 const result = getGenericResult(events);84 const result = getGenericResult(events);
85 85
166 });166 });
167167
168168
169 it('Burn item in Fungible collection', async () => {169 it.only('Burn item in Fungible collection', async () => {
170 const createMode = 'Fungible';170 const createMode = 'Fungible';
171 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});171 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
172 await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens172 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
173 await addCollectionAdminExpectSuccess(alice, collectionId, bob);173 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
174 const tokenId = 0; // ignored
175174
176 await usingApi(async (api) => {175 await usingApi(async (api) => {
177 // Destroy 1 of 10176 // Destroy 1 of 10
178 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);177 const tx = api.tx.nft.burnFrom(collectionId, alice.address, tokenId, 1);
179 const events = await submitTransactionAsync(bob, tx);178 const events = await submitTransactionAsync(bob, tx);
180 const result = getGenericResult(events);179 const result = getGenericResult(events);
181180
189 });188 });
190 });189 });
191190
192 it('Burn item in ReFungible collection', async () => {191 it.only('Burn item in ReFungible collection', async () => {
193 const createMode = 'ReFungible';192 const createMode = 'ReFungible';
194 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});193 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
195 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);194 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
196 await addCollectionAdminExpectSuccess(alice, collectionId, bob);195 await addCollectionAdminExpectSuccess(alice, collectionId, bob);
197196
198 await usingApi(async (api) => {197 await usingApi(async (api) => {
199 const tx = api.tx.nft.burnItem(collectionId, tokenId, 100);198 const tx = api.tx.nft.burnFrom(collectionId, alice.address, tokenId, 100);
200 const events = await submitTransactionAsync(bob, tx);199 const events = await submitTransactionAsync(bob, tx);
201 const result = getGenericResult(events);200 const result = getGenericResult(events);
202 // Get alice balance201 // Get alice balance
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
700 ReFungible: CreateReFungibleData;700 ReFungible: CreateReFungibleData;
701};701};
702702
703export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 0) {703export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 1) {
704 await usingApi(async (api) => {704 await usingApi(async (api) => {
705 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);705 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);
706 const events = await submitTransactionAsync(sender, tx);706 const events = await submitTransactionAsync(sender, tx);