File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
crates/primitives/src/signature Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ impl Parity {
73
73
pub const fn y_parity ( & self ) -> bool {
74
74
match self {
75
75
Self :: Eip155 ( v @ 0 ..=34 ) => * v % 2 == 1 ,
76
- Self :: Eip155 ( v) => ( * v ^ 1 ) % 2 == 0 ,
76
+ Self :: Eip155 ( v) => ( * v ^ 1 ) % 2 == 1 ,
77
77
Self :: NonEip155 ( b) | Self :: Parity ( b) => * b,
78
78
}
79
79
}
@@ -170,10 +170,12 @@ impl alloy_rlp::Decodable for Parity {
170
170
171
171
#[ cfg( test) ]
172
172
mod test {
173
+ use crate :: Parity ;
174
+
173
175
#[ cfg( feature = "rlp" ) ]
174
176
#[ test]
175
177
fn basic_rlp ( ) {
176
- use crate :: { hex, Parity } ;
178
+ use crate :: hex;
177
179
178
180
use alloy_rlp:: { Decodable , Encodable } ;
179
181
@@ -193,4 +195,14 @@ mod test {
193
195
assert_eq ! ( test. 1 , Parity :: decode( & mut buf. as_slice( ) ) . unwrap( ) ) ;
194
196
}
195
197
}
198
+
199
+ #[ test]
200
+ fn round_trip ( ) {
201
+ // with chain ID 1
202
+ let p = Parity :: Eip155 ( 37 ) ;
203
+
204
+ assert_eq ! ( p. to_parity_bool( ) , Parity :: Parity ( false ) ) ;
205
+
206
+ assert_eq ! ( p. with_chain_id( 1 ) , Parity :: Eip155 ( 37 ) ) ;
207
+ }
196
208
}
You can’t perform that action at this time.
0 commit comments