]> Untitled Git - bdk-cli/commitdiff
test(compile): cover sh and sh-wsh script types
authorIkeh Celestine Chukwudi <Chukwudi.ikeh.232330@unn.edu.ng>
Fri, 9 Oct 2026 20:34:09 +0000 (21:34 +0100)
committerIkeh Celestine Chukwudi <Chukwudi.ikeh.232330@unn.edu.ng>
Fri, 9 Oct 2026 20:34:09 +0000 (21:34 +0100)
The existing compile tests only exercise wsh and tr. Add a test
for the sh and sh-wsh branches so every ScriptType variant is covered.

tests/integration/init.rs

index 5244d9969f643b2420a095f85838b00f3852c30d..120341abe7c79aeed501af38993db707293770b3 100644 (file)
@@ -223,6 +223,26 @@ mod test_compile {
             .stdout(predicate::str::contains("wsh("));
     }
 
+    #[test]
+    fn test_compile_sh_and_sh_wsh() {
+        let temp_dir = TempDir::new().unwrap();
+        let cli = BdkCli::new("testnet", Some(temp_dir.path().to_path_buf()));
+
+        let policy = "pk(02e5b88fdb71c696e1a473f309a47535b7190e21a22bd25e7fc8bd055db3bba12f)";
+
+        // compile sh
+        cli.cmd("compile", &[policy, "--type", "sh"])
+            .assert()
+            .success()
+            .stdout(predicate::str::contains("\"descriptor\": \"sh(pk("));
+
+        // compile sh-wsh
+        cli.cmd("compile", &[policy, "--type", "sh-wsh"])
+            .assert()
+            .success()
+            .stdout(predicate::str::contains("\"descriptor\": \"sh(wsh(pk("));
+    }
+
     #[test]
     fn test_compile_invalid_policy() {
         let temp_dir = TempDir::new().unwrap();