Closed ethanfrey closed 4 years ago
If we want tests written in TypeScript, this requires spawning an instance of the faucet as a background process from within the tests (because ./bin/cosmwasm-faucet
is only available after build). Then those tests are nodejs-only, since browsers cannot spawn other processes.
Hmmm....
Either I explained bad or the code looks different than I thought. I should take a deepe look at how the code is organized.
I don't want to test the http endpoints, or use the faucet when writing bcp tests, but rather I would like to ensure the handlers work with a real blockchain. So test this initial startup and balancing coins in the faucet account is good enough. Is it impossible to test handlers/controllers without a separate process?
Basically, I just want to make sure the cosmwasm connection is truly compatible here, not test clients against the faucet.
Ah, I see, testing the higher level functionality of the faucet from within the faucet. Makes sense, good point.
Unfortunately the structure of the code does not allow that at the moment. All the real work is written for the binary: https://github.com/confio/cosm-js/blob/a74310ab4ce7170d45d41820848c62c50abd10a9/packages/faucet/src/actions/start/start.ts#L30-L149
But yeah, it would be good to split that into reusable components.
Yeah, exactly, like lines 41-70 could easily be unit tested against a local chain. But this requires a refactor and is a bigger issue than I want to get into now. I know faucet works, and if we test CosmWasmConnection, no reason it shouldn't work.
I'll put this on hold for "later"
Since we have the nice test setup for CI, let's add some tests to faucet to show it works with the proper balance. If you need to give more funds to a starting account (for the faucet), there are some instructions here: https://github.com/cosmwasm/wasmd/blob/master/README.md#ci
Just add a few more cosmos addresses after
setup.sh
and they will all have funds in the genesis. Then commit the newtemplate