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 './util/helpers';2223chai.use(chaiAsPromised);24const expect = chai.expect;2526describe.skip('Integration Test fungible overflows', () => {27 let alice: IKeyringPair;28 let bob: IKeyringPair;29 let charlie: IKeyringPair;3031 before(async () => {32 await usingApi(async (api, privateKeyWrapper) => {33 alice = privateKeyWrapper('//Alice');34 bob = privateKeyWrapper('//Bob');35 charlie = privateKeyWrapper('//Charlie');36 });37 });3839 it('fails when overflows on transfer', async () => {40 await usingApi(async api => {41 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});4243 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});44 await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');4546 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: 1n});47 await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);4849 expect(await getBalance(api, fungibleCollectionId, alice.address, 0)).to.equal(1n);50 expect(await getBalance(api, fungibleCollectionId, bob.address, 0)).to.equal(U128_MAX);51 });52 });5354 it('fails when overflows on transferFrom', async () => {55 await usingApi(async api => {56 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});57 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});58 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, U128_MAX);59 await transferFromExpectSuccess(fungibleCollectionId, 0, bob, alice, charlie, U128_MAX, 'Fungible');6061 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);62 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(0n);6364 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});65 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, 1n);66 await transferFromExpectFail(fungibleCollectionId, 0, bob, alice, charlie, 1);6768 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);69 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(1n);70 });71 });72});