Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix unchecked arithmetic on remaining integration-tests
  • Loading branch information
ascjones committed Oct 3, 2023
commit 5e0187e5f491221a9b1eef0d48e0f3f13e0747fb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod incrementer {

#[ink(message)]
pub fn inc_by(&mut self, delta: i64) {
self.value += delta;
self.value.checked_add(delta).unwrap();
}

#[ink(message)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod incrementer {

#[ink(message)]
pub fn inc_by(&mut self, delta: i64) {
self.value += delta;
self.value.checked_add(delta).unwrap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod incrementer {
/// Increases the value of the incrementer by an amount.
#[ink(message)]
pub fn inc_by(&mut self, delta: u64) {
self.value += delta;
self.value.checked_add(delta).unwrap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod delegatee {
/// Increments the current value.
#[ink(message)]
pub fn inc(&mut self) {
self.counter += 2;
self.counter = self.counter.checked_add(2).unwrap();
}

/// Adds current value of counter to the `addresses`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub mod incrementer {
/// We use a different step size (4) here than in the original `incrementer`.
#[ink(message)]
pub fn inc(&mut self) {
self.count += 4;
self.count = self.count.checked_add(4).unwrap();
ink::env::debug_println!("The new count is {}, it was modified using the updated `new_incrementer` code.", self.count);
}

Expand Down