difftreelog
test add tests
in: master
2 files changed
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Contract} from 'web3-eth-contract';19import {Contract} from 'web3-eth-contract';20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import { CREATE_COLLECTION_DATA_DEFAULTS, CollectionMode, CreateCollectionData, TokenPermissionField } from './util/playgrounds/types';212222describe('Check ERC721 token URI for NFT', () => {23describe('Check ERC721 token URI for NFT', () => {23 let donor: IKeyringPair;24 let donor: IKeyringPair;197 }198 }198 });199 });200201 itEth('Can perform mintBulkCross()', async ({helper}) => {202 const caller = await helper.eth.createAccountWithBalance(donor);203 const callerCross = helper.ethCrossAccount.fromAddress(caller);204 const receiver = helper.eth.createAccount();205 const receiverCross = helper.ethCrossAccount.fromAddress(receiver);206207 const permissions = [208 {code: TokenPermissionField.Mutable, value: true},209 {code: TokenPermissionField.TokenOwner, value: true},210 {code: TokenPermissionField.CollectionAdmin, value: true},211 ];212 const {collectionAddress} = await helper.eth.createCollection(213 caller,214 {215 ...CREATE_COLLECTION_DATA_DEFAULTS,216 name: 'A',217 description: 'B',218 tokenPrefix: 'C',219 collectionMode: 'rft',220 adminList: [callerCross],221 tokenPropertyPermissions: [222 {key: 'key_0_0', permissions},223 {key: 'key_1_0', permissions},224 {key: 'key_1_1', permissions},225 {key: 'key_2_0', permissions},226 {key: 'key_2_1', permissions},227 {key: 'key_2_2', permissions},228 ],229 },230 ).send();231232 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);233 {234 const nextTokenId = await contract.methods.nextTokenId().call();235 expect(nextTokenId).to.be.equal('1');236 const result = await contract.methods.mintBulkCross([237 {238 owner: receiverCross,239 properties: [240 {key: 'key_0_0', value: Buffer.from('value_0_0')},241 ],242 },243 {244 owner: receiverCross,245 properties: [246 {key: 'key_1_0', value: Buffer.from('value_1_0')},247 {key: 'key_1_1', value: Buffer.from('value_1_1')},248 ],249 },250 {251 owner: receiverCross,252 properties: [253 {key: 'key_2_0', value: Buffer.from('value_2_0')},254 {key: 'key_2_1', value: Buffer.from('value_2_1')},255 {key: 'key_2_2', value: Buffer.from('value_2_2')},256 ],257 },258 ]).send({from: caller});259 const events = result.events.Transfer.sort((a: any, b: any) => +a.returnValues.tokenId - b.returnValues.tokenId);260 const bulkSize = 3;261 for(let i = 0; i < bulkSize; i++) {262 const event = events[i];263 expect(event.address).to.equal(collectionAddress);264 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');265 expect(event.returnValues.to).to.equal(receiver);266 expect(event.returnValues.tokenId).to.equal(`${+nextTokenId + i}`);267 }268269 const properties = [270 await contract.methods.properties(+nextTokenId, []).call(),271 await contract.methods.properties(+nextTokenId + 1, []).call(),272 await contract.methods.properties(+nextTokenId + 2, []).call(),273 ];274 expect(properties).to.be.deep.equal([275 [276 ['key_0_0', helper.getWeb3().utils.toHex('value_0_0')],277 ],278 [279 ['key_1_0', helper.getWeb3().utils.toHex('value_1_0')],280 ['key_1_1', helper.getWeb3().utils.toHex('value_1_1')],281 ],282 [283 ['key_2_0', helper.getWeb3().utils.toHex('value_2_0')],284 ['key_2_1', helper.getWeb3().utils.toHex('value_2_1')],285 ['key_2_2', helper.getWeb3().utils.toHex('value_2_2')],286 ],287 ]);288 }289 });199290200 itEth('Can perform burn()', async ({helper}) => {291 itEth('Can perform burn()', async ({helper}) => {201 const caller = await helper.eth.createAccountWithBalance(donor);292 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);