Skip to content

Commit 6dfec32

Browse files
committed
Provide better get_chain_utxo return coverage in router_target
1 parent 4ee0114 commit 6dfec32

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

fuzz/fuzz_targets/router_target.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,19 @@ struct DummyChainWatcher {
7777
}
7878

7979
impl ChainWatchInterface for DummyChainWatcher {
80-
fn install_watch_script(&self, _script_pub_key: &Script) {
81-
}
82-
83-
fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) {
84-
}
85-
86-
fn watch_all_txn(&self) {
87-
}
88-
89-
fn register_listener(&self, _listener: Weak<ChainListener>) {
90-
}
80+
fn install_watch_script(&self, _script_pub_key: &Script) { }
81+
fn install_watch_outpoint(&self, _outpoint: (Sha256dHash, u32), _out_script: &Script) { }
82+
fn watch_all_txn(&self) { }
83+
fn register_listener(&self, _listener: Weak<ChainListener>) { }
9184

9285
fn get_chain_utxo(&self, _genesis_hash: Sha256dHash, _unspent_tx_output_identifier: u64) -> Result<(Script, u64), ChainError> {
93-
match self.input.get_slice(1) {
94-
Some(slice) => Ok((Builder::new().push_opcode(opcodes::All::OP_PUSHBYTES_0).into_script().to_v0_p2wsh(), 0)),
86+
match self.input.get_slice(2) {
87+
Some(&[0, _]) => Err(ChainError::NotSupported),
88+
Some(&[1, _]) => Err(ChainError::NotWatched),
89+
Some(&[2, _]) => Err(ChainError::UnknownTx),
90+
Some(&[_, x]) => Ok((Builder::new().push_int(x as i64).into_script().to_v0_p2wsh(), 0)),
9591
None => Err(ChainError::UnknownTx),
92+
_ => unreachable!(),
9693
}
9794
}
9895
}

0 commit comments

Comments
 (0)