test(lite-backend): port the core-crate tests to the current API
The lite backend core's in-crate tests no longer compiled (119 errors in
lightwallet/tests.rs and the lightclient and walletzkey test modules):
they still used the old LightWallet::new and send_to_address signatures,
the removed extfvks/extsks/zaddress fields and the old new_from_phrase
and do_send arities. So `cargo test` built nothing and no backend change
could be checked against them.
Port them, and the commands and checkpoints tests, to the current API,
touching only #[cfg(test)] code:
- LightWallet::new takes 4 arguments, send_to_address 7 (with an
explicit default fee, returning (txid, raw tx)), new_from_phrase 5 and
do_send 2; keys are read through zkeys and tkeys;
- every config uses the "main" chain: creating a wallet on the "test"
chain panics in base58_pubkey_address, so LightClient::unconnected
(which hard-codes "test") is no longer used;
- every LightClient lives in a temporary data dir, so a test cannot
write to the real ~/.silentdragonxlite or ~/.zcash-params;
- ten send_to_address recipient lists garbled by an upstream change in
2020 are restored from the upstream history.
Expectations that contradicted deliberate current behaviour are updated;
none is ignored:
- a pending send's mempool entry sits at the tip, not tip+1, and
zbalance no longer counts a note with a pending spend;
- keys cannot be added to an encrypted wallet, so the encrypted-receive
tests derive their second address before encrypting;
- the t-address vectors are m/44'/141'/0'/0/{0,1}, checked against an
independent BIP32 derivation; the z-address vectors record the current
output;
- test_addresses and test_checkpoints follow the current address count
and checkpoint tables.
All 43 tests pass on the unchanged production code (three runs) and
leave the real wallet and params directories untouched; that list is the
regression baseline for the following commits. They cover balances,
address derivation, bookkeeping, the mempool, encryption, serialization
and rollback, but none verifies a proof, an anchor or a witness.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-7
@@ -1007,15 +1007,16 @@ pub mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_checkpoints() {
|
||||
// Heights follow the current tables: test {130000, 152000}; main every 10000 from 10000.
|
||||
assert_eq!(get_test_checkpoint(100000), None);
|
||||
assert_eq!(get_test_checkpoint(120000).unwrap().0, 120000);
|
||||
assert_eq!(get_test_checkpoint(125000).unwrap().0, 120000);
|
||||
assert_eq!(get_test_checkpoint(157000).unwrap().0, 157000);
|
||||
assert_eq!(get_test_checkpoint(175000).unwrap().0, 157000);
|
||||
assert_eq!(get_test_checkpoint(130000).unwrap().0, 130000);
|
||||
assert_eq!(get_test_checkpoint(135000).unwrap().0, 130000);
|
||||
assert_eq!(get_test_checkpoint(152000).unwrap().0, 152000);
|
||||
assert_eq!(get_test_checkpoint(175000).unwrap().0, 152000);
|
||||
|
||||
assert_eq!(get_main_checkpoint(100000), None);
|
||||
assert_eq!(get_main_checkpoint(170947).unwrap().0, 170947);
|
||||
assert_eq!(get_main_checkpoint(170949).unwrap().0, 170947);
|
||||
assert_eq!(get_main_checkpoint(9999), None);
|
||||
assert_eq!(get_main_checkpoint(170000).unwrap().0, 170000);
|
||||
assert_eq!(get_main_checkpoint(170947).unwrap().0, 170000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user