entropyxyz / entropy-core

Protocol and cryptography development.
https://docs.entropy.xyz/
GNU Affero General Public License v3.0
11 stars 2 forks source link

Refactor/split `server`'s `user` tests #487

Open ameba23 opened 1 year ago

ameba23 commented 1 year ago

@HCastano noted in this PR comment that the sign_tx_no_chain test is very long and has both happy case and negative test, and could maybe be split up: https://github.com/entropyxyz/entropy-core/pull/475#discussion_r1382140160

I think this is also true of some of the other tests in https://github.com/entropyxyz/entropy-core/blob/master/crypto/server/src/user/tests.rs - they are a bit difficult to maintain and could be refactored.

Why is this issue relevant?

We want to have tests make it easy to see what the problem is when they fail, and are easy to maintain when we want to make changes

What steps are required to resolve this?

Refactor the tests a bit

Does this change the spec? HTTP, extrinsic, or storage? Is it breaking? Clearly describe the new interface.

Not breaking

HCastano commented 1 year ago

I've been looking into this recently and I believe the crux of the issue here is that a lot of the tests depend on a running Substrate node, and this setup is quite expensive (it takes about 30s for a debug node and 10s for a release node on my end to get the process to a point where we can run tests against it).

Instead of spinning up multiple nodes for multiple tests it's quicker to do the setup once and just write a ton of tests under the scope of a single "test".

Some ways we could potentially split the tests up:

HCastano commented 2 months ago

Some of this was done in https://github.com/entropyxyz/entropy-core/pull/1026, but the whole test could still be split out more.