Skip to content

Commit

Permalink
Fixed fallback method
Browse files Browse the repository at this point in the history
  • Loading branch information
McReader committed Dec 4, 2023
1 parent 7c09b39 commit 0332990
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ contract Oracle is IOracle, DataStreamConsumer, PriceFeedConsumer {

bool executable = reqStats.status ==
IRequestsManager.RequestStatus.Pending &&
reqStats.blockNumber + requestTimeout > block.number;
reqStats.blockNumber + requestTimeout < block.number;

return (id, executable);
}
Expand Down
50 changes: 48 additions & 2 deletions src/test/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract OracleTest is Test {
);
}

function test_addRequest() public {
function test_AddRequest() public {
vm.expectEmit();
emit AutomationTrigger(
address(this),
Expand All @@ -48,7 +48,7 @@ contract OracleTest is Test {
);
}

function test_avoidEmitingDuplicatedRequest() public {
function test_RevertIfDuplicatedRequestAdded() public {
vm.expectEmit();

emit AutomationTrigger(
Expand All @@ -73,4 +73,50 @@ contract OracleTest is Test {
address(this)
);
}

// function test_Fallback() public {
// oracle.addRequest(
// address(this),
// abi.encodePacked("test"),
// 0,
// address(this)
// );

// vm.roll(100);

// oracle.fallbackCall(
// address(this),
// abi.encodePacked("test"),
// 0,
// address(this)
// );
// }

function test_RevertIfTimoutHasNotPassed() public {
oracle.addRequest(
address(this),
abi.encodePacked("test"),
0,
address(this)
);

vm.expectRevert();

oracle.fallbackCall(
address(this),
abi.encodePacked("test"),
0,
address(this)
);
}

function test_RevertIfNoRequestToFallback() public {
vm.expectRevert();
oracle.fallbackCall(
address(this),
abi.encodePacked("test"),
0,
address(this)
);
}
}

0 comments on commit 0332990

Please sign in to comment.