Skip to content

Commit

Permalink
Merge pull request #59 from tellor-io/tim2
Browse files Browse the repository at this point in the history
fix getCurrentValue issue when value count is zero
  • Loading branch information
tkernell authored Feb 14, 2022
2 parents 40b851b + ea1fb8d commit c961857
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/UsingTellor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ contract UsingTellor {
)
{
uint256 _count = tellor.getNewValueCountbyQueryId(_queryId);
if (_count == 0) {
return (false, bytes(""), 0);
}
uint256 _time = tellor.getTimestampbyQueryIdandIndex(
_queryId,
_count - 1
Expand Down Expand Up @@ -71,7 +74,7 @@ contract UsingTellor {
);
if (!_found) return (false, bytes(""), 0);
uint256 _time = tellor.getTimestampbyQueryIdandIndex(_queryId, _index);
_value = tellor.retrieveData(_queryId, _time);
_value = tellor.retrieveData(_queryId, _time);
if (keccak256(_value) != keccak256(bytes("")))
return (true, _value, _time);
return (false, bytes(""), 0);
Expand Down
4 changes: 4 additions & 0 deletions test/usingTellorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ describe("UsingTellor", function() {
expect(currentVal3[0])
expect(currentVal3[1]).to.equal(h.bytes("houdini"))
expect(currentVal3[2]).to.equal(blocky3.timestamp)
currentVal4 = await bench.getCurrentValue(h.uintTob32(2))
expect(!currentVal4[0])
expect(currentVal4[1]).to.equal('0x')
expect(currentVal4[2]).to.equal(0)
})

it("getIndexForDataBefore()", async function() {
Expand Down

0 comments on commit c961857

Please sign in to comment.