Best JavaScript code snippet using fast-check-monorepo
Fixed.test.ts
Source:Fixed.test.ts
...917 expect(await caller.muluDivu(bn(0), bn(0), bn(1))).to.equal(bn(0))918 })919 it('muluDivu(,,FLOOR) works for many values', async () => {920 await fc.assert(921 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {922 if (z == 0n) return923 const expected: bigint = (x * y) / z924 if (UINTMIN <= expected && expected <= UINTMAX) {925 expect(await caller.muluDivu(bn(x), bn(y), bn(z))).to.equal(bn(expected))926 expect(await caller.muluDivuRnd(bn(x), bn(y), bn(z), FLOOR)).to.equal(bn(expected))927 } else {928 await expect(caller.muluDivu(bn(x), bn(y), bn(z))).to.be.reverted929 await expect(caller.muluDivuRnd(bn(x), bn(y), bn(z), FLOOR)).to.be.reverted930 }931 })932 )933 })934 it('muluDivu(,,CEIL) works for many values', async () => {935 await fc.assert(936 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {937 if (z == 0n) return938 const expected: bigint = ceilDiv(x * y, z)939 if (UINTMIN <= expected && expected <= UINTMAX) {940 expect(await caller.muluDivuRnd(bn(x), bn(y), bn(z), CEIL)).to.equal(bn(expected))941 } else {942 await expect(caller.muluDivuRnd(bn(x), bn(y), bn(z), CEIL)).to.be.reverted943 }944 })945 )946 })947 it('muluDivu(,,ROUND) works for many values', async () => {948 await fc.assert(949 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {950 if (z == 0n) return951 const expected: bigint = roundDiv(x * y, z)952 if (UINTMIN <= expected && expected <= UINTMAX) {953 expect(await caller.muluDivuRnd(bn(x), bn(y), bn(z), ROUND)).to.equal(bn(expected))954 } else {955 await expect(caller.muluDivuRnd(bn(x), bn(y), bn(z), ROUND)).to.be.reverted956 }957 })958 )959 })960 })961 describe('mulDiv + mulDivRnd', () => {962 it('mulDiv(0,0,*,*) = 0.0)', async () => {963 expect(await caller.mulDivRnd(bn(0), bn(0), fp(1), FLOOR)).to.equal(bn(0))964 expect(await caller.mulDivRnd(bn(0), bn(0), fp(1), CEIL)).to.equal(bn(0))965 expect(await caller.mulDivRnd(bn(0), bn(0), fp(1), ROUND)).to.equal(bn(0))966 expect(await caller.mulDiv(bn(0), bn(0), fp(1))).to.equal(bn(0))967 expect(await caller.mulDivRnd(bn(0), bn(0), bn(1), FLOOR)).to.equal(bn(0))968 expect(await caller.mulDivRnd(bn(0), bn(0), bn(1), CEIL)).to.equal(bn(0))969 expect(await caller.mulDivRnd(bn(0), bn(0), bn(1), ROUND)).to.equal(bn(0))970 expect(await caller.mulDiv(bn(0), bn(0), bn(1))).to.equal(bn(0))971 })972 it('mulDiv(,,FLOOR) works for many values', async () => {973 await fc.assert(974 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(192), fc.bigUintN(192), async (x, y, z) => {975 if (z == 0n) return976 const expected: bigint = (x * y) / z977 if (UINTMIN <= expected && expected <= UINTMAX) {978 expect(await caller.mulDiv(bn(x), bn(y), bn(z))).to.equal(bn(expected))979 expect(await caller.mulDivRnd(bn(x), bn(y), bn(z), FLOOR)).to.equal(bn(expected))980 } else {981 await expect(caller.mulDiv(bn(x), bn(y), bn(z))).to.be.reverted982 await expect(caller.mulDivRnd(bn(x), bn(y), bn(z), FLOOR)).to.be.reverted983 }984 })985 )986 })987 it('mulDiv(,,CEIL) works for many values', async () => {988 await fc.assert(989 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(192), fc.bigUintN(192), async (x, y, z) => {990 if (z == 0n) return991 const expected: bigint = ceilDiv(x * y, z)992 if (UINTMIN <= expected && expected <= UINTMAX) {993 expect(await caller.mulDivRnd(bn(x), bn(y), bn(z), CEIL)).to.equal(bn(expected))994 } else {995 await expect(caller.mulDivRnd(bn(x), bn(y), bn(z), CEIL)).to.be.reverted996 }997 })998 )999 })1000 it('mulDiv(,,ROUND) works for many values', async () => {1001 await fc.assert(1002 fc.asyncProperty(fc.bigUintN(192), fc.bigUintN(192), fc.bigUintN(192), async (x, y, z) => {1003 if (z == 0n) return1004 const expected: bigint = roundDiv(x * y, z)1005 if (UINTMIN <= expected && expected <= UINTMAX) {1006 expect(await caller.mulDivRnd(bn(x), bn(y), bn(z), ROUND)).to.equal(bn(expected))1007 } else {1008 await expect(caller.mulDivRnd(bn(x), bn(y), bn(z), ROUND)).to.be.reverted1009 }1010 })1011 )1012 })1013 })1014 describe('mulDiv256 + mulDiv256Rnd', () => {1015 it('mulDiv256(0,0,1,*) = 0', async () => {1016 expect(await caller.mulDiv256Rnd_(bn(0), bn(0), bn(1), FLOOR)).to.equal(bn(0))1017 expect(await caller.mulDiv256Rnd_(bn(0), bn(0), bn(1), ROUND)).to.equal(bn(0))1018 expect(await caller.mulDiv256Rnd_(bn(0), bn(0), bn(1), CEIL)).to.equal(bn(0))1019 expect(await caller.mulDiv256_(bn(0), bn(0), bn(1))).to.equal(bn(0))1020 })1021 it('mulDiv256(,,FLOOR) works for many values', async () => {1022 await fc.assert(1023 fc.asyncProperty(fc.bigUintN(256), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {1024 if (z == 0n) return1025 const expected: bigint = (x * y) / z1026 if (expected < WORD) {1027 expect(await caller.mulDiv256_(bn(x), bn(y), bn(z))).to.equal(bn(expected))1028 expect(await caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), FLOOR)).to.equal(bn(expected))1029 } else {1030 await expect(caller.mulDiv256_(bn(x), bn(y), bn(z))).to.be.reverted1031 await expect(caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), FLOOR)).to.be.reverted1032 }1033 })1034 )1035 })1036 it('mulDiv256(,,CEIL) works for many values', async () => {1037 await fc.assert(1038 fc.asyncProperty(fc.bigUintN(256), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {1039 if (z == 0n) return1040 const expected: bigint = ceilDiv(x * y, z)1041 if (expected < WORD) {1042 expect(await caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), CEIL)).to.equal(bn(expected))1043 } else {1044 await expect(caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), CEIL)).to.be.reverted1045 }1046 })1047 )1048 })1049 it('mulDiv256(,,ROUND) works for many values', async () => {1050 await fc.assert(1051 fc.asyncProperty(fc.bigUintN(256), fc.bigUintN(256), fc.bigUintN(256), async (x, y, z) => {1052 if (z == 0n) return1053 const expected: bigint = roundDiv(x * y, z)1054 if (expected < WORD) {1055 expect(await caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), ROUND)).to.equal(bn(expected))1056 } else {1057 await expect(caller.mulDiv256Rnd_(bn(x), bn(y), bn(z), ROUND)).to.be.reverted1058 }1059 })1060 )1061 })1062 })1063 describe('fullMul', () => {1064 it(`works for many values`, async () => {1065 await fc.assert(1066 fc.asyncProperty(fc.bigUintN(256), fc.bigUintN(256), async (x, y) => {1067 const loExpected = (x * y) % WORD1068 const hiExpected = (x * y) / WORD1069 const [hiResult, loResult] = await caller.fullMul_(BigNumber.from(x), BigNumber.from(y))1070 expect(hiResult).to.equal(hiExpected)1071 expect(loResult).to.equal(loExpected)1072 }),1073 {1074 examples: [1075 [0n, 0n],1076 [0n, 1n],1077 [1n, WORD - 1n],1078 [WORD - 1n, WORD - 1n],1079 ],1080 }...
AddLiquidityGivenDebt.spec.ts
Source:AddLiquidityGivenDebt.spec.ts
...65// fc66// .record({67// newLiquidityParams: fc68// .record({69// assetIn: fc.bigUintN(112),70// debtIn: fc.bigUintN(112),71// collateralIn: fc.bigUintN(112),72// })73// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),74// addLiquidityParams: fc.record({75// assetIn: fc.bigUintN(112),76// minLiquidity: fc.bigUintN(256),77// maxDebt: fc.bigUintN(112),78// maxCollateral: fc.bigUintN(112),79// }),80// })81// .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)).noShrink(),82// async (data) => {83// const success = async () => {84// const constructor = await loadFixture(fixture)85// await setTime(Number(currentTime + 5000n))86// const newLiquidity = await newLiquidityFixture(constructor, signers[0], data.newLiquidityParams)87// await setTime(Number(currentTime + 10000n))88// const addLiquidity = await liquidityGivenAssetFixture(newLiquidity, signers[0], data.addLiquidityParams)89// return addLiquidity90// }91// await addLiquidityProperties(data, currentTime, success, assetToken.address, collateralToken.address)92// }93// ),94// { skipAllAfterTimeLimit: 50000, numRuns: 10 }95// )96// }).timeout(100000)97// it('Failed', async () => {98// const { maturity, assetToken, collateralToken } = await loadFixture(fixture)99// let currentTime = await now()100// await fc.assert(101// fc.asyncProperty(102// fc103// .record({104// newLiquidityParams: fc105// .record({106// assetIn: fc.bigUintN(112),107// debtIn: fc.bigUintN(112),108// collateralIn: fc.bigUintN(112),109// })110// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),111// addLiquidityParams: fc.record({112// assetIn: fc.bigUintN(112),113// minLiquidity: fc.bigUintN(256),114// maxDebt: fc.bigUintN(112),115// maxCollateral: fc.bigUintN(112),116// }),117// })118// .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))119// .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),120// async ({ data, error }) => {121// const constructor = await loadFixture(fixture)122// await setTime(Number(currentTime + 5000n))123// await newLiquidityFixture(constructor, signers[0], data.newLiquidityParams)124// await setTime(Number(currentTime + 10000n))125// await expect(126// constructor.convenience.convenienceContract.liquidityGivenAsset({127// asset: assetToken.address,128// collateral: collateralToken.address,129// maturity,130// liquidityTo: signers[0].address,131// dueTo: signers[0].address,132// assetIn: data.addLiquidityParams.assetIn,133// minLiquidity: data.addLiquidityParams.minLiquidity,134// maxDebt: data.addLiquidityParams.maxDebt,135// maxCollateral: data.addLiquidityParams.maxCollateral,136// deadline: maturity,137// })138// ).to.be.revertedWith(error)139// }140// ),141// { skipAllAfterTimeLimit: 50000, numRuns: 10 }142// )143// }).timeout(100000)144// })145// describe('Add Liquidity ETH Asset', () => {146// it('Succeeded', async () => {147// const { maturity, convenience, collateralToken } = await loadFixture(fixture)148// let currentTime = await now()149// await fc.assert(150// fc.asyncProperty(151// fc152// .record({153// newLiquidityParams: fc154// .record({155// assetIn: fc.bigUintN(112),156// debtIn: fc.bigUintN(112),157// collateralIn: fc.bigUintN(112),158// })159// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),160// addLiquidityParams: fc.record({161// assetIn: fc.bigUintN(112),162// minLiquidity: fc.bigUintN(256),163// maxDebt: fc.bigUintN(112),164// maxCollateral: fc.bigUintN(112),165// }),166// })167// .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),168// async (data) => {169// const success = async () => {170// const constructor = await loadFixture(fixture)171// await setTime(Number(currentTime + 5000n))172// const newLiquidity = await newLiquidityETHAssetFixture(constructor, signers[0], data.newLiquidityParams)173// await setTime(Number(currentTime + 10000n))174// const addLiquidity = await liquidityGivenAssetETHAssetFixture(newLiquidity, signers[0], data.addLiquidityParams)175// return addLiquidity176// }177// await addLiquidityProperties(178// data,179// currentTime,180// success,181// convenience.wethContract.address,182// collateralToken.address183// )184// }185// ),186// { skipAllAfterTimeLimit: 50000, numRuns: 10 }187// )188// }).timeout(100000)189// it('Failed', async () => {190// const { maturity, collateralToken } = await loadFixture(fixture)191// let currentTime = await now()192// await fc.assert(193// fc.asyncProperty(194// fc195// .record({196// newLiquidityParams: fc197// .record({198// assetIn: fc.bigUintN(112),199// debtIn: fc.bigUintN(112),200// collateralIn: fc.bigUintN(112),201// })202// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),203// addLiquidityParams: fc.record({204// assetIn: fc.bigUintN(112),205// minLiquidity: fc.bigUintN(256),206// maxDebt: fc.bigUintN(112),207// maxCollateral: fc.bigUintN(112),208// }),209// })210// .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))211// .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),212// async ({ data, error }) => {213// const constructor = await loadFixture(fixture)214// await setTime(Number(currentTime + 5000n))215// await newLiquidityETHAssetFixture(constructor, signers[0], data.newLiquidityParams)216// await setTime(Number(currentTime + 10000n))217// await expect(218// constructor.convenience.convenienceContract.liquidityGivenAssetETHAsset(219// {220// collateral: collateralToken.address,221// maturity,222// liquidityTo: signers[0].address,223// dueTo: signers[0].address,224// minLiquidity: data.addLiquidityParams.minLiquidity,225// maxDebt: data.addLiquidityParams.maxDebt,226// maxCollateral: data.addLiquidityParams.maxCollateral,227// deadline: maturity,228// },229// { value: data.addLiquidityParams.assetIn }230// )231// ).to.be.revertedWith(error)232// }233// ),234// { skipAllAfterTimeLimit: 50000, numRuns: 10 }235// )236// }).timeout(100000)237// })238// describe('Add Liquidity ETH Collateral', () => {239// it('Succeeded', async () => {240// const { maturity, assetToken, convenience } = await loadFixture(fixture)241// let currentTime = await now()242// await fc.assert(243// fc.asyncProperty(244// fc245// .record({246// newLiquidityParams: fc247// .record({248// assetIn: fc.bigUintN(112),249// debtIn: fc.bigUintN(112),250// collateralIn: fc.bigUintN(112),251// })252// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),253// addLiquidityParams: fc.record({254// assetIn: fc.bigUintN(112),255// minLiquidity: fc.bigUintN(256),256// maxDebt: fc.bigUintN(112),257// maxCollateral: fc.bigUintN(112),258// }),259// })260// .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),261// async (data) => {262// const success = async () => {263// const constructor = await loadFixture(fixture)264// await setTime(Number(currentTime + 5000n))265// const newLiquidity = await newLiquidityETHCollateralFixture(266// constructor,267// signers[0],268// data.newLiquidityParams269// )270// await setTime(Number(currentTime + 10000n))271// const addLiquidity = await liquidityGivenAssetETHCollateralFixture(272// newLiquidity,273// signers[0],274// data.addLiquidityParams275// )276// return addLiquidity277// }278// await addLiquidityProperties(data, currentTime, success, assetToken.address, convenience.wethContract.address)279// }280// ),281// { skipAllAfterTimeLimit: 50000, numRuns: 10 }282// )283// }).timeout(100000)284// it('Failed', async () => {285// const { maturity, assetToken } = await loadFixture(fixture)286// let currentTime = await now()287// await fc.assert(288// fc.asyncProperty(289// fc290// .record({291// newLiquidityParams: fc292// .record({293// assetIn: fc.bigUintN(112),294// debtIn: fc.bigUintN(112),295// collateralIn: fc.bigUintN(112),296// })297// .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),298// addLiquidityParams: fc.record({299// assetIn: fc.bigUintN(112),300// minLiquidity: fc.bigUintN(256),301// maxDebt: fc.bigUintN(112),302// maxCollateral: fc.bigUintN(112),303// }),304// })305// .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))306// .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity))307// .noShrink(),308// async ({ data, error }) => {309// const constructor = await loadFixture(fixture)310// await setTime(Number(currentTime + 5000n))311// await newLiquidityETHCollateralFixture(constructor, signers[0], data.newLiquidityParams)312// await setTime(Number(currentTime + 10000n))313// await expect(314// constructor.convenience.convenienceContract.liquidityGivenAssetETHCollateral(315// {316// asset: assetToken.address,...
AddLiquidity.spec.ts
Source:AddLiquidity.spec.ts
...37 fc38 .record({39 newLiquidityParams: fc40 .record({41 assetIn: fc.bigUintN(112),42 debtIn: fc.bigUintN(112),43 collateralIn: fc.bigUintN(112),44 })45 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),46 addLiquidityParams: fc.record({47 assetIn: fc.bigUintN(112),48 minLiquidity: fc.bigUintN(256),49 maxDebt: fc.bigUintN(112),50 maxCollateral: fc.bigUintN(112),51 }),52 })53 .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)).noShrink(),54 async (data) => {55 const success = async () => {56 const constructor = await loadFixture(fixture)57 await setTime(Number(currentTime + 5000n))58 const newLiquidity = await newLiquidityFixture(constructor, signers[0], data.newLiquidityParams)59 await setTime(Number(currentTime + 10000n))60 const addLiquidity = await liquidityGivenAssetFixture(newLiquidity, signers[0], data.addLiquidityParams)61 return addLiquidity62 }63 await addLiquidityProperties(data, currentTime, success, assetToken.address, collateralToken.address)64 }65 ),66 { skipAllAfterTimeLimit: 50000, numRuns: 10 }67 )68 }).timeout(100000)69 it('Failed', async () => {70 const { maturity, assetToken, collateralToken } = await loadFixture(fixture)71 let currentTime = await now()72 await fc.assert(73 fc.asyncProperty(74 fc75 .record({76 newLiquidityParams: fc77 .record({78 assetIn: fc.bigUintN(112),79 debtIn: fc.bigUintN(112),80 collateralIn: fc.bigUintN(112),81 })82 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),83 addLiquidityParams: fc.record({84 assetIn: fc.bigUintN(112),85 minLiquidity: fc.bigUintN(256),86 maxDebt: fc.bigUintN(112),87 maxCollateral: fc.bigUintN(112),88 }),89 })90 .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))91 .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),92 async ({ data, error }) => {93 const constructor = await loadFixture(fixture)94 await setTime(Number(currentTime + 5000n))95 await newLiquidityFixture(constructor, signers[0], data.newLiquidityParams)96 await setTime(Number(currentTime + 10000n))97 await expect(98 constructor.convenience.convenienceContract.liquidityGivenAsset({99 asset: assetToken.address,100 collateral: collateralToken.address,101 maturity,102 liquidityTo: signers[0].address,103 dueTo: signers[0].address,104 assetIn: data.addLiquidityParams.assetIn,105 minLiquidity: data.addLiquidityParams.minLiquidity,106 maxDebt: data.addLiquidityParams.maxDebt,107 maxCollateral: data.addLiquidityParams.maxCollateral,108 deadline: maturity,109 })110 ).to.be.revertedWith(error)111 }112 ),113 { skipAllAfterTimeLimit: 50000, numRuns: 10 }114 )115 }).timeout(100000)116})117describe('Add Liquidity ETH Asset', () => {118 it('Succeeded', async () => {119 const { maturity, convenience, collateralToken } = await loadFixture(fixture)120 let currentTime = await now()121 await fc.assert(122 fc.asyncProperty(123 fc124 .record({125 newLiquidityParams: fc126 .record({127 assetIn: fc.bigUintN(112),128 debtIn: fc.bigUintN(112),129 collateralIn: fc.bigUintN(112),130 })131 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),132 addLiquidityParams: fc.record({133 assetIn: fc.bigUintN(112),134 minLiquidity: fc.bigUintN(256),135 maxDebt: fc.bigUintN(112),136 maxCollateral: fc.bigUintN(112),137 }),138 })139 .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),140 async (data) => {141 const success = async () => {142 const constructor = await loadFixture(fixture)143 await setTime(Number(currentTime + 5000n))144 const newLiquidity = await newLiquidityETHAssetFixture(constructor, signers[0], data.newLiquidityParams)145 await setTime(Number(currentTime + 10000n))146 const addLiquidity = await liquidityGivenAssetETHAssetFixture(newLiquidity, signers[0], data.addLiquidityParams)147 return addLiquidity148 }149 await addLiquidityProperties(150 data,151 currentTime,152 success,153 convenience.wethContract.address,154 collateralToken.address155 )156 }157 ),158 { skipAllAfterTimeLimit: 50000, numRuns: 10 }159 )160 }).timeout(100000)161 it('Failed', async () => {162 const { maturity, collateralToken } = await loadFixture(fixture)163 let currentTime = await now()164 await fc.assert(165 fc.asyncProperty(166 fc167 .record({168 newLiquidityParams: fc169 .record({170 assetIn: fc.bigUintN(112),171 debtIn: fc.bigUintN(112),172 collateralIn: fc.bigUintN(112),173 })174 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),175 addLiquidityParams: fc.record({176 assetIn: fc.bigUintN(112),177 minLiquidity: fc.bigUintN(256),178 maxDebt: fc.bigUintN(112),179 maxCollateral: fc.bigUintN(112),180 }),181 })182 .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))183 .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),184 async ({ data, error }) => {185 const constructor = await loadFixture(fixture)186 await setTime(Number(currentTime + 5000n))187 await newLiquidityETHAssetFixture(constructor, signers[0], data.newLiquidityParams)188 await setTime(Number(currentTime + 10000n))189 await expect(190 constructor.convenience.convenienceContract.liquidityGivenAssetETHAsset(191 {192 collateral: collateralToken.address,193 maturity,194 liquidityTo: signers[0].address,195 dueTo: signers[0].address,196 minLiquidity: data.addLiquidityParams.minLiquidity,197 maxDebt: data.addLiquidityParams.maxDebt,198 maxCollateral: data.addLiquidityParams.maxCollateral,199 deadline: maturity,200 },201 { value: data.addLiquidityParams.assetIn }202 )203 ).to.be.revertedWith(error)204 }205 ),206 { skipAllAfterTimeLimit: 50000, numRuns: 10 }207 )208 }).timeout(100000)209})210describe('Add Liquidity ETH Collateral', () => {211 it('Succeeded', async () => {212 const { maturity, assetToken, convenience } = await loadFixture(fixture)213 let currentTime = await now()214 await fc.assert(215 fc.asyncProperty(216 fc217 .record({218 newLiquidityParams: fc219 .record({220 assetIn: fc.bigUintN(112),221 debtIn: fc.bigUintN(112),222 collateralIn: fc.bigUintN(112),223 })224 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),225 addLiquidityParams: fc.record({226 assetIn: fc.bigUintN(112),227 minLiquidity: fc.bigUintN(256),228 maxDebt: fc.bigUintN(112),229 maxCollateral: fc.bigUintN(112),230 }),231 })232 .filter((x) => LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity)),233 async (data) => {234 const success = async () => {235 const constructor = await loadFixture(fixture)236 await setTime(Number(currentTime + 5000n))237 const newLiquidity = await newLiquidityETHCollateralFixture(238 constructor,239 signers[0],240 data.newLiquidityParams241 )242 await setTime(Number(currentTime + 10000n))243 const addLiquidity = await liquidityGivenAssetETHCollateralFixture(244 newLiquidity,245 signers[0],246 data.addLiquidityParams247 )248 return addLiquidity249 }250 await addLiquidityProperties(data, currentTime, success, assetToken.address, convenience.wethContract.address)251 }252 ),253 { skipAllAfterTimeLimit: 50000, numRuns: 10 }254 )255 }).timeout(100000)256 it('Failed', async () => {257 const { maturity, assetToken } = await loadFixture(fixture)258 let currentTime = await now()259 await fc.assert(260 fc.asyncProperty(261 fc262 .record({263 newLiquidityParams: fc264 .record({265 assetIn: fc.bigUintN(112),266 debtIn: fc.bigUintN(112),267 collateralIn: fc.bigUintN(112),268 })269 .filter((x) => LiquidityFilter.newLiquiditySuccess(x, currentTime + 5_000n, maturity)),270 addLiquidityParams: fc.record({271 assetIn: fc.bigUintN(112),272 minLiquidity: fc.bigUintN(256),273 maxDebt: fc.bigUintN(112),274 maxCollateral: fc.bigUintN(112),275 }),276 })277 .filter((x) => !LiquidityFilter.addLiquiditySuccess(x, currentTime + 5_000n, currentTime + 10_000n, maturity))278 .map((x) => LiquidityFilter.addLiquidityError(x, currentTime + 5_000n, currentTime + 10_000n, maturity))279 .noShrink(),280 async ({ data, error }) => {281 const constructor = await loadFixture(fixture)282 await setTime(Number(currentTime + 5000n))283 await newLiquidityETHCollateralFixture(constructor, signers[0], data.newLiquidityParams)284 await setTime(Number(currentTime + 10000n))285 await expect(286 constructor.convenience.convenienceContract.liquidityGivenAssetETHCollateral(287 {288 asset: assetToken.address,...
Using AI Code Generation
1const fc = require("fast-check");2const bigUintN = require("big-uint64");3fc.assert(4 fc.property(fc.bigUintN(64), (a) => {5 const b = bigUintN(a);6 return b == a;7 })8);9const fc = require("fast-check");10const bigUintN = require("big-uint64");11fc.assert(12 fc.property(fc.bigUintN(64), (a) => {13 const b = bigUintN(a);14 return b == a;15 })16);17const fc = require("fast-check");18const bigUintN = require("big-uint64");19fc.assert(20 fc.property(fc.bigUintN(64), (a) => {21 const b = bigUintN(a);22 return b == a;23 })24);25const fc = require("fast-check");26const bigUintN = require("big-uint64");27fc.assert(28 fc.property(fc.bigUintN(64), (a) => {29 const b = bigUintN(a);30 return b == a;31 })32);33const fc = require("fast-check");34const bigUintN = require("big-uint64");35fc.assert(36 fc.property(fc.bigUintN(64), (a) => {37 const b = bigUintN(a);38 return b == a;39 })40);41const fc = require("fast-check");42const bigUintN = require("big-uint64");43fc.assert(44 fc.property(fc.bigUintN(64), (a) => {45 const b = bigUintN(a);46 return b == a;47 })48);49const fc = require("fast-check");50const bigUintN = require("big-uint64");51fc.assert(52 fc.property(fc.bigUintN
Using AI Code Generation
1const fc = require("fast-check");2const bigUintN = require("big-integer").bigUintN;3const test3 = () => {4 fc.assert(5 fc.property(fc.bigUintN(128), (x) => {6 return bigUintN(128, x).equals(x);7 })8 );9};10test3();11const fc = require("fast-check");12const bigUintN = require("big-integer").bigUintN;13const test4 = () => {14 fc.assert(15 fc.property(fc.bigUintN(128), (x) => {16 return bigUintN(128, x).equals(x);17 })18 );19};20test4();21const fc = require("fast-check");22const bigUintN = require("big-integer").bigUintN;23const test5 = () => {24 fc.assert(25 fc.property(fc.bigUintN(128), (x) => {26 return bigUintN(128, x).equals(x);27 })28 );29};30test5();31const fc = require("fast-check");32const bigUintN = require("big-integer").bigUintN;33const test6 = () => {34 fc.assert(35 fc.property(fc.bigUintN(128), (x) => {36 return bigUintN(128, x).equals(x);37 })38 );39};40test6();41const fc = require("fast-check");42const bigUintN = require("big-integer").bigUintN;43const test7 = () => {44 fc.assert(45 fc.property(fc.bigUintN(128), (x) => {46 return bigUintN(128, x).equals(x);47 })48 );49};50test7();51const fc = require("fast-check");52const bigUintN = require("big-integer").bigUintN;53const test8 = () => {54 fc.assert(55 fc.property(fc
Using AI Code Generation
1const fc = require('fast-check');2const bigUintN = require('fast-check/lib/types/biguintn.js');3fc.assert(4 fc.property(fc.bigUintN(64), (a) => {5 console.log(a);6 return true;7 }),8);9const fc = require('fast-check');10const bigUintN = require('fast-check/lib/types/biguintn.js');11fc.assert(12 fc.property(fc.bigUintN(64), (a) => {13 console.log(a);14 return true;15 }),16);17const fc = require('fast-check');18const bigUintN = require('fast-check/lib/types/biguintn.js');19fc.assert(20 fc.property(fc.bigUintN(64), (a) => {21 console.log(a);22 return true;23 }),24);25const fc = require('fast-check');26const bigUintN = require('fast-check/lib/types/biguintn.js');27fc.assert(28 fc.property(fc.bigUintN(64), (a) => {29 console.log(a);30 return true;31 }),32);33const fc = require('fast-check');34const bigUintN = require('fast-check/lib/types/biguintn.js');35fc.assert(36 fc.property(fc.bigUintN(64), (a) => {37 console.log(a);38 return true;39 }),40);41const fc = require('fast-check');42const bigUintN = require('fast-check/lib/types/biguintn.js');43fc.assert(44 fc.property(fc.bigUintN(64), (a) => {45 console.log(a);46 return true;47 }),48);49const fc = require('fast-check');50const bigUintN = require('fast-check/lib/types/biguintn.js');51fc.assert(52 fc.property(fc.bigUintN(64), (a) => {
Using AI Code Generation
1import { bigUintN } from 'fast-check';2const value = bigUintN(128, 0);3console.log(value);4import { bigUintN } from 'fast-check';5const value = bigUintN(128, 0);6console.log(value);7import { bigUintN } from 'fast-check';8const value = bigUintN(128, 0);9console.log(value);10import { bigUintN } from 'fast-check';11const value = bigUintN(128, 0);12console.log(value);13import { bigUintN } from 'fast-check';14const value = bigUintN(128, 0);15console.log(value);16import { bigUintN } from 'fast-check';17const value = bigUintN(128, 0);18console.log(value);19import { bigUintN } from 'fast-check';20const value = bigUintN(128, 0);21console.log(value);22import { bigUintN } from 'fast-check';23const value = bigUintN(128, 0);24console.log(value);25import { bigUintN } from 'fast-check';26const value = bigUintN(128, 0);27console.log(value);28import { bigUintN } from 'fast-check';29const value = bigUintN(128, 0);30console.log(value);31import { bigUintN } from '
Using AI Code Generation
1const fc = require('fast-check');2const bigUintN = require('big-uint-n');3const bigInt = require('big-integer');4const { bigUintNArbitrary } = require('fast-check-monorepo');5const bigUintNArb = bigUintNArbitrary(bigUintN);6fc.assert(fc.property(bigUintNArb, (x) => x >= 0n));7fc.assert(fc.property(bigUintNArb, (x) => x < 2n**64n));8fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() >= 0));9fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() < 2**64));10fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() === Number(x)));11fc.assert(fc.property(bigUintNArb, (x) => Number(x) === Number(x.toString())));12fc.assert(fc.property(bigUintNArb, (x) => x.toString() === x.toString(10)));13fc.assert(fc.property(bigUintNArb, (x) => x.toString(16) === x.toString(16)));14fc.assert(fc.property(bigUintNArb, (x) => x.toString(36) === x.toString(36)));15const fc = require('fast-check');16const bigUintN = require('big-uint-n');17const bigInt = require('big-integer');18const { bigUintNArbitrary } = require('fast-check-monorepo');19const bigUintNArb = bigUintNArbitrary(bigUintN);20fc.assert(fc.property(bigUintNArb, (x) => x >= 0n));21fc.assert(fc.property(bigUintNArb, (x) => x < 2n**64n));22fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() >= 0));23fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() < 2**64));24fc.assert(fc.property(bigUintNArb, (x) => bigInt(x).toJSNumber() === Number(x)));25fc.assert(fc.property(bigUintNArb
Using AI Code Generation
1const fc = require('fast-check');2const bigUintN = require('big-integer').bigUintN;3const { toBigIntLE, fromBigIntLE } = require('bigint-buffer');4const { Buffer } = require('buffer');5const { performance } = require('perf_hooks');6fc.assert(7 fc.property(fc.bigUintN(32), (x) => {8 const start = performance.now();9 const b = toBigIntLE(Buffer.from(x.toString(16), 'hex'));10 const end = performance.now();11 console.log('toBigIntLE took: ' + (end - start));12 const start2 = performance.now();13 const c = fromBigIntLE(b, 4);14 const end2 = performance.now();15 console.log('fromBigIntLE took: ' + (end2 - start2));16 const start3 = performance.now();17 const d = bigUintN(32, b);18 const end3 = performance.now();19 console.log('bigUintN took: ' + (end3 - start3));20 return c.toString('hex') === x.toString(16) && d.toString(16) === x.toString(16);21 })22);23const fc = require('fast-check');24const bigUintN = require('big-integer').bigUintN;25const { toBigIntLE, fromBigIntLE } = require('bigint-buffer');26const { Buffer } = require('buffer');27const { performance } = require('perf_hooks');28fc.assert(29 fc.property(fc.bigUintN(32), (x) => {30 const start = performance.now();31 const b = toBigIntLE(Buffer.from(x.toString(16), 'hex'));32 const end = performance.now();33 console.log('toBigIntLE took: ' + (end - start));34 const start2 = performance.now();35 const c = fromBigIntLE(b, 4);36 const end2 = performance.now();37 console.log('fromBigIntLE took: ' + (end2 - start2));38 const start3 = performance.now();39 const d = bigUintN(32, b);40 const end3 = performance.now();41 console.log('bigUintN took: ' + (end3 - start3));42 return c.toString('hex') === x.toString(16) && d.toString(16
Using AI Code Generation
1const fc = require('fast-check');2const bigUintN = fc.bigUintN;3const bigUintNGenerator = bigUintN(64);4const bigUintNArbitrary = bigUintNGenerator();5const bigUintNShrinkable = bigUintNArbitrary.generate(fc.random());6console.log(bigUintNShrinkable.value);7const fc = require('fast-check');8const bigUintN = fc.bigUintN;9const bigUintNGenerator = bigUintN(64);10const bigUintNArbitrary = bigUintNGenerator();11const bigUintNShrinkable = bigUintNArbitrary.generate(fc.random());12console.log(bigUintNShrinkable.value);13const fc = require('fast-check');14const bigUintN = fc.bigUintN;15const bigUintNGenerator = bigUintN(64);16const bigUintNArbitrary = bigUintNGenerator();17const bigUintNShrinkable = bigUintNArbitrary.generate(fc.random());18console.log(bigUintNShrinkable.value);19const fc = require('fast-check');20const bigUintN = fc.bigUintN;21const bigUintNGenerator = bigUintN(64);22const bigUintNArbitrary = bigUintNGenerator();23const bigUintNShrinkable = bigUintNArbitrary.generate(fc.random());24console.log(bigUintNShrinkable.value);25const fc = require('fast-check');26const bigUintN = fc.bigUintN;27const bigUintNGenerator = bigUintN(64);28const bigUintNArbitrary = bigUintNGenerator();29const bigUintNShrinkable = bigUintNArbitrary.generate(fc.random());30console.log(bigUintNShrinkable.value);
Using AI Code Generation
1const fc = require("fast-check");2const bigUintN = fc.bigUintN;3const fcBigInt = fc.bigInt();4const fcUintN = fc.uint8();5fc.assert(fc.property(fcUintN, fcBigInt, (x, y) => {6 const bigN = bigUintN(x, y);7 return bigN.toString() === y.toString() && bigN < 2n ** BigInt(x);8}));9const fc = require("fast-check");10const bigUintN = fc.bigUintN;11const fcBigInt = fc.bigInt();12const fcUintN = fc.uint8();13fc.assert(fc.property(fcUintN, fcBigInt, (x, y) => {14 const bigN = bigUintN(x, y);15 return bigN.toString() === y.toString() && bigN < 2n ** BigInt(x);16}));17const fc = require("fast-check");18const bigUintN = fc.bigUintN;19const fcBigInt = fc.bigInt();20const fcUintN = fc.uint8();21fc.assert(fc.property(fcUintN, fcBigInt, (x, y) => {22 const bigN = bigUintN(x, y);23 return bigN.toString() === y.toString() && bigN < 2n ** BigInt(x);24}));25const fc = require("fast-check");26const bigUintN = fc.bigUintN;27const fcBigInt = fc.bigInt();28const fcUintN = fc.uint8();29fc.assert(fc.property(fcUintN, fcBigInt, (x, y) => {30 const bigN = bigUintN(x, y);31 return bigN.toString() === y.toString() && bigN < 2n ** BigInt(x);32}));33const fc = require("fast-check");34const bigUintN = fc.bigUintN;35const fcBigInt = fc.bigInt();36const fcUintN = fc.uint8();37fc.assert(fc.property(fcUintN, fcBigInt, (x, y) => {38 const bigN = bigUintN(x
Using AI Code Generation
1const fc = require('fast-check');2const bigIntN = require('big-integer');3console.log(typeof(bigIntN.bigUintN));4console.log(typeof(bigIntN.bigUintN(10, 10n)));5console.log(typeof(bigIntN.bigUintN(10, 10)));6console.log(typeof(bigIntN.bigUintN(10, "10")));7console.log(typeof(bigIntN.bigUintN(10, "10.0")));8console.log(typeof(bigIntN.bigUintN(10, "10.1")));9console.log(typeof(bigIntN.bigUintN(10, "10.1e1")));10console.log(typeof(bigIntN.bigUintN(10, "10.1e-1")));11console.log(typeof(bigIntN.bigUintN(10, "10.1e100")));12console.log(typeof(bigIntN.bigUintN(10, "10.1e-100")));13console.log(typeof(bigIntN.bigUintN(10, "10.1e100")));
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!