photon-sdk / photon-lib

A high level library for building bitcoin wallets with react native
https://docs.photonsdk.org
MIT License
53 stars 12 forks source link

All test cases don't pass #33

Open BitcoinZavior opened 2 years ago

BitcoinZavior commented 2 years ago

All test cases don't pass.

To Replicate:

npm run npm run test or npm run test:integration and npm run test:unit results in the following:

Screenshot 2022-01-26 at 10 35 33

This is because of env file is not being read to provide the the mnemonics.

Screenshot 2022-01-26 at 10 36 36

Screenshot 2022-01-26 at 10 36 28

Screenshot 2022-01-26 at 10 36 22

Screenshot 2022-01-26 at 10 36 10

Issue and suggested Solution:

  1. To read the env variables from a .env file a dotenv dev dependency is required or an env variables file to be read via process.env.

Once this dev dependency is added it will need to configured in jest or in photon-lib/__tests__/setup.js

  1. Once env file is configured and available, following variables will be needed in the .env file:
MNEMONICS_COBO
MNEMONICS_COLDCARD
HD_MNEMONIC_BIP84
HD_MNEMONIC
FAULTY_ZPUB
HD_MNEMONIC_BIP49
HD_MNEMONIC_BIP49_MANY_TX
  1. Adding the above will ensure all env variables required for running test cases are available HOWEVER the test cases expect specific mnemonics, the test cases have been written to pass only with specific mnemonics for example HD_MNEMONIC_BIP49_MANY_TX should be a mnemonic with a 107 transactions and a total balance of 51432

There could be some other instances where specific values are required.

Also the hardcoded peers might need to be updated as well in case this is an issue.

If all the test cases were passing before then It would be great if someone who has worked on the project before can share a env file which works with the test cases.

BitcoinZavior commented 2 years ago

Step 1 and Step 2 done.

A lot more test cases now pass:

Screenshot 2022-01-28 at 17 48 13

Screenshot 2022-01-28 at 17 47 44

A lot of test cases fail because expected, address, xpub or specific info does not match the hardcoded data in test cases:

Screenshot 2022-01-28 at 17 47 50

The test cases failing are because the test cases expect specific mnemonics in the .env file. If the same info info is not provided in the .env file then test cases will need to be re written.

tanx commented 2 years ago

Hey. The tests that cover the wallet libraries were ported from BlueWallet. I don't have the env vars either. You will have to replace them with new seeds and addresses if you want the tests to pass.

BitcoinZavior commented 2 years ago

@tanx if we use new seeds in .env then we will need to update all the test cases with new addresses and other derived data isn't it? Or am I missing something?