Some of these test-utils crates have a lot of very similar (possibly the same?) functionality:
In mc-transaction-core-test-utils:
initialize_ledger takes a ledger db object and adds a bunch of test blocks to it
create_transaction creates a test transaction
get_blocks creates a list of test blocks
In mc-transaction-std, we have separate, slightly different versions of create_transaction in the tests module.
In mc-ledger-db-test-utils, get_test_ledger_blocks is almost the same transaction-core-test-utils::get_blocks.
In ledger/sync/src/test_app/main.rs we have functions like _make_ledger_long which takes a ledger and adds a bunch of blocks to it. This is almost exactly the same as mc_transaction_core_test_utils::initialize_ledger.
In mobilecoind::test_utils, add_block_to_ledger_db is almost the same as mc-transaction-core-test-utils::initialize_ledger and the _make_ledger_long.
We could likely have 2 or 3 functions instead of 10. This would make it much easier to read and maintain this test code, if we just had one flexible "add blocks to ledger" function instead of 3 or 4 variations on a theme that no one can remember the differences between. It would also make it much easier in the future when we have to make changes to TxOut or TransactionBuilder, which will happen whenever we want to ship new features into the blockchain.
Numerous core crates come also with a "test-utils" crate (although sometimes the
test-utils
come in a submodule).mc-transaction-core-test-utils
mc-ledger-db::test_utils
mobilecoind-test-utils
Some of these test-utils crates have a lot of very similar (possibly the same?) functionality:
In
mc-transaction-core-test-utils
:initialize_ledger
takes a ledger db object and adds a bunch of test blocks to itcreate_transaction
creates a test transactionget_blocks
creates a list of test blocksIn
mc-transaction-std
, we have separate, slightly different versions ofcreate_transaction
in the tests module.In
mc-ledger-db-test-utils
,get_test_ledger_blocks
is almost the sametransaction-core-test-utils::get_blocks
.In
ledger/sync/src/test_app/main.rs
we have functions like_make_ledger_long
which takes a ledger and adds a bunch of blocks to it. This is almost exactly the same asmc_transaction_core_test_utils::initialize_ledger
.In
mobilecoind::test_utils
,add_block_to_ledger_db
is almost the same asmc-transaction-core-test-utils::initialize_ledger
and the_make_ledger_long
.We could likely have 2 or 3 functions instead of 10. This would make it much easier to read and maintain this test code, if we just had one flexible "add blocks to ledger" function instead of 3 or 4 variations on a theme that no one can remember the differences between. It would also make it much easier in the future when we have to make changes to
TxOut
orTransactionBuilder
, which will happen whenever we want to ship new features into the blockchain.