Fix Checkpoints fuzz overflow (#4184)
Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
@ -86,12 +86,14 @@ function testPush(
|
||||
|
||||
if (keys.length > 0) {
|
||||
${opts.keyTypeName} lastKey = keys[keys.length - 1];
|
||||
if (lastKey > 0) {
|
||||
pastKey = _bound${capitalize(opts.keyTypeName)}(pastKey, 0, lastKey - 1);
|
||||
|
||||
vm.expectRevert();
|
||||
this.push(pastKey, values[keys.length % values.length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used to test reverts
|
||||
function push(${opts.keyTypeName} key, ${opts.valueTypeName} value) external {
|
||||
@ -173,6 +175,7 @@ function testPush(
|
||||
// Can't push any key in the past
|
||||
if (keys.length > 0) {
|
||||
${opts.keyTypeName} lastKey = keys[keys.length - 1];
|
||||
if (lastKey > 0) {
|
||||
pastKey = _bound${capitalize(opts.keyTypeName)}(pastKey, 0, lastKey - 1);
|
||||
|
||||
vm.roll(pastKey);
|
||||
@ -180,6 +183,7 @@ function testPush(
|
||||
this.push(values[keys.length % values.length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used to test reverts
|
||||
function push(${opts.valueTypeName} value) external {
|
||||
|
||||
@ -66,6 +66,7 @@ contract CheckpointsHistoryTest is Test {
|
||||
// Can't push any key in the past
|
||||
if (keys.length > 0) {
|
||||
uint32 lastKey = keys[keys.length - 1];
|
||||
if (lastKey > 0) {
|
||||
pastKey = _boundUint32(pastKey, 0, lastKey - 1);
|
||||
|
||||
vm.roll(pastKey);
|
||||
@ -73,6 +74,7 @@ contract CheckpointsHistoryTest is Test {
|
||||
this.push(values[keys.length % values.length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used to test reverts
|
||||
function push(uint224 value) external {
|
||||
@ -185,12 +187,14 @@ contract CheckpointsTrace224Test is Test {
|
||||
|
||||
if (keys.length > 0) {
|
||||
uint32 lastKey = keys[keys.length - 1];
|
||||
if (lastKey > 0) {
|
||||
pastKey = _boundUint32(pastKey, 0, lastKey - 1);
|
||||
|
||||
vm.expectRevert();
|
||||
this.push(pastKey, values[keys.length % values.length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used to test reverts
|
||||
function push(uint32 key, uint224 value) external {
|
||||
@ -291,12 +295,14 @@ contract CheckpointsTrace160Test is Test {
|
||||
|
||||
if (keys.length > 0) {
|
||||
uint96 lastKey = keys[keys.length - 1];
|
||||
if (lastKey > 0) {
|
||||
pastKey = _boundUint96(pastKey, 0, lastKey - 1);
|
||||
|
||||
vm.expectRevert();
|
||||
this.push(pastKey, values[keys.length % values.length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used to test reverts
|
||||
function push(uint96 key, uint160 value) external {
|
||||
|
||||
Reference in New Issue
Block a user