From 6dfec329ea3083aa54df686eb63129af6eb986c7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 3 Sep 2018 17:38:38 -0400 Subject: [PATCH] Provide better get_chain_utxo return coverage in router_target --- fuzz/fuzz_targets/router_target.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fuzz/fuzz_targets/router_target.rs b/fuzz/fuzz_targets/router_target.rs index 288dc56a4..fdc59efc6 100644 --- a/fuzz/fuzz_targets/router_target.rs +++ b/fuzz/fuzz_targets/router_target.rs @@ -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) { - } + 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) { } 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!(), } } } -- 2.39.5