ethereum-consensus
ethereum-consensus copied to clipboard
Add testing
Ideally there would be static test vectors that replicate the request/response cycle of a consumer/provider of this API but we don't really have anything like that right now
It would be very nice to add some kind of automatic testing though to make sure things are all good...
I could add tests for each function in the Client Impl. Would it be better in the same file or a separate folder? I think writing tests for each function would show users how to use interact with them.
if we are just adding unit tests, then I'd just suggest a new tests module in the same file.
although this file is getting kind of long already so I'd imagine even putting them in a separate file just for manageability
that all being said, I think the type of tests that would be ideal would be more like an integration test -- and rust has idioms for this: https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html
if we did write an integration test for this, we would need to mock out a beacon node and also the HTTP functionality of the client -- both relatively large tasks on their own -- happy to work w/ you on the next steps here if you are interested
Large tasks just mean I have more things to practice rust with, so I'm interested.
I'm not familiar with integration tests in rust yet, so I'll go research and experiment with them.
I would appreciate it if you could highlight the steps we would need to take next to complete this task.
ok great!
there are a couple routes here and I think the simplest may be to use something like https://docs.rs/httpmock/latest/httpmock/ to mock out the beacon API server