Skip to content

Commit

Permalink
fixed AvlTree test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mllwchrry committed Jun 12, 2024
1 parent 676a5c7 commit 41dd749
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions contracts/mock/libs/data-structures/AvlTreeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,45 @@ contract AvlTreeMock {
}

function traverseAddress() external view returns (uint256[] memory, address[] memory) {
(uint256[] memory keys_, bytes32[] memory values_) = _traverseAll(
_addressTree.first(),
_addressTree.size(),
true
);
Traversal.Iterator memory iterator_ = _addressTree.first();

bytes32[] memory keys_ = new bytes32[](_addressTree.size());
bytes32[] memory values_ = new bytes32[](keys_.length);

(keys_[0], values_[0]) = iterator_.value();

uint256 index_ = 1;

while (iterator_.hasNext()) {
(keys_[index_], values_[index_]) = iterator_.next();

index_++;
}

return (keys_, values_.asAddressArray());
return (keys_.asUint256Array(), values_.asAddressArray());
}

function backwardsTraversalAddress()
external
view
returns (uint256[] memory, address[] memory)
{
(uint256[] memory keys_, bytes32[] memory values_) = _traverseAll(
_addressTree.last(),
_addressTree.size(),
false
);
Traversal.Iterator memory iterator_ = _addressTree.last();

bytes32[] memory keys_ = new bytes32[](_addressTree.size());
bytes32[] memory values_ = new bytes32[](keys_.length);

(keys_[0], values_[0]) = iterator_.value();

uint256 index_ = 1;

while (iterator_.hasPrev()) {
(keys_[index_], values_[index_]) = iterator_.prev();

index_++;
}

return (keys_, values_.asAddressArray());
return (keys_.asUint256Array(), values_.asAddressArray());
}

function nextOnLast() external view returns (uint256, uint256) {
Expand Down

0 comments on commit 41dd749

Please sign in to comment.