difftreelog
Fix test and improve throwing errors
in: master
3 files changed
tests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth247 // unstake has no effect if no stakes at all247 // unstake has no effect if no stakes at all248 testCase.method === 'unstakeAll'248 testCase.method === 'unstakeAll'249 ? await helper.staking.unstakeAll(staker)249 ? await helper.staking.unstakeAll(staker)250 : await helper.staking.unstakePartial(staker, 100n * nominal);250 : await expect(helper.staking.unstakePartial(staker, 100n * nominal)).to.be.rejectedWith('Arithmetic: Underflow');251251252 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(0n);252 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(0n);253 expect(await helper.balance.getSubstrate(staker.address) / nominal).to.be.equal(999n); // TODO bigint closeTo helper253 expect(await helper.balance.getSubstrate(staker.address) / nominal).to.be.equal(999n); // TODO bigint closeTo helper262 await helper.staking.unstakeAll(staker);262 await helper.staking.unstakeAll(staker);263 } else {263 } else {264 await helper.staking.unstakePartial(staker, 100n * nominal);264 await helper.staking.unstakePartial(staker, 100n * nominal);265 await helper.staking.unstakePartial(staker, 100n * nominal);265 await expect(helper.staking.unstakePartial(staker, 100n * nominal)).to.be.rejectedWith('Arithmetic: Underflow');266 }266 }267267268 expect(await helper.staking.getStakesNumber({Substrate: staker.address})).to.eq(0);268 expect(await helper.staking.getStakesNumber({Substrate: staker.address})).to.eq(0);tests/src/util/playgrounds/types.tsdiffbeforeafterboth21 }[];21 }[];22 },22 },23 blockHash: string,23 blockHash: string,24 moduleError?: string;24 moduleError?: string | object;25}25}262627export interface ISubscribeBlockEventsData {27export interface ISubscribeBlockEventsData {tests/src/util/playgrounds/unique.tsdiffbeforeafterboth672 params,672 params,673 } as IUniqueHelperLog;673 } as IUniqueHelperLog;674675 let errorMessage = '';674676675 if(result.status !== this.transactionStatus.SUCCESS) {677 if(result.status !== this.transactionStatus.SUCCESS) {676 if (result.moduleError) log.moduleError = result.moduleError;678 if (result.moduleError) {679 errorMessage = typeof result.moduleError === 'string'680 ? result.moduleError681 : `${Object.keys(result.moduleError)[0]}: ${Object.values(result.moduleError)[0]}`;682 log.moduleError = errorMessage;683 }677 else if (result.result.dispatchError) log.dispatchError = result.result.dispatchError;684 else if (result.result.dispatchError) log.dispatchError = result.result.dispatchError;678 }685 }679 if(events.length > 0) log.events = events;686 if(events.length > 0) log.events = events;680687681 this.chainLog.push(log);688 this.chainLog.push(log);682689683 if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) {690 if(expectSuccess && result.status !== this.transactionStatus.SUCCESS) {684 if (result.moduleError) throw Error(`${result.moduleError}`);691 if (result.moduleError) throw Error(`${errorMessage}`);685 else if (result.result.dispatchError) throw Error(JSON.stringify(result.result.dispatchError));692 else if (result.result.dispatchError) throw Error(JSON.stringify(result.result.dispatchError));686 }693 }687 return result;694 return result;