@@ -15,6 +15,8 @@ use crate::crypto_helper::{encode_bech32, KESPeriod, OpCert, SerDeShelleyFileFor
15
15
use crate :: entities:: { BlockNumber , ChainPoint , Epoch , SlotNumber , StakeDistribution } ;
16
16
use crate :: { CardanoNetwork , StdResult } ;
17
17
18
+ const CARDANO_ERA : & str = "latest" ;
19
+
18
20
/// `CliRunner` trait defines the asynchronous methods
19
21
/// for interaction with the Cardano CLI.
20
22
#[ async_trait]
@@ -66,6 +68,7 @@ impl CardanoCliRunner {
66
68
fn command_for_utxo ( & self , address : & str , out_file : PathBuf ) -> Command {
67
69
let mut command = self . get_command ( ) ;
68
70
command
71
+ . arg ( CARDANO_ERA )
69
72
. arg ( "query" )
70
73
. arg ( "utxo" )
71
74
. arg ( "--address" )
@@ -79,7 +82,10 @@ impl CardanoCliRunner {
79
82
80
83
fn command_for_stake_distribution ( & self ) -> Command {
81
84
let mut command = self . get_command ( ) ;
82
- command. arg ( "query" ) . arg ( "stake-distribution" ) ;
85
+ command
86
+ . arg ( CARDANO_ERA )
87
+ . arg ( "query" )
88
+ . arg ( "stake-distribution" ) ;
83
89
self . post_config_command ( & mut command) ;
84
90
85
91
command
@@ -88,6 +94,7 @@ impl CardanoCliRunner {
88
94
fn command_for_stake_snapshot ( & self , stake_pool_id : & str ) -> Command {
89
95
let mut command = self . get_command ( ) ;
90
96
command
97
+ . arg ( CARDANO_ERA )
91
98
. arg ( "query" )
92
99
. arg ( "stake-snapshot" )
93
100
. arg ( "--stake-pool-id" )
@@ -100,6 +107,7 @@ impl CardanoCliRunner {
100
107
fn command_for_stake_snapshot_all_pools ( & self ) -> Command {
101
108
let mut command = self . get_command ( ) ;
102
109
command
110
+ . arg ( CARDANO_ERA )
103
111
. arg ( "query" )
104
112
. arg ( "stake-snapshot" )
105
113
. arg ( "--all-stake-pools" ) ;
@@ -110,15 +118,15 @@ impl CardanoCliRunner {
110
118
111
119
fn command_for_epoch ( & self ) -> Command {
112
120
let mut command = self . get_command ( ) ;
113
- command. arg ( "query" ) . arg ( "tip" ) ;
121
+ command. arg ( CARDANO_ERA ) . arg ( "query" ) . arg ( "tip" ) ;
114
122
self . post_config_command ( & mut command) ;
115
123
116
124
command
117
125
}
118
126
119
127
fn command_for_chain_point ( & self ) -> Command {
120
128
let mut command = self . get_command ( ) ;
121
- command. arg ( "query" ) . arg ( "tip" ) ;
129
+ command. arg ( CARDANO_ERA ) . arg ( "query" ) . arg ( "tip" ) ;
122
130
self . post_config_command ( & mut command) ;
123
131
124
132
command
@@ -127,6 +135,7 @@ impl CardanoCliRunner {
127
135
fn command_for_kes_period ( & self , opcert_file : & str ) -> Command {
128
136
let mut command = self . get_command ( ) ;
129
137
command
138
+ . arg ( CARDANO_ERA )
130
139
. arg ( "query" )
131
140
. arg ( "kes-period-info" )
132
141
. arg ( "--op-cert-file" )
@@ -556,8 +565,8 @@ mod tests {
556
565
CardanoNetwork :: TestNet ( 10 ) ,
557
566
) ;
558
567
559
- assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" tip\" \" --testnet-magic\" \" 10\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_epoch( ) ) ) ;
560
- assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" stake-distribution\" \" --testnet-magic\" \" 10\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_stake_distribution( ) ) ) ;
568
+ assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" tip\" \" --testnet-magic\" \" 10\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_epoch( ) ) ) ;
569
+ assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" stake-distribution\" \" --testnet-magic\" \" 10\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_stake_distribution( ) ) ) ;
561
570
}
562
571
563
572
#[ tokio:: test]
@@ -568,8 +577,8 @@ mod tests {
568
577
CardanoNetwork :: DevNet ( 25 ) ,
569
578
) ;
570
579
571
- assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" tip\" \" --cardano-mode\" \" --testnet-magic\" \" 25\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_epoch( ) ) ) ;
572
- assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" stake-distribution\" \" --cardano-mode\" \" --testnet-magic\" \" 25\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_stake_distribution( ) ) ) ;
580
+ assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" tip\" \" --cardano-mode\" \" --testnet-magic\" \" 25\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_epoch( ) ) ) ;
581
+ assert_eq ! ( "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" stake-distribution\" \" --cardano-mode\" \" --testnet-magic\" \" 25\" , kill_on_drop: false }" , format!( "{:?}" , runner. command_for_stake_distribution( ) ) ) ;
573
582
}
574
583
575
584
#[ tokio:: test]
@@ -581,11 +590,11 @@ mod tests {
581
590
) ;
582
591
583
592
assert_eq ! (
584
- "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" tip\" \" --mainnet\" , kill_on_drop: false }" ,
593
+ "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" tip\" \" --mainnet\" , kill_on_drop: false }" ,
585
594
format!( "{:?}" , runner. command_for_epoch( ) )
586
595
) ;
587
596
assert_eq ! (
588
- "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" query\" \" stake-distribution\" \" --mainnet\" , kill_on_drop: false }" ,
597
+ "Command { std: CARDANO_NODE_SOCKET_PATH=\" /tmp/whatever.sock\" \" cardano-cli\" \" latest \" \" query\" \" stake-distribution\" \" --mainnet\" , kill_on_drop: false }" ,
589
598
format!( "{:?}" , runner. command_for_stake_distribution( ) )
590
599
) ;
591
600
}
0 commit comments