File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,11 +137,21 @@ def test_recursion_limit_exceed_on_nested_maps() -> None:
137137 assert 'in DAG-CBOR decoding' in str (exc_info .value )
138138
139139
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
140+ def test_dag_cbor_decode_largest_unsigned_int_roundtrip () -> None :
141+ data = bytes .fromhex ('1bffffffffffffffff' )
143142
143+ decoded_result = libipld .decode_dag_cbor (data )
144+ assert decoded_result == 2 ** 64 - 1
144145
145- def test_dag_cbor_decode_smallest_negative_int () -> None :
146- result = libipld .decode_dag_cbor (bytes .fromhex ('3bffffffffffffffff' ))
147- assert result == - (2 ** 64 )
146+ encoded_result = libipld .encode_dag_cbor (decoded_result )
147+ assert encoded_result == data
148+
149+
150+ def test_dag_cbor_decode_smallest_negative_int_roundtrip () -> None :
151+ data = bytes .fromhex ('3bffffffffffffffff' )
152+
153+ decoded_result = libipld .decode_dag_cbor (data )
154+ assert decoded_result == - (2 ** 64 )
155+
156+ encoded_result = libipld .encode_dag_cbor (decoded_result )
157+ assert encoded_result == data
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ fn encode_dag_cbor_from_pyobject<'py, W: Write>(
231231
232232 Ok ( ( ) )
233233 } else if obj. is_instance_of :: < PyInt > ( ) {
234- let i: i64 = obj. extract ( ) ?;
234+ let i: i128 = obj. extract ( ) ?;
235235
236236 if i. is_negative ( ) {
237237 encode:: write_u64 ( w, MajorKind :: NegativeInt , -( i + 1 ) as u64 ) ?
You can’t perform that action at this time.
0 commit comments