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

Write test cases for getting chain data #42

Open
HarleyAppleChoi opened this issue Aug 27, 2020 · 2 comments
Open

Write test cases for getting chain data #42

HarleyAppleChoi opened this issue Aug 27, 2020 · 2 comments

Comments

@HarleyAppleChoi
Copy link
Contributor

Feature description

There should be some function on test cases in the cosmos SDK which we can do test cases on a dummy chain maybe?

@HarleyAppleChoi
Copy link
Contributor Author

@RiccardoM Can we reference in test case in cosmos-sdj or you have some idea on testing?

@RiccardoM
Copy link
Contributor

@HarleyAppleChoi Currently I see two types of tests that could be done.

1. Unit tests

The first thing we could do is increment the coverage by testing the handlers and the other parts that are not tested right now. This can be done by creating a mocked database and then using that to verify the calls are made properly.

This is the fastest way to increment the test coverage, but it relies on the fact that the database layer needs to be tested properly.

2. Integration tests

These are the harder one to realize. They are based on a dummy chain that is started and then they listen to the data that is sent to it. The problem with these tests is that they are very complex to setup. Particularly, we would need to:

  1. Start a dummy chain
  2. Start BDJuno
  3. Perform some transactions into the dummy chain
  4. Verify that BDJuno handles the transactions properly

Honestly, this is very hard to do and can take up even months to be setup properly.

Conclusions

What I suggest we do is increment the current test coverage by writing the missing unit tests. This means testing the workings of handlers as well as periodic operations. When we have a 84% or more test coverage we can assure that our code is stable.

Also, I would add more tests to the database layer trying to push the boundaries to make sure that we test all the limit cases. An example could be passing a nil validator description to the database to see if it handles it correctly. I think there are a lot of possible nil pointer dereferences right now inside the code that might cause some problems in the future. Tests should allow us to identify them and fix them in advance.

I would leave out the testing of the integration with a chain right now since that is also something that should be tested inside Juno as we rely on it for that part.

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