Skip to content

Commit 4aeb71f

Browse files
Merge pull request #9 from CetusProtocol/unit-tests
Unit tests
2 parents 83f9c18 + ad5d6b2 commit 4aeb71f

18 files changed

Lines changed: 3323 additions & 1121 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
/build
88
/.idea
99
/.aptos
10+
/sui/.coverage_map.mvcov
11+
/sui/.trace

sui/Move.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
name = "IntegerMate"
55
version = "1.2.0"
66
published-at = "0xf1e4fae2183dabebc4827b0a46ddae9c0d0a6afa06a416e1f887a4ffd33f5067"
7+
edition = "2024"
78

89
[dependencies]
910
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.48.2" }

sui/migration.patch

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--- ./sources/i128.move
2+
+++ ./sources/i128.move
3+
@@ -14 +14 @@
4+
- struct I128 has copy, drop, store {
5+
+ public struct I128 has copy, drop, store {
6+
@@ -53,2 +53,2 @@
7+
- let sum = num1.bits ^ num2.bits;
8+
- let carry = (num1.bits & num2.bits) << 1;
9+
+ let mut sum = num1.bits ^ num2.bits;
10+
+ let mut carry = (num1.bits & num2.bits) << 1;
11+
--- ./sources/i32.move
12+
+++ ./sources/i32.move
13+
@@ -11 +11 @@
14+
- struct I32 has copy, drop, store {
15+
+ public struct I32 has copy, drop, store {
16+
@@ -48,2 +48,2 @@
17+
- let sum = num1.bits ^ num2.bits;
18+
- let carry = (num1.bits & num2.bits) << 1;
19+
+ let mut sum = num1.bits ^ num2.bits;
20+
+ let mut carry = (num1.bits & num2.bits) << 1;
21+
--- ./sources/i64.move
22+
+++ ./sources/i64.move
23+
@@ -11 +11 @@
24+
- struct I64 has copy, drop, store {
25+
+ public struct I64 has copy, drop, store {
26+
@@ -48,2 +48,2 @@
27+
- let sum = num1.bits ^ num2.bits;
28+
- let carry = (num1.bits & num2.bits) << 1;
29+
+ let mut sum = num1.bits ^ num2.bits;
30+
+ let mut carry = (num1.bits & num2.bits) << 1;
31+
--- ./tests/i32_tests.move
32+
+++ ./tests/i32_tests.move
33+
@@ -733 +733 @@
34+
- let i = mod(neg_from(2), from(5));
35+
+ let mut i = mod(neg_from(2), from(5));
36+
--- ./tests/i64_tests.move
37+
+++ ./tests/i64_tests.move
38+
@@ -622 +622 @@
39+
- let i = mod(neg_from(2), from(5));
40+
+ let mut i = mod(neg_from(2), from(5));

sui/sources/full_math_u128.move

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ module integer_mate::full_math_u128 {
1919
(product as u128)
2020
}
2121

22+
23+
#[
24+
deprecated(
25+
note = b"This function converts num1 and num2 to u256, multiplies them, then left-shifts the result by the specified number of bits, and finally coerces the result into u128. The left shift does not perform overflow checks, so it is recommended not to use this function to avoid unexpected results.",
26+
),
27+
]
2228
public fun mul_shl(num1: u128, num2: u128, shift: u8): u128 {
2329
let product = full_mul(num1, num2) << shift;
2430
(product as u128)

sui/sources/full_math_u64.move

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ module integer_mate::full_math_u64 {
1919
(r as u64)
2020
}
2121

22+
#[
23+
deprecated(
24+
note = b"This function converts num1 and num2 to u128, multiplies them, then left-shifts the result by the specified number of bits, and finally coerces the result into u64. The left shift does not perform overflow checks, so it is recommended not to use this function to avoid unexpected results.",
25+
),
26+
]
2227
public fun mul_shl(num1: u64, num2: u64, shift: u8): u64 {
2328
let r = full_mul(num1, num2) << shift;
2429
(r as u64)

0 commit comments

Comments
 (0)