Skip to content

Commit 9f0ec72

Browse files
Merge pull request #108 from morpho-dao/upgrade-morpho-1
Merge `upgrade-morpho-1` into `morpho-v1`
2 parents f19cd81 + 7e43ca7 commit 9f0ec72

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

contracts/HeapOrdering.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ library HeapOrdering {
327327
/// @return The address of the next account.
328328
function getNext(HeapArray storage _heap, address _id) internal view returns (address) {
329329
uint256 rank = _heap.ranks[_id];
330-
if (rank < _heap.accounts.length) return getAccount(_heap, rank + 1).id;
331-
else return address(0);
330+
if (rank == 0 || rank >= _heap.accounts.length) return address(0);
331+
332+
return getAccount(_heap, rank + 1).id;
332333
}
333334
}

test-foundry/TestHeapOrdering.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,4 +546,9 @@ contract TestHeapOrdering is DSTest {
546546
hevm.expectRevert("SafeCast: value doesn't fit in 96 bits");
547547
update(accounts[0], uint256(type(uint128).max), 0);
548548
}
549+
550+
function testGetNextUnknown() public {
551+
update(accounts[0], 0, 1);
552+
assertEq(heap.getNext(address(0xdEaD)), ADDR_ZERO);
553+
}
549554
}

0 commit comments

Comments
 (0)