-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tree: document and test base functionality
- Loading branch information
1 parent
d9613af
commit 4411b03
Showing
4 changed files
with
796 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../lib/TimeHelpersMock.sol"; | ||
import "../../lib/HexSumTree.sol"; | ||
|
||
|
||
contract CheckpointedHexSumTreeMock is TimeHelpersMock { | ||
using HexSumTree for HexSumTree.Tree; | ||
|
||
HexSumTree.Tree internal tree; | ||
|
||
function init() external { | ||
tree.init(); | ||
} | ||
|
||
function insert(uint64 _time, uint256 _value) external returns (uint256) { | ||
return tree.insert(_time, _value); | ||
} | ||
|
||
function set(uint256 _key, uint64 _time, uint256 _value) external { | ||
tree.set(_key, _time, _value); | ||
} | ||
|
||
function update(uint256 _key, uint64 _time, uint256 _delta, bool _positive) external { | ||
tree.update(_key, _time, _delta, _positive); | ||
} | ||
|
||
function nextKey() public view returns (uint256) { | ||
return tree.nextKey; | ||
} | ||
|
||
function item(uint256 _key) public view returns (uint256) { | ||
return tree.getItem(_key); | ||
} | ||
|
||
function itemAt(uint256 _key, uint64 _time) public view returns (uint256) { | ||
return tree.getItemPast(_key, _time); | ||
} | ||
|
||
function height() public view returns (uint256) { | ||
return tree.getRootDepth(); | ||
} | ||
|
||
function heightAt(uint64 _time) public view returns (uint256) { | ||
return tree.getRootDepthAt(_time, true); | ||
} | ||
|
||
function total() public view returns (uint256) { | ||
return tree.totalSum(); | ||
} | ||
|
||
function totalAt(uint64 _time) public view returns (uint256) { | ||
return tree.totalSumPast(_time); | ||
} | ||
|
||
function getLast(uint256 _level, uint256 _key) public view returns (uint256) { | ||
return tree.get(_level, _key); | ||
} | ||
|
||
function getAt(uint256 _level, uint256 _key, uint64 _time) public view returns (uint256) { | ||
return tree.getPast(_level, _key, _time); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.