-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
verify.rs
66 lines (61 loc) Β· 1.77 KB
/
verify.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use super::*;
#[test]
fn verify() {
assert_eq!(
CommandBuilder::new([
"verify",
"--address", "bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l",
"--text", "Hello World",
"--witness", "AkcwRAIgZRfIY3p7/DoVTty6YZbWS71bc5Vct9p9Fia83eRmw2QCICK/ENGfwLtptFluMGs2KsqoNSk89pO7F29zJLUx9a/sASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI="
])
.run_and_extract_stdout(),
""
);
}
#[test]
fn verify_fails() {
CommandBuilder::new([
"verify",
"--address", "bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l",
"--text", "Hello World - this should fail",
"--witness", "AkcwRAIgZRfIY3p7/DoVTty6YZbWS71bc5Vct9p9Fia83eRmw2QCICK/ENGfwLtptFluMGs2KsqoNSk89pO7F29zJLUx9a/sASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI="
])
.expected_exit_code(1)
.stderr_regex("error: Invalid signature.*")
.run_and_extract_stdout();
}
#[test]
fn witness_and_transaction_conflict() {
CommandBuilder::new([
"verify",
"--address", "bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l",
"--text", "Hello World",
"--transaction", "asdf",
"--witness", "AkcwRAIgZRfIY3p7/DoVTty6YZbWS71bc5Vct9p9Fia83eRmw2QCICK/ENGfwLtptFluMGs2KsqoNSk89pO7F29zJLUx9a/sASECx/EgAxlkQpQ9hYjgGu6EBCPMVPwVIVJqO4XCsMvViHI="
])
.expected_exit_code(2)
.stderr_regex(".*error.*")
.run_and_extract_stdout();
}
#[test]
fn verify_with_transaction() {
let tx = bip322::sign_full_encoded(
"bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l",
"Hello World",
"L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k",
)
.unwrap();
assert_eq!(
CommandBuilder::new([
"verify",
"--address",
"bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l",
"--text",
"Hello World",
"--transaction",
&tx,
])
.run_and_extract_stdout(),
""
);
}