ton-blockchain / stablecoin-contract

Sample code for centralised stablecoin jetton. TEP-74 and TEP-89 compatible
146 stars 43 forks source link

Potential problem with getRandomInt #41

Closed grannnsacker closed 8 months ago

grannnsacker commented 8 months ago

Hello, I want to apologize right away for my speech. English is not my native language. image (pict 1) Math.random() returns a number in the range [0;1). In the getRandomInt method, you round the resulting number using Math.round. With a sufficiently large number obtained from Math.random, getRandomInt can return a number equal to max. Example in JettonWallet.spec.ts (pict 2) image Proofs (pict 3) image

if I really helped in any way, my telegram @grannsacker

tolya-yanot commented 8 months ago

This is code of tests, not code of smart contract. Max value is also valid for tests