difftreelog
test add tests
in: master
2 files changed
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -18,6 +18,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import { CREATE_COLLECTION_DATA_DEFAULTS, CollectionMode, CreateCollectionData, TokenPermissionField } from './util/playgrounds/types';
describe('Check ERC721 token URI for NFT', () => {
let donor: IKeyringPair;
@@ -197,6 +198,96 @@
}
});
+ itEth('Can perform mintBulkCross()', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const callerCross = helper.ethCrossAccount.fromAddress(caller);
+ const receiver = helper.eth.createAccount();
+ const receiverCross = helper.ethCrossAccount.fromAddress(receiver);
+
+ const permissions = [
+ {code: TokenPermissionField.Mutable, value: true},
+ {code: TokenPermissionField.TokenOwner, value: true},
+ {code: TokenPermissionField.CollectionAdmin, value: true},
+ ];
+ const {collectionAddress} = await helper.eth.createCollection(
+ caller,
+ {
+ ...CREATE_COLLECTION_DATA_DEFAULTS,
+ name: 'A',
+ description: 'B',
+ tokenPrefix: 'C',
+ collectionMode: 'rft',
+ adminList: [callerCross],
+ tokenPropertyPermissions: [
+ {key: 'key_0_0', permissions},
+ {key: 'key_1_0', permissions},
+ {key: 'key_1_1', permissions},
+ {key: 'key_2_0', permissions},
+ {key: 'key_2_1', permissions},
+ {key: 'key_2_2', permissions},
+ ],
+ },
+ ).send();
+
+ const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);
+ {
+ const nextTokenId = await contract.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await contract.methods.mintBulkCross([
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_0_0', value: Buffer.from('value_0_0')},
+ ],
+ },
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_1_0', value: Buffer.from('value_1_0')},
+ {key: 'key_1_1', value: Buffer.from('value_1_1')},
+ ],
+ },
+ {
+ owner: receiverCross,
+ properties: [
+ {key: 'key_2_0', value: Buffer.from('value_2_0')},
+ {key: 'key_2_1', value: Buffer.from('value_2_1')},
+ {key: 'key_2_2', value: Buffer.from('value_2_2')},
+ ],
+ },
+ ]).send({from: caller});
+ const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);
+ const bulkSize = 3;
+ for(let i = 0; i < bulkSize; i++) {
+ const event = events[i];
+ expect(event.address).to.equal(collectionAddress);
+ expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.equal(receiver);
+ expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);
+ }
+
+ const properties = [
+ await contract.methods.properties(+nextTokenId, []).call(),
+ await contract.methods.properties(+nextTokenId + 1, []).call(),
+ await contract.methods.properties(+nextTokenId + 2, []).call(),
+ ];
+ expect(properties).to.be.deep.equal([
+ [
+ ['key_0_0', helper.getWeb3().utils.toHex('value_0_0')],
+ ],
+ [
+ ['key_1_0', helper.getWeb3().utils.toHex('value_1_0')],
+ ['key_1_1', helper.getWeb3().utils.toHex('value_1_1')],
+ ],
+ [
+ ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],
+ ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],
+ ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],
+ ],
+ ]);
+ }
+ });
+
itEth('Can perform burn()', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth18import {expect, itEth, usingEthPlaygrounds} from './util';18import {expect, itEth, usingEthPlaygrounds} from './util';19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import { CREATE_COLLECTION_DATA_DEFAULTS, TokenPermissionField } from './util/playgrounds/types';212222describe('Refungible: Plain calls', () => {23describe('Refungible: Plain calls', () => {23 let donor: IKeyringPair;24 let donor: IKeyringPair;125 }126 }126 });127 });128129 itEth('Can perform mintBulkCross()', async ({helper}) => {130 const caller = await helper.eth.createAccountWithBalance(donor);131 const callerCross = helper.ethCrossAccount.fromAddress(caller);132 const receiver = helper.eth.createAccount();133 const receiverCross = helper.ethCrossAccount.fromAddress(receiver);134135 const permissions = [136 {code: TokenPermissionField.Mutable, value: true},137 {code: TokenPermissionField.TokenOwner, value: true},138 {code: TokenPermissionField.CollectionAdmin, value: true},139 ];140 const {collectionAddress} = await helper.eth.createCollection(141 caller,142 {143 ...CREATE_COLLECTION_DATA_DEFAULTS,144 name: 'A',145 description: 'B',146 tokenPrefix: 'C',147 collectionMode: 'rft',148 adminList: [callerCross],149 tokenPropertyPermissions: [150 {key: 'key_0_0', permissions},151 {key: 'key_1_0', permissions},152 {key: 'key_1_1', permissions},153 {key: 'key_2_0', permissions},154 {key: 'key_2_1', permissions},155 {key: 'key_2_2', permissions},156 ],157 },158 ).send();159160 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);161 {162 const nextTokenId = await contract.methods.nextTokenId().call();163 expect(nextTokenId).to.be.equal('1');164 const result = await contract.methods.mintBulkCross([165 {166 owner: receiverCross,167 properties: [168 {key: 'key_0_0', value: Buffer.from('value_0_0')},169 ],170 },171 {172 owner: receiverCross,173 properties: [174 {key: 'key_1_0', value: Buffer.from('value_1_0')},175 {key: 'key_1_1', value: Buffer.from('value_1_1')},176 ],177 },178 {179 owner: receiverCross,180 properties: [181 {key: 'key_2_0', value: Buffer.from('value_2_0')},182 {key: 'key_2_1', value: Buffer.from('value_2_1')},183 {key: 'key_2_2', value: Buffer.from('value_2_2')},184 ],185 },186 ]).send({from: caller});187 const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);188 const bulkSize = 3;189 for(let i = 0; i < bulkSize; i++) {190 const event = events[i];191 expect(event.address).to.equal(collectionAddress);192 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');193 expect(event.returnValues.to).to.equal(receiver);194 expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);195 }196197 const properties = [198 await contract.methods.properties(+nextTokenId, []).call(),199 await contract.methods.properties(+nextTokenId + 1, []).call(),200 await contract.methods.properties(+nextTokenId + 2, []).call(),201 ];202 expect(properties).to.be.deep.equal([203 [204 ['key_0_0', helper.getWeb3().utils.toHex('value_0_0')],205 ],206 [207 ['key_1_0', helper.getWeb3().utils.toHex('value_1_0')],208 ['key_1_1', helper.getWeb3().utils.toHex('value_1_1')],209 ],210 [211 ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],212 ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],213 ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],214 ],215 ]);216 }217 });127218128 itEth('Can perform setApprovalForAll()', async ({helper}) => {219 itEth('Can perform setApprovalForAll()', async ({helper}) => {129 const owner = await helper.eth.createAccountWithBalance(donor);220 const owner = await helper.eth.createAccountWithBalance(donor);