zcash-swift-wallet-sdk
zcash-swift-wallet-sdk copied to clipboard
Add a test to check if it's possible to brick the autoshielding using dust
- Initialize an empty wallet.
- Send the wallet enough 1 zat UTXOs that an attempt to spend them all would be larger than the block size.
- Try to autoshield, it should fail because it notices it can't pay the fee in a transaction that's small enough to be valid.
- Now send the wallet a 1000 zat UTXO, and try to autoshield, it should be smart enough to use the 1000 zat UTXO to build a transaction that vacuums up some of the dust.
If (4) fails, then it's possible to brick a wallet by sending it lots of dust.
The UTXO selection algorithm needs to be smart enough to select the higher-value notes first in order to pay the fee, and stop including more UTXOs once it reaches the transaction size limit. This test will confirm it's doing the right thing.