zcash / librustzcash

Rust-language assets for Zcash
Other
324 stars 242 forks source link

Migrate test framework from `zcash_client_sqlite` to `zcash_client_backend` #1412

Open str4d opened 2 weeks ago

str4d commented 2 weeks ago

zcash_client_sqlite::testing contains a TestBuilder that can be used to produce a TestState, on which a test can operate. The test framework is generic over a block cache, that can optionally be provided with a TestCache implementation for tests that require block scanning. However, it currently hard-codes zcash_client_sqlite::WalletDb as the wallet that is tested.

In order to make the tests reusable with other wallet backends, we should rework TestBuilder etc to be generic over a TestWallet trait, that exposes the necessary operations that we currently depend on concrete WalletDb methods for. The new generic TestBuilder parameter should also be bound on WalletRead, WalletWrite, etc. as appropriate (i.e. only when the test framework requires a given bound).

Once that refactor is done, we can then move the test framework to zcash_client_backend behind the test-dependencies feature flag, and depend on it from zcash_client_sqlite. This will then free us up to subsequently genericise and migrate individual tests from zcash_client_sqlite to zcash_client_backend as we wish.