@@ -3034,7 +3034,7 @@ mod tests {
3034
3034
}
3035
3035
3036
3036
#[ test]
3037
- fn test_get_all_utxos ( ) {
3037
+ fn test_get_all_utxos_with_one_confirmed ( ) {
3038
3038
let miner_seed = vec ! [ 1 , 1 , 1 , 1 ] ;
3039
3039
let keychain = Keychain :: default ( miner_seed. clone ( ) ) ;
3040
3040
let miner_pubkey = keychain. get_pub_key ( ) ;
@@ -3055,11 +3055,13 @@ mod tests {
3055
3055
3056
3056
let utxos = btc_controller. get_all_utxos ( & miner_pubkey) ;
3057
3057
assert_eq ! ( 1 , utxos. len( ) ) ;
3058
+ let utxo = & utxos[ 0 ] ;
3059
+ assert_eq ! ( 101 , utxo. confirmations) ;
3060
+ assert_eq ! ( 5000000000 , utxo. amount) ;
3058
3061
}
3059
3062
3060
3063
#[ test]
3061
- //NOTE: STALL if burn block at block_height doesn't exist....
3062
- fn test_get_utxos ( ) {
3064
+ fn test_get_utxos_ok ( ) {
3063
3065
let miner_seed = vec ! [ 1 , 1 , 1 , 1 ] ;
3064
3066
let keychain = Keychain :: default ( miner_seed. clone ( ) ) ;
3065
3067
let miner_pubkey = keychain. get_pub_key ( ) ;
@@ -3078,7 +3080,7 @@ mod tests {
3078
3080
let btc_controller = BitcoinRegtestController :: new ( config. clone ( ) , None ) ;
3079
3081
btc_controller. bootstrap_chain ( 101 ) ;
3080
3082
3081
- let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, 19000 , None , 0 ) ;
3083
+ let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, 10000 , None , 0 ) ;
3082
3084
3083
3085
let uxto_set = utxos. expect ( "Shouldn't be None!" ) ;
3084
3086
assert_eq ! ( 1 , uxto_set. num_utxos( ) ) ;
@@ -3088,6 +3090,45 @@ mod tests {
3088
3090
assert_eq ! ( 5000000000 , utxo. amount) ;
3089
3091
}
3090
3092
3093
+
3094
+ #[ test]
3095
+ //NOTE: STALL if burn block at block_height doesn't exist....
3096
+ fn test_get_utxos_fails_due_to_filtering ( ) {
3097
+ let miner_seed = vec ! [ 1 , 1 , 1 , 1 ] ;
3098
+ let keychain = Keychain :: default ( miner_seed. clone ( ) ) ;
3099
+ let miner_pubkey = keychain. get_pub_key ( ) ;
3100
+
3101
+ let mut config = Config :: default ( ) ;
3102
+ config. burnchain . magic_bytes = "T3" . as_bytes ( ) . into ( ) ;
3103
+ config. burnchain . local_mining_public_key = Some ( miner_pubkey. to_hex ( ) ) ;
3104
+ config. burnchain . username = Some ( "user" . to_owned ( ) ) ;
3105
+ config. burnchain . password = Some ( "12345" . to_owned ( ) ) ;
3106
+
3107
+ let mut btcd_controller = BitcoinCoreController :: new ( config. clone ( ) ) ;
3108
+ btcd_controller
3109
+ . start_bitcoind ( )
3110
+ . expect ( "bitcoind should be started!" ) ;
3111
+
3112
+ let btc_controller = BitcoinRegtestController :: new ( config. clone ( ) , None ) ;
3113
+ btc_controller. bootstrap_chain ( 101 ) ;
3114
+
3115
+ let too_much_required = 1000000000000000000_u64 ;
3116
+ let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, too_much_required, None , 0 ) ;
3117
+ assert ! ( utxos. is_none( ) , "None because too much required" ) ;
3118
+
3119
+ let other_pubkey = Secp256k1PublicKey :: from_hex ( "01010101010101100101010101" ) . unwrap ( ) ;
3120
+ let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & other_pubkey, too_much_required, None , 0 ) ;
3121
+ assert ! ( utxos. is_none( ) , "None because utxos for other pubkey don't exist" ) ;
3122
+
3123
+ let future_block_height = 1000 ;
3124
+ let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, too_much_required, None , future_block_height) ;
3125
+ assert ! ( utxos. is_none( ) , "None because utxos for future block height don't exist" ) ;
3126
+
3127
+ let existent_utxo = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, 0 , None , 0 ) . expect ( "utxo set should exist" ) ;
3128
+ let utxos = btc_controller. get_utxos ( StacksEpochId :: Epoch31 , & miner_pubkey, 0 , Some ( existent_utxo) , 0 ) ;
3129
+ assert ! ( utxos. is_none( ) , "None because utxos filtering out existent utxo set" ) ;
3130
+ }
3131
+
3091
3132
#[ test]
3092
3133
fn test_build_leader_block_commit_tx_ok_with_new_block_commit ( ) {
3093
3134
let miner_seed = vec ! [ 1 , 1 , 1 , 1 ] ;
0 commit comments