git.delta.rocks / unique-network / refs/commits / 3eee5dcd05c9

difftreelog

Merge pull request #301 from UniqueNetwork/feature/CORE-215

kozyrevdev2022-03-29parents: #e9ee75b #9299221.patch.diff
in: master
CORE-215 Fix helpers: check same sender and recepient

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
763 type = 'NFT',764 type = 'NFT',
764) {765) {
765 await usingApi(async (api: ApiPromise) => {766 await usingApi(async (api: ApiPromise) => {
767 const from = normalizeAccountId(accountFrom);
766 const to = normalizeAccountId(accountTo);768 const to = normalizeAccountId(accountTo);
767 let balanceBefore = 0n;769 let balanceBefore = 0n;
768 if (type === 'Fungible') {770 if (type === 'Fungible') {
778 }780 }
779 if (type === 'Fungible') {781 if (type === 'Fungible') {
780 const balanceAfter = await getBalance(api, collectionId, to, tokenId);782 const balanceAfter = await getBalance(api, collectionId, to, tokenId);
783 if (JSON.stringify(to) !== JSON.stringify(from)) {
781 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));784 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));
785 } else {
786 expect(balanceAfter).to.be.equal(balanceBefore);
787 }
782 }788 }
783 if (type === 'ReFungible') {789 if (type === 'ReFungible') {
784 expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(BigInt(value));790 expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(BigInt(value));
877 type = 'NFT',883 type = 'NFT',
878) {884) {
879 await usingApi(async (api: ApiPromise) => {885 await usingApi(async (api: ApiPromise) => {
886 const from = normalizeAccountId(sender);
880 const to = normalizeAccountId(recipient);887 const to = normalizeAccountId(recipient);
881888
882 let balanceBefore = 0n;889 let balanceBefore = 0n;
898 }905 }
899 if (type === 'Fungible') {906 if (type === 'Fungible') {
900 const balanceAfter = await getBalance(api, collectionId, to, tokenId);907 const balanceAfter = await getBalance(api, collectionId, to, tokenId);
908 if (JSON.stringify(to) !== JSON.stringify(from)) {
901 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));909 expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));
910 } else {
911 expect(balanceAfter).to.be.equal(balanceBefore);
912 }
902 }913 }
903 if (type === 'ReFungible') {914 if (type === 'ReFungible') {
904 expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true;915 expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true;