Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Smell: it is a bad practice to use the random number generator to produce test code #823

Open
TestSmell opened this issue Aug 11, 2022 · 1 comment

Comments

@TestSmell
Copy link

Hi!
We notice that the random number generator (RNG) is used to produce test code in your project.
For example, a random generator in the test method named ''testEmptyRandomWallet()'' in ''WalletTest.java''.

But generating random numbers in test code is not a good test practice.
Random number generation can create couplings between classes and timing artifacts because most random number generator classes are thread-safe and therefore introduce additional synchronization.
So, a potential problem is that a test that should fail due to incorrect synchronization in the class under test might pass because of synchronization in the RNG used in the test code.

In terms of solutions,

  1. you could use another simple random algorithm (e.g., https://pastebin.com/BTCa6Jqh) that was not synchronized;
  2. you could also generate a class that stored 10000 random numbers (or however many you need) beforehand and then handed them out without synchronization.
@YazNaz94
Copy link

Hello TestSmell,

Sorry I'm off topic, I see that you know your topic,I have a problem with my wallet.
I received a transaction in 2017 Same day and once confirmed there was a transaction with the same amount of btc received to another empty address. May I know if it's a bug? Do you have any ideas ?

Here is the address of my wallet: https://www.blockchain.com/btc/address/1FbDvS7nL9njJXSP796u9nW8mfcUZg8pHt

Here is the address of the wallet to which the transaction was made: https://www.blockchain.com/btc/address/1NcLMBfoet2QLRuuboFd6g7tm9jRsvKFF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants