File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -135,3 +135,13 @@ def test_recursion_limit_exceed_on_nested_maps() -> None:
135135 libipld .decode_dag_cbor (dag_cbor )
136136
137137 assert 'in DAG-CBOR decoding' in str (exc_info .value )
138+
139+
140+ def test_dag_cbor_decode_largest_unsigned_int () -> None :
141+ result = libipld .decode_dag_cbor (bytes .fromhex ('1bffffffffffffffff' ))
142+ assert result == 2 ** 64 - 1
143+
144+
145+ def test_dag_cbor_decode_smallest_negative_int () -> None :
146+ result = libipld .decode_dag_cbor (bytes .fromhex ('3bffffffffffffffff' ))
147+ assert result == - (2 ** 64 )
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ fn decode_dag_cbor_to_pyobject<R: Read + Seek>(
122122 let major = decode:: read_major ( r) ?;
123123 Ok ( match major. kind ( ) {
124124 MajorKind :: UnsignedInt => decode:: read_uint ( r, major) ?. into_pyobject ( py) ?. into ( ) ,
125- MajorKind :: NegativeInt => ( -1 - decode:: read_uint ( r, major) ? as i64 ) . into_pyobject ( py) ?. into ( ) ,
125+ MajorKind :: NegativeInt => ( -1 - decode:: read_uint ( r, major) ? as i128 ) . into_pyobject ( py) ?. into ( ) ,
126126 MajorKind :: ByteString => {
127127 let len = decode:: read_uint ( r, major) ?;
128128 PyBytes :: new ( py, & decode:: read_bytes ( r, len) ?) . into_pyobject ( py) ?. into ( )
You can’t perform that action at this time.
0 commit comments