1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';20import usingApi from '../substrate/substrate-api';21import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from '../deprecated-helpers/helpers';2223chai.use(chaiAsPromised);24const expect = chai.expect;252627describe.skip('Integration Test fungible overflows', () => {28 let alice: IKeyringPair;29 let bob: IKeyringPair;30 let charlie: IKeyringPair;3132 before(async () => {33 await usingApi(async (api, privateKeyWrapper) => {34 alice = privateKeyWrapper('//Alice');35 bob = privateKeyWrapper('//Bob');36 charlie = privateKeyWrapper('//Charlie');37 });38 });3940 it('fails when overflows on transfer', async () => {41 await usingApi(async api => {42 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});4344 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});45 await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');4647 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: 1n});48 await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);4950 expect(await getBalance(api, fungibleCollectionId, alice.address, 0)).to.equal(1n);51 expect(await getBalance(api, fungibleCollectionId, bob.address, 0)).to.equal(U128_MAX);52 });53 });5455 it('fails when overflows on transferFrom', async () => {56 await usingApi(async api => {57 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});58 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});59 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, U128_MAX);60 await transferFromExpectSuccess(fungibleCollectionId, 0, bob, alice, charlie, U128_MAX, 'Fungible');6162 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);63 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(0n);6465 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});66 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, 1n);67 await transferFromExpectFail(fungibleCollectionId, 0, bob, alice, charlie, 1);6869 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);70 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(1n);71 });72 });73});