diff --git a/contracts/UsingTellor.sol b/contracts/UsingTellor.sol index 26069ca..9accf7a 100644 --- a/contracts/UsingTellor.sol +++ b/contracts/UsingTellor.sol @@ -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 @@ -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); diff --git a/test/usingTellorTest.js b/test/usingTellorTest.js index e40a084..8fd6195 100644 --- a/test/usingTellorTest.js +++ b/test/usingTellorTest.js @@ -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() {