difftreelog
Fixed addCollectionAdmin.test.ts
in: master
8 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5850,34 +5850,34 @@
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
+source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.7#9c572625f6557dfdb19f47474369a0327d51dfbc"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
- "serde",
- "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
- "substrate-test-utils",
- "up-sponsorship",
]
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
-source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.7#9c572625f6557dfdb19f47474369a0327d51dfbc"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
+ "serde",
+ "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
+ "substrate-test-utils",
+ "up-sponsorship",
]
[[package]]
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -22,7 +22,7 @@
const bob = privateKey('//Bob');
const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.Owner).to.be.deep.eq(normalizeAccountId(alice.address));
+ expect(collection.Owner).to.be.equal(alice.address);
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await submitTransactionAsync(alice, changeAdminTx);
@@ -40,7 +40,7 @@
const Charlie = privateKey('//CHARLIE');
const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));
+ expect(collection.Owner).to.be.equal(Alice.address);
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
await submitTransactionAsync(Alice, changeAdminTx);
tests/src/config.tsdiffbeforeafterboth--- a/tests/src/config.ts
+++ b/tests/src/config.ts
@@ -6,7 +6,7 @@
import process from 'process';
const config = {
- substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844',
+ substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944',
};
export default config;
\ No newline at end of file
tests/src/contracts.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import usingApi, { submitTransactionAsync } from './substrate/substrate-api';9import fs from 'fs';10import { Abi, ContractPromise as Contract } from '@polkadot/api-contract';11import privateKey from './substrate/privateKey';12import {13 deployFlipper,14 getFlipValue,15 deployTransferContract,16} from './util/contracthelpers';1718import {19 addToWhiteListExpectSuccess,20 approveExpectSuccess,21 createCollectionExpectSuccess,22 createItemExpectSuccess,23 enablePublicMintingExpectSuccess,24 enableWhiteListExpectSuccess,25 getGenericResult,26 normalizeAccountId,27 isWhitelisted,28 transferFromExpectSuccess,29} from './util/helpers';303132chai.use(chaiAsPromised);33const expect = chai.expect;3435const value = 0;36const gasLimit = 9000n * 1000000n;37const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';3839describe('Contracts', () => {40 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {41 await usingApi(async api => {42 const [contract, deployer] = await deployFlipper(api);43 const initialGetResponse = await getFlipValue(contract, deployer);4445 const bob = privateKey('//Bob');46 const flip = contract.tx.flip(value, gasLimit);47 await submitTransactionAsync(bob, flip);4849 const afterFlipGetResponse = await getFlipValue(contract, deployer);50 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');51 });52 });5354 it('Can initialize contract instance', async () => {55 await usingApi(async (api) => {56 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));57 const abi = new Abi(metadata);58 const newContractInstance = new Contract(api, abi, marketContractAddress);59 expect(newContractInstance).to.have.property('address');60 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);61 });62 });63});6465describe.only('Chain extensions', () => {66 it('Transfer CE', async () => {67 await usingApi(async api => {68 const alice = privateKey('//Alice');69 const bob = privateKey('//Bob');7071 // Prep work72 const collectionId = await createCollectionExpectSuccess();73 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');74 const [contract] = await deployTransferContract(api);75 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);76 await submitTransactionAsync(alice, changeAdminTx);7778 const tokenBefore: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();79 80 // Transfer81 const transferTx = contract.tx.transfer(value, gasLimit, bob.address, collectionId, tokenId, 1);82 const events = await submitTransactionAsync(alice, transferTx);83 const result = getGenericResult(events);84 const tokenAfter: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();8586 // tslint:disable-next-line:no-unused-expression87 expect(result.success).to.be.true;88 expect(tokenBefore.Owner).to.be.deep.equal(normalizeAccountId(alice.address));89 expect(tokenAfter.Owner).to.be.deep.equal(normalizeAccountId(bob.address));90 });91 });9293 it('Mint CE', async () => {94 await usingApi(async api => {95 const alice = privateKey('//Alice');96 const bob = privateKey('//Bob');9798 const collectionId = await createCollectionExpectSuccess();99 const [contract] = await deployTransferContract(api);100 await enablePublicMintingExpectSuccess(alice, collectionId);101 await enableWhiteListExpectSuccess(alice, collectionId);102 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);103 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);104105 const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, { Nft: {const_data: '0x010203', variable_data: '0x020304' }});106 const events = await submitTransactionAsync(alice, transferTx);107 const result = getGenericResult(events);108 expect(result.success).to.be.true;109110 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any).map((kv: any) => kv[1].toJSON());111 expect(tokensAfter).to.be.deep.equal([112 {113 Owner: bob.address,114 ConstData: '0x010203',115 VariableData: '0x020304',116 },117 ]);118 });119 });120121 it('Bulk mint CE', async () => {122 await usingApi(async api => {123 const alice = privateKey('//Alice');124 const bob = privateKey('//Bob');125126 const collectionId = await createCollectionExpectSuccess();127 const [contract] = await deployTransferContract(api);128 await enablePublicMintingExpectSuccess(alice, collectionId);129 await enableWhiteListExpectSuccess(alice, collectionId);130 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);131 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);132133 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [134 { Nft: { const_data: '0x010203', variable_data: '0x020304' } },135 { Nft: { const_data: '0x010204', variable_data: '0x020305' } },136 { Nft: { const_data: '0x010205', variable_data: '0x020306' } },137 ]);138 const events = await submitTransactionAsync(alice, transferTx);139 const result = getGenericResult(events);140 expect(result.success).to.be.true;141142 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any)143 .map((kv: any) => kv[1].toJSON())144 .sort((a: any, b: any) => a.ConstData.localeCompare(b.ConstData));145 expect(tokensAfter).to.be.deep.equal([146 {147 Owner: bob.address,148 ConstData: '0x010203',149 VariableData: '0x020304',150 },151 {152 Owner: bob.address,153 ConstData: '0x010204',154 VariableData: '0x020305',155 },156 {157 Owner: bob.address,158 ConstData: '0x010205',159 VariableData: '0x020306',160 },161 ]);162 });163 });164165 it('Approve CE', async () => {166 await usingApi(async api => {167 const alice = privateKey('//Alice');168 const bob = privateKey('//Bob');169 const charlie = privateKey('//Charlie');170171 const collectionId = await createCollectionExpectSuccess();172 const [contract] = await deployTransferContract(api);173 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());174175 const transferTx = contract.tx.approve(value, gasLimit, bob.address, collectionId, tokenId, 1);176 const events = await submitTransactionAsync(alice, transferTx);177 const result = getGenericResult(events);178 expect(result.success).to.be.true;179180 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');181 });182 });183184 it('TransferFrom CE', async () => {185 await usingApi(async api => {186 const alice = privateKey('//Alice');187 const bob = privateKey('//Bob');188 const charlie = privateKey('//Charlie');189190 const collectionId = await createCollectionExpectSuccess();191 const [contract] = await deployTransferContract(api);192 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);193 await approveExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), 1);194195 const transferTx = contract.tx.transferFrom(value, gasLimit, bob.address, charlie.address, collectionId, tokenId, 1);196 const events = await submitTransactionAsync(alice, transferTx);197 const result = getGenericResult(events);198 expect(result.success).to.be.true;199200 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();201 expect(token.Owner.toString()).to.be.equal(charlie.address);202 });203 });204205 it('SetVariableMetaData CE', async () => {206 await usingApi(async api => {207 const alice = privateKey('//Alice');208209 const collectionId = await createCollectionExpectSuccess();210 const [contract] = await deployTransferContract(api);211 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());212213 const transferTx = contract.tx.setVariableMetaData(value, gasLimit, collectionId, tokenId, '0x121314');214 const events = await submitTransactionAsync(alice, transferTx);215 const result = getGenericResult(events);216 expect(result.success).to.be.true;217218 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();219 expect(token.VariableData.toString()).to.be.equal('0x121314');220 });221 });222223 it('ToggleWhiteList CE', async () => {224 await usingApi(async api => {225 const alice = privateKey('//Alice');226 const bob = privateKey('//Bob');227228 const collectionId = await createCollectionExpectSuccess();229 const [contract] = await deployTransferContract(api);230 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);231 await submitTransactionAsync(alice, changeAdminTx); 232233 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;234235 {236 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, true);237 const events = await submitTransactionAsync(alice, transferTx);238 const result = getGenericResult(events);239 expect(result.success).to.be.true;240241 expect(await isWhitelisted(collectionId, bob.address)).to.be.true;242 }243 {244 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, false);245 const events = await submitTransactionAsync(alice, transferTx);246 const result = getGenericResult(events);247 expect(result.success).to.be.true;248249 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;250 }251 });252 });253});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import usingApi, { submitTransactionAsync } from './substrate/substrate-api';9import fs from 'fs';10import { Abi, ContractPromise as Contract } from '@polkadot/api-contract';11import privateKey from './substrate/privateKey';12import {13 deployFlipper,14 getFlipValue,15 deployTransferContract,16} from './util/contracthelpers';1718import {19 addToWhiteListExpectSuccess,20 approveExpectSuccess,21 createCollectionExpectSuccess,22 createItemExpectSuccess,23 enablePublicMintingExpectSuccess,24 enableWhiteListExpectSuccess,25 getGenericResult,26 normalizeAccountId,27 isWhitelisted,28 transferFromExpectSuccess,29} from './util/helpers';303132chai.use(chaiAsPromised);33const expect = chai.expect;3435const value = 0;36const gasLimit = 9000n * 1000000n;37const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';3839describe.skip('Contracts', () => {40 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {41 await usingApi(async api => {42 const [contract, deployer] = await deployFlipper(api);43 const initialGetResponse = await getFlipValue(contract, deployer);4445 const bob = privateKey('//Bob');46 const flip = contract.tx.flip(value, gasLimit);47 await submitTransactionAsync(bob, flip);4849 const afterFlipGetResponse = await getFlipValue(contract, deployer);50 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');51 });52 });5354 it('Can initialize contract instance', async () => {55 await usingApi(async (api) => {56 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));57 const abi = new Abi(metadata);58 const newContractInstance = new Contract(api, abi, marketContractAddress);59 expect(newContractInstance).to.have.property('address');60 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);61 });62 });63});6465describe.skip('Chain extensions', () => {66 it('Transfer CE', async () => {67 await usingApi(async api => {68 const alice = privateKey('//Alice');69 const bob = privateKey('//Bob');7071 // Prep work72 const collectionId = await createCollectionExpectSuccess();73 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');74 const [contract] = await deployTransferContract(api);75 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);76 await submitTransactionAsync(alice, changeAdminTx);7778 const tokenBefore: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();79 80 // Transfer81 const transferTx = contract.tx.transfer(value, gasLimit, bob.address, collectionId, tokenId, 1);82 const events = await submitTransactionAsync(alice, transferTx);83 const result = getGenericResult(events);84 const tokenAfter: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();8586 // tslint:disable-next-line:no-unused-expression87 expect(result.success).to.be.true;88 expect(tokenBefore.Owner).to.be.deep.equal(normalizeAccountId(alice.address));89 expect(tokenAfter.Owner).to.be.deep.equal(normalizeAccountId(bob.address));90 });91 });9293 it('Mint CE', async () => {94 await usingApi(async api => {95 const alice = privateKey('//Alice');96 const bob = privateKey('//Bob');9798 const collectionId = await createCollectionExpectSuccess();99 const [contract] = await deployTransferContract(api);100 await enablePublicMintingExpectSuccess(alice, collectionId);101 await enableWhiteListExpectSuccess(alice, collectionId);102 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);103 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);104105 const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, { Nft: {const_data: '0x010203', variable_data: '0x020304' }});106 const events = await submitTransactionAsync(alice, transferTx);107 const result = getGenericResult(events);108 expect(result.success).to.be.true;109110 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any).map((kv: any) => kv[1].toJSON());111 expect(tokensAfter).to.be.deep.equal([112 {113 Owner: bob.address,114 ConstData: '0x010203',115 VariableData: '0x020304',116 },117 ]);118 });119 });120121 it('Bulk mint CE', async () => {122 await usingApi(async api => {123 const alice = privateKey('//Alice');124 const bob = privateKey('//Bob');125126 const collectionId = await createCollectionExpectSuccess();127 const [contract] = await deployTransferContract(api);128 await enablePublicMintingExpectSuccess(alice, collectionId);129 await enableWhiteListExpectSuccess(alice, collectionId);130 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);131 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);132133 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [134 { Nft: { const_data: '0x010203', variable_data: '0x020304' } },135 { Nft: { const_data: '0x010204', variable_data: '0x020305' } },136 { Nft: { const_data: '0x010205', variable_data: '0x020306' } },137 ]);138 const events = await submitTransactionAsync(alice, transferTx);139 const result = getGenericResult(events);140 expect(result.success).to.be.true;141142 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any)143 .map((kv: any) => kv[1].toJSON())144 .sort((a: any, b: any) => a.ConstData.localeCompare(b.ConstData));145 expect(tokensAfter).to.be.deep.equal([146 {147 Owner: bob.address,148 ConstData: '0x010203',149 VariableData: '0x020304',150 },151 {152 Owner: bob.address,153 ConstData: '0x010204',154 VariableData: '0x020305',155 },156 {157 Owner: bob.address,158 ConstData: '0x010205',159 VariableData: '0x020306',160 },161 ]);162 });163 });164165 it('Approve CE', async () => {166 await usingApi(async api => {167 const alice = privateKey('//Alice');168 const bob = privateKey('//Bob');169 const charlie = privateKey('//Charlie');170171 const collectionId = await createCollectionExpectSuccess();172 const [contract] = await deployTransferContract(api);173 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());174175 const transferTx = contract.tx.approve(value, gasLimit, bob.address, collectionId, tokenId, 1);176 const events = await submitTransactionAsync(alice, transferTx);177 const result = getGenericResult(events);178 expect(result.success).to.be.true;179180 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');181 });182 });183184 it('TransferFrom CE', async () => {185 await usingApi(async api => {186 const alice = privateKey('//Alice');187 const bob = privateKey('//Bob');188 const charlie = privateKey('//Charlie');189190 const collectionId = await createCollectionExpectSuccess();191 const [contract] = await deployTransferContract(api);192 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);193 await approveExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), 1);194195 const transferTx = contract.tx.transferFrom(value, gasLimit, bob.address, charlie.address, collectionId, tokenId, 1);196 const events = await submitTransactionAsync(alice, transferTx);197 const result = getGenericResult(events);198 expect(result.success).to.be.true;199200 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();201 expect(token.Owner.toString()).to.be.equal(charlie.address);202 });203 });204205 it('SetVariableMetaData CE', async () => {206 await usingApi(async api => {207 const alice = privateKey('//Alice');208209 const collectionId = await createCollectionExpectSuccess();210 const [contract] = await deployTransferContract(api);211 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());212213 const transferTx = contract.tx.setVariableMetaData(value, gasLimit, collectionId, tokenId, '0x121314');214 const events = await submitTransactionAsync(alice, transferTx);215 const result = getGenericResult(events);216 expect(result.success).to.be.true;217218 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();219 expect(token.VariableData.toString()).to.be.equal('0x121314');220 });221 });222223 it('ToggleWhiteList CE', async () => {224 await usingApi(async api => {225 const alice = privateKey('//Alice');226 const bob = privateKey('//Bob');227228 const collectionId = await createCollectionExpectSuccess();229 const [contract] = await deployTransferContract(api);230 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);231 await submitTransactionAsync(alice, changeAdminTx); 232233 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;234235 {236 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, true);237 const events = await submitTransactionAsync(alice, transferTx);238 const result = getGenericResult(events);239 expect(result.success).to.be.true;240241 expect(await isWhitelisted(collectionId, bob.address)).to.be.true;242 }243 {244 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, false);245 const events = await submitTransactionAsync(alice, transferTx);246 const result = getGenericResult(events);247 expect(result.success).to.be.true;248249 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;250 }251 });252 });253});tests/src/overflow.test.tsdiffbeforeafterboth--- a/tests/src/overflow.test.ts
+++ b/tests/src/overflow.test.ts
@@ -8,7 +8,7 @@
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
-import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getFungibleBalance, transferExpectFail, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX } from './util/helpers';
+import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getFungibleBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX } from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -33,7 +33,7 @@
await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');
await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: 1n });
- await transferExpectFail(fungibleCollectionId, 0, alice, bob, 1, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);
expect(await getFungibleBalance(fungibleCollectionId, alice.address)).to.equal(1n);
expect(await getFungibleBalance(fungibleCollectionId, bob.address)).to.equal(U128_MAX);
tests/src/scheduler.test.tsdiffbeforeafterboth--- a/tests/src/scheduler.test.ts
+++ b/tests/src/scheduler.test.ts
@@ -28,7 +28,7 @@
await setCollectionSponsorExpectSuccess(nftCollectionId, Alice.address);
await confirmSponsorshipExpectSuccess(nftCollectionId);
- await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');
+ await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
});
});
});
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -16,7 +16,7 @@
findUnusedAddress,
getCreateCollectionResult,
getCreateItemResult,
- transferExpectFail,
+ transferExpectFailure,
transferExpectSuccess,
} from './util/helpers';
@@ -103,13 +103,13 @@
await usingApi(async (api) => {
// nft
const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFail(nftCollectionCount + 1, 1, Alice, Bob, 1);
+ await transferExpectFailure(nftCollectionCount + 1, 1, Alice, Bob, 1);
// fungible
const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob, 1);
+ await transferExpectFailure(fungibleCollectionCount + 1, 1, Alice, Bob, 1);
// reFungible
const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);
+ await transferExpectFailure(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);
});
});
it('Transfer with deleted collection_id', async () => {
@@ -117,43 +117,41 @@
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
await destroyCollectionExpectSuccess(nftCollectionId);
- await transferExpectFail(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');
+ await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
await destroyCollectionExpectSuccess(fungibleCollectionId);
- await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await destroyCollectionExpectSuccess(reFungibleCollectionId);
- await transferExpectFail(
+ await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
Alice,
Bob,
1,
- 'ReFungible',
);
});
it('Transfer with not existed item_id', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await transferExpectFail(nftCollectionId, 2, Alice, Bob, 1, 'NFT');
+ await transferExpectFailure(nftCollectionId, 2, Alice, Bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await transferExpectFail(fungibleCollectionId, 2, Alice, Bob, 1, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, 2, Alice, Bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- await transferExpectFail(
+ await transferExpectFailure(
reFungibleCollectionId,
2,
Alice,
Bob,
1,
- 'ReFungible',
);
});
it('Transfer with deleted item_id', async () => {
@@ -161,46 +159,44 @@
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
- await transferExpectFail(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');
+ await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);
- await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
- await transferExpectFail(
+ await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
Alice,
Bob,
1,
- 'ReFungible',
);
});
it('Transfer with recipient that is not owner', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await transferExpectFail(nftCollectionId, newNftTokenId, Charlie, Bob, 1, 'NFT');
+ await transferExpectFailure(nftCollectionId, newNftTokenId, Charlie, Bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await transferExpectFail(
+ await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
Charlie,
Bob,
1,
- 'ReFungible',
);
});
});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -543,9 +543,9 @@
});
}
-export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string) {
+export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value: boolean = true) {
await usingApi(async (api) => {
- const tx = api.tx.nft.toggleContractWhiteList(contractAddress, true);
+ const tx = api.tx.nft.toggleContractWhiteList(contractAddress, value);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
@@ -820,7 +820,7 @@
}
export async function
-transferExpectFail(
+transferExpectFailure(
collectionId: number,
tokenId: number,
sender: IKeyringPair,