difftreelog
Combine call tests
in: master
7 files changed
tests/src/eth/collections/callMethodsERC20.test.tsdiffbeforeafterbothno changes
tests/src/eth/collections/callMethodsERC721.test.tsdiffbeforeafterbothno changes
tests/src/eth/fungible.test.tsdiffbeforeafterboth17import {expect, itEth, usingEthPlaygrounds} from './util';17import {expect, itEth, usingEthPlaygrounds} from './util';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';1920describe('Fungible: Information getting', () => {21 let donor: IKeyringPair;22 let alice: IKeyringPair;2324 before(async function() {25 await usingEthPlaygrounds(async (helper, privateKey) => {26 donor = await privateKey({filename: __filename});27 [alice] = await helper.arrange.createAccounts([20n], donor);28 });29 });3031 itEth('totalSupply', async ({helper}) => {32 const caller = await helper.eth.createAccountWithBalance(donor);33 const collection = await helper.ft.mintCollection(alice);34 await collection.mint(alice, 200n);3536 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);37 const totalSupply = await contract.methods.totalSupply().call();38 expect(totalSupply).to.equal('200');39 });4041 itEth('balanceOf', async ({helper}) => {42 const caller = await helper.eth.createAccountWithBalance(donor);43 const collection = await helper.ft.mintCollection(alice);44 await collection.mint(alice, 200n, {Ethereum: caller});4546 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);47 const balance = await contract.methods.balanceOf(caller).call();48 expect(balance).to.equal('200');49 });50});511952describe('Fungible: Plain calls', () => {20describe('Fungible: Plain calls', () => {53 let donor: IKeyringPair;21 let donor: IKeyringPair;tests/src/eth/nonFungible.test.tsdiffbeforeafterboth20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';212223describe('NFT: Information getting', () => {24 let donor: IKeyringPair;25 let alice: IKeyringPair;2627 before(async function() {28 await usingEthPlaygrounds(async (helper, privateKey) => {29 donor = await privateKey({filename: __filename});30 [alice] = await helper.arrange.createAccounts([10n], donor);31 });32 });3334 itEth('totalSupply', async ({helper}) => {35 const collection = await helper.nft.mintCollection(alice, {});36 await collection.mintToken(alice);3738 const caller = await helper.eth.createAccountWithBalance(donor);3940 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);41 const totalSupply = await contract.methods.totalSupply().call();4243 expect(totalSupply).to.equal('1');44 });4546 itEth('balanceOf', async ({helper}) => {47 const collection = await helper.nft.mintCollection(alice, {});48 const caller = await helper.eth.createAccountWithBalance(donor);4950 await collection.mintToken(alice, {Ethereum: caller});51 await collection.mintToken(alice, {Ethereum: caller});52 await collection.mintToken(alice, {Ethereum: caller});5354 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);55 const balance = await contract.methods.balanceOf(caller).call();5657 expect(balance).to.equal('3');58 });5960 itEth('ownerOf', async ({helper}) => {61 const collection = await helper.nft.mintCollection(alice, {});62 const caller = await helper.eth.createAccountWithBalance(donor);6364 const token = await collection.mintToken(alice, {Ethereum: caller});6566 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);6768 const owner = await contract.methods.ownerOf(token.tokenId).call();6970 expect(owner).to.equal(caller);71 });7273 itEth('name/symbol is available regardless of ERC721Metadata support', async ({helper}) => {74 const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});75 const caller = helper.eth.createAccount();7677 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);7879 expect(await contract.methods.name().call()).to.equal('test');80 expect(await contract.methods.symbol().call()).to.equal('TEST');81 });82});832184describe('Check ERC721 token URI for NFT', () => {22describe('Check ERC721 token URI for NFT', () => {85 let donor: IKeyringPair;23 let donor: IKeyringPair;tests/src/eth/reFungible.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';20import {ITokenPropertyPermission} from '../util/playgrounds/types';2122describe('Refungible: Information getting', () => {23 let donor: IKeyringPair;2425 before(async function() {26 await usingEthPlaygrounds(async (helper, privateKey) => {27 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);2829 donor = await privateKey({filename: __filename});30 });31 });3233 itEth('totalSupply', async ({helper}) => {34 const caller = await helper.eth.createAccountWithBalance(donor);35 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');36 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);3738 await contract.methods.mint(caller).send();3940 const totalSupply = await contract.methods.totalSupply().call();41 expect(totalSupply).to.equal('1');42 });4344 itEth('balanceOf', async ({helper}) => {45 const caller = await helper.eth.createAccountWithBalance(donor);46 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');47 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);4849 await contract.methods.mint(caller).send();50 await contract.methods.mint(caller).send();51 await contract.methods.mint(caller).send();5253 const balance = await contract.methods.balanceOf(caller).call();54 expect(balance).to.equal('3');55 });5657 itEth('ownerOf', async ({helper}) => {58 const caller = await helper.eth.createAccountWithBalance(donor);59 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');60 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);6162 const result = await contract.methods.mint(caller).send();63 const tokenId = result.events.Transfer.returnValues.tokenId;6465 const owner = await contract.methods.ownerOf(tokenId).call();66 expect(owner).to.equal(caller);67 });6869 itEth('ownerOf after burn', async ({helper}) => {70 const caller = await helper.eth.createAccountWithBalance(donor);71 const receiver = helper.eth.createAccount();72 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');73 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);7475 const result = await contract.methods.mint(caller).send();76 const tokenId = result.events.Transfer.returnValues.tokenId;77 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);7879 await tokenContract.methods.repartition(2).send();80 await tokenContract.methods.transfer(receiver, 1).send();8182 await tokenContract.methods.burnFrom(caller, 1).send();8384 const owner = await contract.methods.ownerOf(tokenId).call();85 expect(owner).to.equal(receiver);86 });8788 itEth('ownerOf for partial ownership', async ({helper}) => {89 const caller = await helper.eth.createAccountWithBalance(donor);90 const receiver = helper.eth.createAccount();91 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');92 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);9394 const result = await contract.methods.mint(caller).send();95 const tokenId = result.events.Transfer.returnValues.tokenId;96 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);9798 await tokenContract.methods.repartition(2).send();99 await tokenContract.methods.transfer(receiver, 1).send();100101 const owner = await contract.methods.ownerOf(tokenId).call();102 expect(owner).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF');103 });104});10521106describe('Refungible: Plain calls', () => {22describe('Refungible: Plain calls', () => {107 let donor: IKeyringPair;23 let donor: IKeyringPair;tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth20import {Contract} from 'web3-eth-contract';20import {Contract} from 'web3-eth-contract';212223describe('Refungible token: Information getting', () => {24 let donor: IKeyringPair;25 let alice: IKeyringPair;2627 before(async function() {28 await usingEthPlaygrounds(async (helper, privateKey) => {29 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);3031 donor = await privateKey({filename: __filename});32 [alice] = await helper.arrange.createAccounts([20n], donor);33 });34 });3536 itEth('totalSupply', async ({helper}) => {37 const caller = await helper.eth.createAccountWithBalance(donor);38 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});39 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});4041 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);42 const totalSupply = await contract.methods.totalSupply().call();43 expect(totalSupply).to.equal('200');44 });4546 itEth('balanceOf', async ({helper}) => {47 const caller = await helper.eth.createAccountWithBalance(donor);48 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});49 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});5051 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);52 const balance = await contract.methods.balanceOf(caller).call();53 expect(balance).to.equal('200');54 });5556 itEth('decimals', async ({helper}) => {57 const caller = await helper.eth.createAccountWithBalance(donor);58 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});59 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});6061 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);62 const decimals = await contract.methods.decimals().call();63 expect(decimals).to.equal('0');64 });65});662167// FIXME: Need erc721 for ReFubgible.22// FIXME: Need erc721 for ReFubgible.68describe('Check ERC721 token URI for ReFungible', () => {23describe('Check ERC721 token URI for ReFungible', () => {tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth255 }255 }256 }256 }257257258 async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {258 async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18, mergeDeprecated = false): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[], collection: Contract }> {259 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();259 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();260 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);260 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);261 const functionName: string = this.createCollectionMethodName(mode);261 const functionName: string = this.createCollectionMethodName(mode);266 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);266 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);267 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);267 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);268 const events = this.helper.eth.normalizeEvents(result.events);268 const events = this.helper.eth.normalizeEvents(result.events);269 const collection = await this.helper.ethNativeContract.collectionById(collectionId, mode, signer, mergeDeprecated);269270270 return {collectionId, collectionAddress, events};271 return {collectionId, collectionAddress, events, collection};271 }272 }272273273 createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {274 createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {