git.delta.rocks / unique-network / refs/commits / 29c61bb4c50d

difftreelog

Fixed addCollectionAdmin.test.ts

Greg Zaitsev2021-07-13parent: #5b3615f.patch.diff
in: master

8 files changed

modifiedCargo.lockdiffbeforeafterboth
5847 "sp-std",5847 "sp-std",
5848]5848]
5849
5850[[package]]
5851name = "pallet-scheduler"
5852version = "3.0.0"
5853dependencies = [
5854 "frame-benchmarking",
5855 "frame-support",
5856 "frame-system",
5857 "log",
5858 "parity-scale-codec 2.1.3",
5859 "serde",
5860 "sp-core",
5861 "sp-io",
5862 "sp-runtime",
5863 "sp-std",
5864 "substrate-test-utils",
5865 "up-sponsorship",
5866]
58675849
5868[[package]]5850[[package]]
5869name = "pallet-scheduler"5851name = "pallet-scheduler"
5880 "sp-std",5862 "sp-std",
5881]5863]
5864
5865[[package]]
5866name = "pallet-scheduler"
5867version = "3.0.0"
5868dependencies = [
5869 "frame-benchmarking",
5870 "frame-support",
5871 "frame-system",
5872 "log",
5873 "parity-scale-codec 2.1.3",
5874 "serde",
5875 "sp-core",
5876 "sp-io",
5877 "sp-runtime",
5878 "sp-std",
5879 "substrate-test-utils",
5880 "up-sponsorship",
5881]
58825882
5883[[package]]5883[[package]]
5884name = "pallet-session"5884name = "pallet-session"
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
22 const bob = privateKey('//Bob');22 const bob = privateKey('//Bob');
2323
24 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();24 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
25 expect(collection.Owner).to.be.deep.eq(normalizeAccountId(alice.address));25 expect(collection.Owner).to.be.equal(alice.address);
2626
27 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));27 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
28 await submitTransactionAsync(alice, changeAdminTx);28 await submitTransactionAsync(alice, changeAdminTx);
40 const Charlie = privateKey('//CHARLIE');40 const Charlie = privateKey('//CHARLIE');
4141
42 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();42 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
43 expect(collection.Owner).to.be.deep.eq(normalizeAccountId(Alice.address));43 expect(collection.Owner).to.be.equal(Alice.address);
4444
45 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));45 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
46 await submitTransactionAsync(Alice, changeAdminTx);46 await submitTransactionAsync(Alice, changeAdminTx);
modifiedtests/src/config.tsdiffbeforeafterboth
6import process from 'process';6import process from 'process';
77
8const config = {8const config = {
9 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9844',9 substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944',
10};10};
1111
12export default config;12export default config;
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
36const gasLimit = 9000n * 1000000n;36const gasLimit = 9000n * 1000000n;
37const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';37const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';
3838
39describe('Contracts', () => {39describe.skip('Contracts', () => {
40 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {40 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {
41 await usingApi(async api => {41 await usingApi(async api => {
42 const [contract, deployer] = await deployFlipper(api);42 const [contract, deployer] = await deployFlipper(api);
62 });62 });
63});63});
6464
65describe.only('Chain extensions', () => {65describe.skip('Chain extensions', () => {
66 it('Transfer CE', async () => {66 it('Transfer CE', async () => {
67 await usingApi(async api => {67 await usingApi(async api => {
68 const alice = privateKey('//Alice');68 const alice = privateKey('//Alice');
modifiedtests/src/overflow.test.tsdiffbeforeafterboth
8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';
9import privateKey from './substrate/privateKey';9import privateKey from './substrate/privateKey';
10import usingApi from './substrate/substrate-api';10import usingApi from './substrate/substrate-api';
11import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getFungibleBalance, transferExpectFail, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX } from './util/helpers';11import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getFungibleBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX } from './util/helpers';
1212
13chai.use(chaiAsPromised);13chai.use(chaiAsPromised);
14const expect = chai.expect;14const expect = chai.expect;
33 await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');33 await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');
3434
35 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: 1n });35 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: 1n });
36 await transferExpectFail(fungibleCollectionId, 0, alice, bob, 1, 'Fungible');36 await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);
3737
38 expect(await getFungibleBalance(fungibleCollectionId, alice.address)).to.equal(1n);38 expect(await getFungibleBalance(fungibleCollectionId, alice.address)).to.equal(1n);
39 expect(await getFungibleBalance(fungibleCollectionId, bob.address)).to.equal(U128_MAX);39 expect(await getFungibleBalance(fungibleCollectionId, bob.address)).to.equal(U128_MAX);
modifiedtests/src/scheduler.test.tsdiffbeforeafterboth
28 await setCollectionSponsorExpectSuccess(nftCollectionId, Alice.address);28 await setCollectionSponsorExpectSuccess(nftCollectionId, Alice.address);
29 await confirmSponsorshipExpectSuccess(nftCollectionId);29 await confirmSponsorshipExpectSuccess(nftCollectionId);
3030
31 await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');31 await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
32 });32 });
33 });33 });
34});34});
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
16 findUnusedAddress,16 findUnusedAddress,
17 getCreateCollectionResult,17 getCreateCollectionResult,
18 getCreateItemResult,18 getCreateItemResult,
19 transferExpectFail,19 transferExpectFailure,
20 transferExpectSuccess,20 transferExpectSuccess,
21} from './util/helpers';21} from './util/helpers';
2222
103 await usingApi(async (api) => {103 await usingApi(async (api) => {
104 // nft104 // nft
105 const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;105 const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
106 await transferExpectFail(nftCollectionCount + 1, 1, Alice, Bob, 1);106 await transferExpectFailure(nftCollectionCount + 1, 1, Alice, Bob, 1);
107 // fungible107 // fungible
108 const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;108 const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
109 await transferExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob, 1);109 await transferExpectFailure(fungibleCollectionCount + 1, 1, Alice, Bob, 1);
110 // reFungible110 // reFungible
111 const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;111 const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
112 await transferExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);112 await transferExpectFailure(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);
113 });113 });
114 });114 });
115 it('Transfer with deleted collection_id', async () => {115 it('Transfer with deleted collection_id', async () => {
116 // nft116 // nft
117 const nftCollectionId = await createCollectionExpectSuccess();117 const nftCollectionId = await createCollectionExpectSuccess();
118 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');118 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
119 await destroyCollectionExpectSuccess(nftCollectionId);119 await destroyCollectionExpectSuccess(nftCollectionId);
120 await transferExpectFail(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');120 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
121 // fungible121 // fungible
122 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});122 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
123 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');123 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
124 await destroyCollectionExpectSuccess(fungibleCollectionId);124 await destroyCollectionExpectSuccess(fungibleCollectionId);
125 await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');125 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
126 // reFungible126 // reFungible
127 const reFungibleCollectionId = await127 const reFungibleCollectionId = await
128 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});128 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
129 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');129 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
130 await destroyCollectionExpectSuccess(reFungibleCollectionId);130 await destroyCollectionExpectSuccess(reFungibleCollectionId);
131 await transferExpectFail(131 await transferExpectFailure(
132 reFungibleCollectionId,132 reFungibleCollectionId,
133 newReFungibleTokenId,133 newReFungibleTokenId,
134 Alice,134 Alice,
135 Bob,135 Bob,
136 1,136 1,
137 'ReFungible',
138 );137 );
139 });138 });
140 it('Transfer with not existed item_id', async () => {139 it('Transfer with not existed item_id', async () => {
141 // nft140 // nft
142 const nftCollectionId = await createCollectionExpectSuccess();141 const nftCollectionId = await createCollectionExpectSuccess();
143 await transferExpectFail(nftCollectionId, 2, Alice, Bob, 1, 'NFT');142 await transferExpectFailure(nftCollectionId, 2, Alice, Bob, 1);
144 // fungible143 // fungible
145 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});144 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
146 await transferExpectFail(fungibleCollectionId, 2, Alice, Bob, 1, 'Fungible');145 await transferExpectFailure(fungibleCollectionId, 2, Alice, Bob, 1);
147 // reFungible146 // reFungible
148 const reFungibleCollectionId = await147 const reFungibleCollectionId = await
149 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});148 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
150 await transferExpectFail(149 await transferExpectFailure(
151 reFungibleCollectionId,150 reFungibleCollectionId,
152 2,151 2,
153 Alice,152 Alice,
154 Bob,153 Bob,
155 1,154 1,
156 'ReFungible',
157 );155 );
158 });156 });
159 it('Transfer with deleted item_id', async () => {157 it('Transfer with deleted item_id', async () => {
160 // nft158 // nft
161 const nftCollectionId = await createCollectionExpectSuccess();159 const nftCollectionId = await createCollectionExpectSuccess();
162 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');160 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
163 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);161 await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
164 await transferExpectFail(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');162 await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
165 // fungible163 // fungible
166 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});164 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
167 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');165 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
168 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);166 await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);
169 await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');167 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
170 // reFungible168 // reFungible
171 const reFungibleCollectionId = await169 const reFungibleCollectionId = await
172 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});170 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
173 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');171 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
174 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);172 await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
175 await transferExpectFail(173 await transferExpectFailure(
176 reFungibleCollectionId,174 reFungibleCollectionId,
177 newReFungibleTokenId,175 newReFungibleTokenId,
178 Alice,176 Alice,
179 Bob,177 Bob,
180 1,178 1,
181 'ReFungible',
182 );179 );
183 });180 });
184 it('Transfer with recipient that is not owner', async () => {181 it('Transfer with recipient that is not owner', async () => {
185 // nft182 // nft
186 const nftCollectionId = await createCollectionExpectSuccess();183 const nftCollectionId = await createCollectionExpectSuccess();
187 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');184 const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
188 await transferExpectFail(nftCollectionId, newNftTokenId, Charlie, Bob, 1, 'NFT');185 await transferExpectFailure(nftCollectionId, newNftTokenId, Charlie, Bob, 1);
189 // fungible186 // fungible
190 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});187 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
191 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');188 const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
192 await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1, 'Fungible');189 await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1);
193 // reFungible190 // reFungible
194 const reFungibleCollectionId = await191 const reFungibleCollectionId = await
195 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});192 createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
196 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');193 const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
197 await transferExpectFail(194 await transferExpectFailure(
198 reFungibleCollectionId,195 reFungibleCollectionId,
199 newReFungibleTokenId,196 newReFungibleTokenId,
200 Charlie,197 Charlie,
201 Bob,198 Bob,
202 1,199 1,
203 'ReFungible',
204 );200 );
205 });201 });
206});202});
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
543 });543 });
544}544}
545545
546export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string) {546export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value: boolean = true) {
547 await usingApi(async (api) => {547 await usingApi(async (api) => {
548 const tx = api.tx.nft.toggleContractWhiteList(contractAddress, true);548 const tx = api.tx.nft.toggleContractWhiteList(contractAddress, value);
549 const events = await submitTransactionAsync(sender, tx);549 const events = await submitTransactionAsync(sender, tx);
550 const result = getGenericResult(events);550 const result = getGenericResult(events);
551551
820}820}
821821
822export async function822export async function
823transferExpectFail(823transferExpectFailure(
824 collectionId: number,824 collectionId: number,
825 tokenId: number,825 tokenId: number,
826 sender: IKeyringPair,826 sender: IKeyringPair,