-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
112 lines (96 loc) · 2.69 KB
/
lib.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#![allow(clippy::type_complexity)]
use {
self::{command_builder::CommandBuilder, expected::Expected, test_server::TestServer},
bitcoin::{
address::{Address, NetworkUnchecked},
blockdata::constants::COIN_VALUE,
Network, OutPoint, Txid,
},
executable_path::executable_path,
ord::{
inscription_id::InscriptionId,
rarity::Rarity,
templates::{
block::BlockJson, inscription::InscriptionJson, inscriptions::InscriptionsJson,
output::OutputJson, sat::SatJson,
},
SatPoint,
},
pretty_assertions::assert_eq as pretty_assert_eq,
regex::Regex,
reqwest::{StatusCode, Url},
serde::de::DeserializeOwned,
std::{
collections::BTreeMap,
fs,
io::Write,
net::TcpListener,
path::Path,
process::{Child, Command, Stdio},
str::{self, FromStr},
thread,
time::Duration,
},
tempfile::TempDir,
test_bitcoincore_rpc::{Sent, TransactionTemplate},
};
macro_rules! assert_regex_match {
($string:expr, $pattern:expr $(,)?) => {
let regex = Regex::new(&format!("^(?s){}$", $pattern)).unwrap();
let string = $string;
if !regex.is_match(string.as_ref()) {
panic!(
"Regex:\n\n{}\n\n…did not match string:\n\n{}",
regex, string
);
}
};
}
type Inscribe = ord::subcommand::wallet::inscribe::Output;
fn inscribe(rpc_server: &test_bitcoincore_rpc::Handle) -> (InscriptionId, Txid) {
rpc_server.mine_blocks(1);
let output = CommandBuilder::new("wallet inscribe --fee-rate 1 --file foo.txt")
.write("foo.txt", "FOO")
.rpc_server(rpc_server)
.run_and_deserialize_output::<Inscribe>();
rpc_server.mine_blocks(1);
assert_eq!(output.inscriptions.len(), 1);
(output.inscriptions[0].id, output.reveal)
}
fn envelope(payload: &[&[u8]]) -> bitcoin::Witness {
let mut builder = bitcoin::script::Builder::new()
.push_opcode(bitcoin::opcodes::OP_FALSE)
.push_opcode(bitcoin::opcodes::all::OP_IF);
for data in payload {
let mut buf = bitcoin::script::PushBytesBuf::new();
buf.extend_from_slice(data).unwrap();
builder = builder.push_slice(buf);
}
let script = builder
.push_opcode(bitcoin::opcodes::all::OP_ENDIF)
.into_script();
bitcoin::Witness::from_slice(&[script.into_bytes(), Vec::new()])
}
fn create_wallet(rpc_server: &test_bitcoincore_rpc::Handle) {
CommandBuilder::new(format!("--chain {} wallet create", rpc_server.network()))
.rpc_server(rpc_server)
.run_and_deserialize_output::<ord::subcommand::wallet::create::Output>();
}
mod command_builder;
mod expected;
mod test_server;
mod core;
mod decode;
mod epochs;
mod find;
mod index;
mod info;
mod json_api;
mod list;
mod parse;
mod server;
mod subsidy;
mod supply;
mod traits;
mod version;
mod wallet;