forked from fractal-bitcoin/ord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
balances.rs
86 lines (75 loc) Β· 1.92 KB
/
balances.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
use {super::*, ord::subcommand::balances::Output};
#[test]
fn flag_is_required() {
let core = mockcore::builder().network(Network::Regtest).build();
CommandBuilder::new("--regtest balances")
.core(&core)
.expected_exit_code(1)
.expected_stderr("error: `ord balances` requires index created with `--index-runes` flag\n")
.run_and_extract_stdout();
}
#[test]
fn no_runes() {
let core = mockcore::builder().network(Network::Regtest).build();
let output = CommandBuilder::new("--regtest --index-runes balances")
.core(&core)
.run_and_deserialize_output::<Output>();
assert_eq!(
output,
Output {
runes: BTreeMap::new()
}
);
}
#[test]
fn with_runes() {
let core = mockcore::builder().network(Network::Regtest).build();
let ord = TestServer::spawn_with_server_args(&core, &["--regtest", "--index-runes"], &[]);
create_wallet(&core, &ord);
let a = etch(&core, &ord, Rune(RUNE));
let b = etch(&core, &ord, Rune(RUNE + 1));
let output = CommandBuilder::new("--regtest --index-runes balances")
.core(&core)
.run_and_deserialize_output::<Output>();
assert_eq!(
output,
Output {
runes: vec![
(
SpacedRune::new(Rune(RUNE), 0),
vec![(
OutPoint {
txid: a.output.reveal,
vout: 1
},
Pile {
amount: 1000,
divisibility: 0,
symbol: Some('Β’')
},
)]
.into_iter()
.collect()
),
(
SpacedRune::new(Rune(RUNE + 1), 0),
vec![(
OutPoint {
txid: b.output.reveal,
vout: 1
},
Pile {
amount: 1000,
divisibility: 0,
symbol: Some('Β’')
},
)]
.into_iter()
.collect()
),
]
.into_iter()
.collect(),
}
);
}