ethereum-consensus icon indicating copy to clipboard operation
ethereum-consensus copied to clipboard

Add testing

Open ralexstokes opened this issue 2 years ago • 4 comments

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...

ralexstokes avatar Sep 09 '22 20:09 ralexstokes

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.

Perelyn-sama avatar Oct 17 '22 16:10 Perelyn-sama

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

ralexstokes avatar Oct 24 '22 20:10 ralexstokes

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.

Perelyn-sama avatar Oct 25 '22 12:10 Perelyn-sama

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

ralexstokes avatar Nov 11 '22 18:11 ralexstokes