Skip to content

Commit

Permalink
Fix warning when compiling under 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
delaaxe committed Jan 31, 2024
1 parent 8ddf024 commit 9bcc14e
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 43 deletions.
12 changes: 6 additions & 6 deletions src/bytes/src/tests/test_bytes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn test_bytes_read_u128_packed_out_of_bound() {

let bytes = BytesTrait::new(42, array);

let (new_offset, value) = bytes.read_u128_packed(0, 43);
bytes.read_u128_packed(0, 43);
}

#[test]
Expand All @@ -134,7 +134,7 @@ fn test_bytes_read_u128_packed_too_large() {

let bytes = BytesTrait::new(42, array);

let (new_offset, value) = bytes.read_u128_packed(0, 17);
bytes.read_u128_packed(0, 17);
}

#[test]
Expand Down Expand Up @@ -174,7 +174,7 @@ fn test_bytes_read_u128_array_packed_out_of_bound() {

let bytes = BytesTrait::new(42, array);

let (new_offset, new_array) = bytes.read_u128_array_packed(0, 11, 4);
bytes.read_u128_array_packed(0, 11, 4);
}

#[test]
Expand All @@ -189,7 +189,7 @@ fn test_bytes_read_u128_array_packed_too_large() {

let bytes = BytesTrait::new(42, array);

let (new_offset, new_array) = bytes.read_u128_array_packed(0, 2, 17);
bytes.read_u128_array_packed(0, 2, 17);
}

#[test]
Expand Down Expand Up @@ -220,7 +220,7 @@ fn test_bytes_read_felt252_packed_out_of_bound() {

let bytes = BytesTrait::new(42, array);

let (new_offset, new_array) = bytes.read_felt252_packed(0, 43);
bytes.read_felt252_packed(0, 43);
}

#[test]
Expand All @@ -235,7 +235,7 @@ fn test_bytes_read_felt252_packed_too_large() {

let bytes = BytesTrait::new(42, array);

let (new_offset, new_array) = bytes.read_felt252_packed(0, 32);
bytes.read_felt252_packed(0, 32);
}

#[test]
Expand Down
9 changes: 1 addition & 8 deletions src/data_structures/src/tests/array_ext_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use alexandria_data_structures::array_ext::{ArrayTraitExt, SpanTraitExt};
fn dedup_all_different() {
let mut destination = array![1, 2, 3, 4];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 1, 'Should be 1');
assert(*new_arr[1] == 2, 'Should be 2');
Expand All @@ -21,7 +20,6 @@ fn dedup_all_different() {
fn dedup_one_match() {
let mut destination = array![1, 2, 2, 3, 4];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 1, 'Should be 1');
assert(*new_arr[1] == 2, 'Should be 2');
Expand All @@ -35,7 +33,6 @@ fn dedup_one_match() {
fn dedup_two_matches() {
let mut destination = array![1, 2, 2, 3, 4, 4];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 1, 'Should be 1');
assert(*new_arr[1] == 2, 'Should be 2');
Expand All @@ -49,7 +46,6 @@ fn dedup_two_matches() {
fn dedup_one_match_more() {
let mut destination = array![1, 2, 2, 2, 3, 4, 4];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 1, 'Should be 1');
assert(*new_arr[1] == 2, 'Should be 2');
Expand All @@ -63,7 +59,6 @@ fn dedup_one_match_more() {
fn dedup_all_same() {
let mut destination = array![2, 2, 2, 2];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 2, 'Should be 2');
assert(new_arr.len() == 1, 'Len should be 1');
Expand All @@ -74,7 +69,6 @@ fn dedup_all_same() {
fn dedup_one_elem() {
let mut destination = array![2];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(*new_arr[0] == 2, 'Should be 2');
assert(new_arr.len() == 1, 'Len should be 1');
Expand All @@ -85,7 +79,7 @@ fn dedup_one_elem() {
fn dedup_no_elem() {
let mut destination = ArrayTrait::<felt252>::new();
let new_arr = destination.dedup();
let len = new_arr.len();

assert(new_arr.len() == 0, 'Len should be 0');
}

Expand All @@ -94,7 +88,6 @@ fn dedup_no_elem() {
fn dedup_multiple_duplicates_same() {
let mut destination = array![1, 1, 3, 4, 3, 3, 3, 4, 2, 2];
let new_arr = destination.dedup();
let len = new_arr.len();

assert(new_arr.len() == 6, 'Len should be 6');
assert(*new_arr[0] == 1, 'Should be 1');
Expand Down
2 changes: 1 addition & 1 deletion src/data_structures/src/tests/bit_array_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn test_serde_ser_deser() {
// helpers
fn sample_bit_array() -> BitArray {
let sample: felt252 = BoundedInt::<u128>::max().into() - 1;
let u256{low, high } = sample.into();
let u256{low, high: _ } = sample.into();
let ba = BitArray {
data: array![],
current: low.into() * one_shift_left_bytes_felt252(15),
Expand Down
2 changes: 0 additions & 2 deletions src/data_structures/src/tests/byte_reader_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ fn test_read_sequence_le_arr() {
fn test_clone_byte_array_reader() {
let ba = test_byte_array_64();
let mut rd1 = ba.reader();
let temp = rd1.read_u256().unwrap();
let mut rd2 = rd1.clone();
let a = rd1.read_u128().unwrap();
assert(rd1.index != rd2.index, 'indicies equal');
Expand All @@ -480,7 +479,6 @@ fn test_clone_byte_array_reader() {
fn test_clone_array_of_bytes_reader() {
let ba = test_array_64();
let mut rd1 = ba.reader();
let temp = rd1.read_u256().unwrap();
let mut rd2 = rd1.clone();
let a = rd1.read_u128().unwrap();
assert(rd1.index != rd2.index, 'indicies equal');
Expand Down
2 changes: 1 addition & 1 deletion src/data_structures/src/tests/stack_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn stack_push_pop_push_test<
) {
stack.push(val_1);
stack.push(val_2);
stack.pop();
let _ = stack.pop();
stack.push(val_3);

assert(stack.peek().unwrap() == val_3, 'wrong result');
Expand Down
3 changes: 1 addition & 2 deletions src/data_structures/src/tests/vec_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ fn vec_at_test<
ref vec: V, val_1: T
) {
vec.push(val_1);
let result = vec.at(0);
assert(vec.at(0) == val_1, 'vec at should return val_1');
}

Expand All @@ -39,7 +38,7 @@ fn vec_at_out_of_bounds_test<
>(
ref vec: V
) {
let result = vec.at(0);
vec.at(0);
}

fn vec_push_test<
Expand Down
12 changes: 6 additions & 6 deletions src/encoding/src/tests/rlp_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn test_rlp_decode_short_string() {
let res = RLPTrait::decode(arr.span()).unwrap();

// Remove the byte representing the data type
arr.pop_front();
let _ = arr.pop_front();
let expected_item = array![RLPItem::String(arr.span())].span();

assert(res == expected_item, 'Wrong value');
Expand Down Expand Up @@ -291,8 +291,8 @@ fn test_rlp_decode_long_string_with_payload_len_on_1_byte() {
let res = RLPTrait::decode(arr.span()).unwrap();

// Remove the bytes representing the data type and their length
arr.pop_front();
arr.pop_front();
let _ = arr.pop_front();
let _ = arr.pop_front();
let expected_item = array![RLPItem::String(arr.span())].span();

assert(res == expected_item, 'Wrong value');
Expand Down Expand Up @@ -641,9 +641,9 @@ fn test_rlp_decode_long_string_with_payload_len_on_2_bytes() {
let res = RLPTrait::decode(arr.span()).unwrap();

// Remove the bytes representing the data type and their length
arr.pop_front();
arr.pop_front();
arr.pop_front();
let _ = arr.pop_front();
let _ = arr.pop_front();
let _ = arr.pop_front();
let expected_item = array![RLPItem::String(arr.span())].span();

assert(res == expected_item, 'Wrong value');
Expand Down
1 change: 0 additions & 1 deletion src/math/src/tests/i257_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ fn i257_test_mul() {
// Test multiplication by zero
let a = i257 { abs: 10, is_negative: false };
let b = i257 { abs: 0, is_negative: false };
let expected = i257 { abs: 0, is_negative: false };
let result = a * b;
assert(result.abs == 0, '10 * 0 = 0');
assert(!result.is_negative, '10 * 0 -> positive');
Expand Down
2 changes: 1 addition & 1 deletion src/numeric/src/tests/cumprod_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn cumprod_test() {
#[available_gas(2000000)]
fn cumprod_test_revert_empty() {
let xs: Array<u64> = array![];
let ys = cumprod(xs.span());
cumprod(xs.span());
}
2 changes: 1 addition & 1 deletion src/numeric/src/tests/cumsum_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn cumsum_test() {
#[available_gas(2000000)]
fn cumsum_test_revert_empty() {
let xs: Array<u64> = array![];
let ys = cumsum(xs.span());
cumsum(xs.span());
}
4 changes: 2 additions & 2 deletions src/numeric/src/tests/diff_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ fn diff_test() {
#[available_gas(2000000)]
fn diff_test_revert_not_sorted() {
let xs: Array<u128> = array![3, 2];
let ys = diff(xs.span());
diff(xs.span());
}

#[test]
#[should_panic(expected: ('Array must have at least 1 elt',))]
#[available_gas(2000000)]
fn diff_test_revert_empty() {
let xs: Array<u128> = array![];
let ys = diff(xs.span());
diff(xs.span());
}
3 changes: 0 additions & 3 deletions src/searching/src/tests/dijkstra_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ fn calculate_shortest_path() {
#[test]
#[available_gas(2000000)]
fn calculate_shortest_path_random() {
let source = 0_u32;
let dest = 2_u32;
let weight = 4_u128;
let mut graph = GraphTrait::new();
GraphTrait::add_edge(ref graph, 0, 2, 4);
GraphTrait::add_edge(ref graph, 0, 3, 5);
Expand Down
15 changes: 6 additions & 9 deletions src/storage/src/tests/list_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod AListHolder {
numbers: List<u256>
}

#[external(v0)]
#[abi(embed_v0)]
impl Holder of super::IAListHolder<ContractState> {
fn do_get_len(self: @ContractState) -> (u32, u32) {
(self.addresses.read().len(), self.numbers.read().len())
Expand Down Expand Up @@ -71,8 +71,8 @@ mod AListHolder {
) {
let mut a = self.addresses.read();
let mut n = self.numbers.read();
a.set(index, addrs_value);
n.set(index, numbers_value);
let _ = a.set(index, addrs_value);
let _ = n.set(index, numbers_value);
}

fn do_clean(ref self: ContractState) {
Expand Down Expand Up @@ -189,9 +189,9 @@ mod tests {
let numbers_address = contract_state.numbers.address();
let mut numbers_list = ListTrait::<u256>::new(0, numbers_address);

addresses_list.append(mock_addr());
numbers_list.append(1);
numbers_list.append(2);
let _ = addresses_list.append(mock_addr());
let _ = numbers_list.append(1);
let _ = numbers_list.append(2);

assert(addresses_list.len() == 1, 'Addresses length should be 1');
assert(numbers_list.len() == 2, 'Numbers length should be 2');
Expand All @@ -205,9 +205,7 @@ mod tests {
fn test_fetch_empty_list() {
let contract = deploy_mock();
set_contract_address(contract.contract_address);
let mut contract_state = AListHolder::unsafe_new_contract_state();
let storage_address = storage_base_address_from_felt252('empty_address');
let contract = deploy_mock();

let empty_list = ListTrait::<u128>::fetch(0, storage_address).expect('List fetch failed');

Expand Down Expand Up @@ -512,7 +510,6 @@ mod tests {
#[available_gas(100000000)]
fn test_array_clean_with_empty_array() {
let contract = deploy_mock();
let mock_addr = mock_addr();

assert(contract.do_get_len() == (0, 0), 'is empty');

Expand Down

0 comments on commit 9bcc14e

Please sign in to comment.