]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Provide better get_chain_utxo return coverage in router_target 2018-09-134-rebased
authorMatt Corallo <git@bluematt.me>
Mon, 3 Sep 2018 21:38:38 +0000 (17:38 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 3 Sep 2018 21:40:12 +0000 (17:40 -0400)
fuzz/fuzz_targets/router_target.rs

index 288dc56a432cee896a646d16017fdd423745af41..fdc59efc6f91ce2290c49230fbcb425205a8f48b 100644 (file)
@@ -77,22 +77,19 @@ struct DummyChainWatcher {
 }
 
 impl ChainWatchInterface for DummyChainWatcher {
-       fn install_watch_script(&self, _script_pub_key: &Script) {
-       }
-
-       fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) {
-       }
-
-       fn watch_all_txn(&self) {
-       }
-
-       fn register_listener(&self, _listener: Weak<ChainListener>) {
-       }
+       fn install_watch_script(&self, _script_pub_key: &Script) { }
+       fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) { }
+       fn watch_all_txn(&self) { }
+       fn register_listener(&self, _listener: Weak<ChainListener>) { }
 
        fn get_chain_utxo(&self, _genesis_hash: Sha256dHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
-               match self.input.get_slice(1) {
-                       Some(slice) => Ok((Builder::new().push_opcode(opcodes::All::OP_PUSHBYTES_0).into_script().to_v0_p2wsh(), 0)),
+               match self.input.get_slice(2) {
+                       Some(&[0, _]) => Err(ChainError::NotSupported),
+                       Some(&[1, _]) => Err(ChainError::NotWatched),
+                       Some(&[2, _]) => Err(ChainError::UnknownTx),
+                       Some(&[_, x]) => Ok((Builder::new().push_int(x as i64).into_script().to_v0_p2wsh(), 0)),
                        None => Err(ChainError::UnknownTx),
+                       _ => unreachable!(),
                }
        }
 }