File tree Expand file tree Collapse file tree 5 files changed +10
-23
lines changed Expand file tree Collapse file tree 5 files changed +10
-23
lines changed Original file line number Diff line number Diff line change @@ -622,10 +622,7 @@ pub(crate) mod tests {
622
622
match TryInto :: < Txid > :: try_into ( response) {
623
623
Err ( e) => {
624
624
assert_eq ! ( e. kind( ) , io:: ErrorKind :: InvalidData ) ;
625
- assert_eq ! (
626
- e. get_ref( ) . unwrap( ) . to_string( ) ,
627
- "bad hex string length 6 (expected 64)"
628
- ) ;
625
+ assert_eq ! ( e. get_ref( ) . unwrap( ) . to_string( ) , "failed to parse hex" ) ;
629
626
} ,
630
627
Ok ( _) => panic ! ( "Expected error" ) ,
631
628
}
@@ -637,10 +634,7 @@ pub(crate) mod tests {
637
634
match TryInto :: < Txid > :: try_into ( response) {
638
635
Err ( e) => {
639
636
assert_eq ! ( e. kind( ) , io:: ErrorKind :: InvalidData ) ;
640
- assert_eq ! (
641
- e. get_ref( ) . unwrap( ) . to_string( ) ,
642
- "bad hex string length 4 (expected 64)"
643
- ) ;
637
+ assert_eq ! ( e. get_ref( ) . unwrap( ) . to_string( ) , "failed to parse hex" ) ;
644
638
} ,
645
639
Ok ( _) => panic ! ( "Expected error" ) ,
646
640
}
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ where
198
198
return Err ( UtxoLookupError :: UnknownTx ) ;
199
199
}
200
200
201
- outpoint = OutPoint :: new( transaction. txid ( ) , output_index. into( ) ) ;
201
+ outpoint = OutPoint :: new( transaction. compute_txid ( ) , output_index. into( ) ) ;
202
202
output = transaction. output[ output_index as usize ] . clone( ) ;
203
203
} } ;
204
204
}
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ impl ValidatedBlockHeader {
144
144
if self . height % 2016 == 0 {
145
145
let target = self . header . target ( ) ;
146
146
let previous_target = previous_header. header . target ( ) ;
147
- let min_target = previous_target. min_difficulty_transition_threshold ( ) ;
148
- let max_target = previous_target. max_difficulty_transition_threshold ( ) ;
147
+ let min_target = previous_target. min_transition_threshold ( ) ;
148
+ let max_target = previous_target. max_transition_threshold_unchecked ( ) ;
149
149
if target > max_target || target < min_target {
150
150
return Err ( BlockSourceError :: persistent ( "invalid difficulty transition" ) ) ;
151
151
}
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ impl Blockchain {
53
53
input : vec ! [ ] ,
54
54
output : vec ! [ ] ,
55
55
} ;
56
- let merkle_root = TxMerkleNode :: from_raw_hash ( coinbase. txid ( ) . to_raw_hash ( ) ) ;
56
+ let merkle_root = TxMerkleNode :: from_raw_hash ( coinbase. compute_txid ( ) . to_raw_hash ( ) ) ;
57
57
self . blocks . push ( Block {
58
58
header : Header {
59
59
version : Version :: NO_SOFT_FORK_SIGNALLING ,
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ pub fn hex_to_work(hex: &str) -> Result<Work, HexToArrayError> {
9
9
#[ cfg( test) ]
10
10
mod tests {
11
11
use super :: * ;
12
- use bitcoin:: hex:: HexToBytesError ;
13
12
use bitcoin:: pow:: Work ;
14
13
15
14
#[ test]
@@ -20,31 +19,25 @@ mod tests {
20
19
#[ test]
21
20
fn hex_to_work_too_short_str ( ) {
22
21
let hex = String :: from_utf8 ( vec ! [ b'0' ; 32 ] ) . unwrap ( ) ;
23
- assert_eq ! ( hex_to_work( & hex) , Err ( HexToArrayError :: InvalidLength ( 32 , 64 ) ) ) ;
22
+ assert ! ( hex_to_work( & hex) . is_err ( ) ) ;
24
23
}
25
24
26
25
#[ test]
27
26
fn hex_to_work_too_long_str ( ) {
28
27
let hex = String :: from_utf8 ( vec ! [ b'0' ; 128 ] ) . unwrap ( ) ;
29
- assert_eq ! ( hex_to_work( & hex) , Err ( HexToArrayError :: InvalidLength ( 128 , 64 ) ) ) ;
28
+ assert ! ( hex_to_work( & hex) . is_err ( ) ) ;
30
29
}
31
30
32
31
#[ test]
33
32
fn hex_to_work_odd_length_str ( ) {
34
33
let hex = String :: from_utf8 ( vec ! [ b'0' ; 65 ] ) . unwrap ( ) ;
35
- assert_eq ! (
36
- hex_to_work( & hex) ,
37
- Err ( HexToArrayError :: Conversion ( HexToBytesError :: OddLengthString ( 65 ) ) )
38
- ) ;
34
+ assert ! ( hex_to_work( & hex) . is_err( ) ) ;
39
35
}
40
36
41
37
#[ test]
42
38
fn hex_to_work_invalid_char ( ) {
43
39
let hex = String :: from_utf8 ( vec ! [ b'G' ; 64 ] ) . unwrap ( ) ;
44
- assert_eq ! (
45
- hex_to_work( & hex) ,
46
- Err ( HexToArrayError :: Conversion ( HexToBytesError :: InvalidChar ( b'G' ) ) )
47
- ) ;
40
+ assert ! ( hex_to_work( & hex) . is_err( ) ) ;
48
41
}
49
42
50
43
#[ test]
You can’t perform that action at this time.
0 commit comments