@@ -3,7 +3,13 @@ use {super::*, ord::subcommand::index::info::TransactionsOutput};
3
3
#[ test]
4
4
fn json_with_satoshi_index ( ) {
5
5
let core = mockcore:: spawn ( ) ;
6
+
7
+ let ( tempdir, _) = CommandBuilder :: new ( "--index-sats index update" )
8
+ . core ( & core)
9
+ . run ( ) ;
10
+
6
11
CommandBuilder :: new ( "--index-sats index info" )
12
+ . temp_dir ( tempdir)
7
13
. core ( & core)
8
14
. stdout_regex (
9
15
r#"\{
@@ -37,8 +43,12 @@ fn json_with_satoshi_index() {
37
43
#[ test]
38
44
fn json_without_satoshi_index ( ) {
39
45
let core = mockcore:: spawn ( ) ;
46
+
47
+ let ( tempdir, _) = CommandBuilder :: new ( "index update" ) . core ( & core) . run ( ) ;
48
+
40
49
CommandBuilder :: new ( "index info" )
41
50
. core ( & core)
51
+ . temp_dir ( tempdir)
42
52
. stdout_regex (
43
53
r#"\{
44
54
"blocks_indexed": 1,
@@ -72,39 +82,43 @@ fn json_without_satoshi_index() {
72
82
fn transactions ( ) {
73
83
let core = mockcore:: spawn ( ) ;
74
84
75
- let tempdir = TempDir :: new ( ) . unwrap ( ) ;
85
+ let ( tempdir, _ ) = CommandBuilder :: new ( "index update" ) . core ( & core ) . run ( ) ;
76
86
77
- let index_path = tempdir. path ( ) . join ( "index.redb" ) ;
87
+ let output = CommandBuilder :: new ( "index info --transactions" )
88
+ . temp_dir ( tempdir. clone ( ) )
89
+ . core ( & core)
90
+ . run_and_deserialize_output :: < Vec < TransactionsOutput > > ( ) ;
78
91
79
- assert ! ( CommandBuilder :: new( format!(
80
- "--index {} index info --transactions" ,
81
- index_path. display( )
82
- ) )
83
- . core( & core)
84
- . run_and_deserialize_output:: <Vec <TransactionsOutput >>( )
85
- . is_empty( ) ) ;
92
+ assert ! ( output. is_empty( ) ) ;
86
93
87
94
core. mine_blocks ( 10 ) ;
88
95
89
- let output = CommandBuilder :: new ( format ! (
90
- "--index {} index info --transactions" ,
91
- index_path. display( )
92
- ) )
93
- . core ( & core)
94
- . run_and_deserialize_output :: < Vec < TransactionsOutput > > ( ) ;
96
+ CommandBuilder :: new ( "index update" )
97
+ . temp_dir ( tempdir. clone ( ) )
98
+ . core ( & core)
99
+ . run ( ) ;
100
+
101
+ let output = CommandBuilder :: new ( "index info --transactions" )
102
+ . temp_dir ( tempdir. clone ( ) )
103
+ . core ( & core)
104
+ . stdout_regex ( ".*" )
105
+ . run_and_deserialize_output :: < Vec < TransactionsOutput > > ( ) ;
95
106
96
107
assert_eq ! ( output[ 0 ] . start, 0 ) ;
97
108
assert_eq ! ( output[ 0 ] . end, 1 ) ;
98
109
assert_eq ! ( output[ 0 ] . count, 1 ) ;
99
110
100
111
core. mine_blocks ( 10 ) ;
101
112
102
- let output = CommandBuilder :: new ( format ! (
103
- "--index {} index info --transactions" ,
104
- index_path. display( )
105
- ) )
106
- . core ( & core)
107
- . run_and_deserialize_output :: < Vec < TransactionsOutput > > ( ) ;
113
+ CommandBuilder :: new ( "index update" )
114
+ . temp_dir ( tempdir. clone ( ) )
115
+ . core ( & core)
116
+ . run ( ) ;
117
+
118
+ let output = CommandBuilder :: new ( "index info --transactions" )
119
+ . temp_dir ( tempdir. clone ( ) )
120
+ . core ( & core)
121
+ . run_and_deserialize_output :: < Vec < TransactionsOutput > > ( ) ;
108
122
109
123
assert_eq ! ( output[ 1 ] . start, 1 ) ;
110
124
assert_eq ! ( output[ 1 ] . end, 11 ) ;
0 commit comments