forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 37
/
balances.rs
83 lines (72 loc) Β· 1.8 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
use super::*;
#[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::<Balances>();
assert_eq!(
output,
Balances {
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::<Balances>();
assert_eq!(
output,
Balances {
runes: [
(
SpacedRune::new(Rune(RUNE), 0),
[(
OutPoint {
txid: a.output.reveal,
vout: 1
},
Pile {
amount: 1000,
divisibility: 0,
symbol: Some('Β’')
},
)]
.into()
),
(
SpacedRune::new(Rune(RUNE + 1), 0),
[(
OutPoint {
txid: b.output.reveal,
vout: 1
},
Pile {
amount: 1000,
divisibility: 0,
symbol: Some('Β’')
},
)]
.into()
),
]
.into()
}
);
}