@@ -22,10 +22,30 @@ contract EncodingDecodingTest is Test {
22
22
23
23
assertEq (lqty, decodedLqty);
24
24
assertEq (averageTimestamp, decodedAverageTimestamp);
25
+
26
+ // Redo
27
+ uint224 reEncoded = EncodingDecoding.encodeLQTYAllocation (decodedLqty, decodedAverageTimestamp);
28
+ (uint88 reDecodedLqty , uint32 reDecodedAverageTimestamp ) = EncodingDecoding.decodeLQTYAllocation (encodedValue);
29
+
30
+ assertEq (reEncoded, encodedValue);
31
+ assertEq (reDecodedLqty, decodedLqty);
32
+ assertEq (reDecodedAverageTimestamp, decodedAverageTimestamp);
33
+ }
34
+
35
+
36
+ /// We expect this test to fail as the encoding is ambigous past u120
37
+ function test_fail_encoding_not_equal_reproducer () public {
38
+ _receive_undo_compare (18371677541005923091065047412368542483005086202 );
39
+ }
40
+
41
+ // receive -> undo -> check -> redo -> compare
42
+ function test_receive_undo_compare (uint120 encodedValue ) public {
43
+ _receive_undo_compare (encodedValue);
25
44
}
26
45
27
46
// receive -> undo -> check -> redo -> compare
28
- function test_receive_undo_compare (uint224 encodedValue ) public {
47
+ function _receive_undo_compare (uint224 encodedValue ) public {
48
+ /// These values fail because we could pass a value that is bigger than intended
29
49
(uint88 decodedLqty , uint32 decodedAverageTimestamp ) = EncodingDecoding.decodeLQTYAllocation (encodedValue);
30
50
31
51
uint224 encodedValue2 = EncodingDecoding.encodeLQTYAllocation (decodedLqty, decodedAverageTimestamp);
@@ -36,7 +56,5 @@ contract EncodingDecodingTest is Test {
36
56
assertEq (decodedAverageTimestamp, decodedAverageTimestamp2, "decoded timestamps not equal " );
37
57
}
38
58
39
- function test_encoding_not_equal_reproducer () public {
40
- test_receive_undo_compare (18371677541005923091065047412368542483005086202 );
41
- }
59
+
42
60
}
0 commit comments