Cover all TryFrom implementations in Script
Add tests to cover `TryFrom` implementations in `Script`
This commit is contained in:
parent
6dfa3d8f4d
commit
7e1369b3f1
|
@ -707,6 +707,23 @@ mod tests {
|
||||||
assert!(ScriptHash::try_from(script).is_err());
|
assert!(ScriptHash::try_from(script).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn try_from_scriptbuf_ref_for_scripthash() {
|
||||||
|
let script = ScriptBuf::from(vec![0x51; 520]);
|
||||||
|
assert!(ScriptHash::try_from(&script).is_ok());
|
||||||
|
|
||||||
|
let script = ScriptBuf::from(vec![0x51; 521]);
|
||||||
|
assert!(ScriptHash::try_from(&script).is_err());
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn try_from_script_for_scripthash() {
|
||||||
|
let script = Script::from_bytes(&[0x51; 520]);
|
||||||
|
assert!(ScriptHash::try_from(script).is_ok());
|
||||||
|
|
||||||
|
let script = Script::from_bytes(&[0x51; 521]);
|
||||||
|
assert!(ScriptHash::try_from(script).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn try_from_scriptbuf_for_wscript_hash() {
|
fn try_from_scriptbuf_for_wscript_hash() {
|
||||||
let script = ScriptBuf::from(vec![0x51; 10_000]);
|
let script = ScriptBuf::from(vec![0x51; 10_000]);
|
||||||
|
@ -716,6 +733,25 @@ mod tests {
|
||||||
assert!(WScriptHash::try_from(script).is_err());
|
assert!(WScriptHash::try_from(script).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn try_from_scriptbuf_ref_for_wscript_hash() {
|
||||||
|
let script = ScriptBuf::from(vec![0x51; 10_000]);
|
||||||
|
assert!(WScriptHash::try_from(&script).is_ok());
|
||||||
|
|
||||||
|
let script = ScriptBuf::from(vec![0x51; 10_001]);
|
||||||
|
assert!(WScriptHash::try_from(&script).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn try_from_script_for_wscript_hash() {
|
||||||
|
let script = Script::from_bytes(&[0x51; 10_000]);
|
||||||
|
assert!(WScriptHash::try_from(script).is_ok());
|
||||||
|
|
||||||
|
let script = Script::from_bytes(&[0x51; 10_001]);
|
||||||
|
assert!(WScriptHash::try_from(script).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn script_display() {
|
fn script_display() {
|
||||||
let script = Script::from_bytes(&[0xa1, 0xb2, 0xc3]);
|
let script = Script::from_bytes(&[0xa1, 0xb2, 0xc3]);
|
||||||
|
|
Loading…
Reference in New Issue