-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
136 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
|
||
import {SpendPermissions} from "../../src/SpendPermissions.sol"; | ||
|
||
import {MockSpendPermissions} from "../mocks/MockSpendPermissions.sol"; | ||
|
||
contract SpendPermissionsBase { | ||
MockSpendPermissions mockSpendPermissions; | ||
|
||
function _initializeSpendPermissions() internal { | ||
mockSpendPermissions = new MockSpendPermissions(); | ||
} | ||
|
||
function _createRecurringAllowance(uint48 start, uint48 period, uint160 allowance) | ||
internal | ||
pure | ||
returns (SpendPermissions.RecurringAllowance memory) | ||
{ | ||
return SpendPermissions.RecurringAllowance(start, period, allowance); | ||
} | ||
|
||
function _safeAdd(uint48 a, uint48 b) internal pure returns (uint48 c) { | ||
bool overflow = uint256(a) + uint256(b) > type(uint48).max; | ||
return overflow ? type(uint48).max : a + b; | ||
} | ||
} |
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,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {SpendPermissions} from "../../src/SpendPermissions.sol"; | ||
|
||
contract MockSpendPermissions is SpendPermissions { | ||
|
||
// TODO: what other internal functions should be exposed? | ||
|
||
// function initializeRecurringAllowance( | ||
// address account, | ||
// bytes32 permissionHash, | ||
// RecurringAllowance memory recurringAlowance | ||
// ) public { | ||
// _initializeRecurringAllowance(account, permissionHash, recurringAlowance); | ||
// } | ||
|
||
function useRecurringAllowance(RecurringAllowance memory recurringAllowance, uint256 value) public { | ||
_useRecurringAllowance(recurringAllowance, value); | ||
} | ||
} |
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,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
|
||
import {SpendPermissions} from "../../../src/SpendPermissions.sol"; | ||
|
||
import {SpendPermissionsBase} from "../../base/SpendPermissionsBase.sol"; | ||
|
||
contract ApproveTest is Test, SpendPermissionsBase { | ||
function setUp() public { | ||
_initializeSpendPermissions(); | ||
} | ||
|
||
function test_approve_revert_invalidSender() public {} | ||
function test_approve_success() public {} | ||
} |
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,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
|
||
import {SpendPermissions} from "../../../src/SpendPermissions.sol"; | ||
|
||
import {SpendPermissionsBase} from "../../base/SpendPermissionsBase.sol"; | ||
|
||
contract GetCurrentCycleTest is Test, SpendPermissionsBase { | ||
function setUp() public { | ||
_initializeSpendPermissions(); | ||
} | ||
|
||
function test_getCurrentCycle_revert_beforeRecurringAllowanceStart() public {} | ||
function test_getCurrentCycle_revert_afterRecurringAllowanceEnd() public {} | ||
function test_getCurrentCycle_success_lastCycleStillActive() public {} | ||
function test_getCurrentCycle_success_determineCurrentCycle() public {} | ||
|
||
} |
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,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
|
||
import {SpendPermissions} from "../../../src/SpendPermissions.sol"; | ||
|
||
import {SpendPermissionsBase} from "../../base/SpendPermissionsBase.sol"; | ||
|
||
contract GetHashTest is Test, SpendPermissionsBase { | ||
function setUp() public { | ||
_initializeSpendPermissions(); | ||
} | ||
|
||
function test_getHash_success() public {} | ||
} |
Empty file.
Empty file.
Empty file.
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,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
|
||
import {SpendPermissions} from "../../../src/SpendPermissions.sol"; | ||
|
||
import {SpendPermissionsBase} from "../../base/SpendPermissionsBase.sol"; | ||
|
||
contract UseRecurringAllowanceTest is Test, SpendPermissionsBase { | ||
function setUp() public { | ||
_initializeSpendPermissions(); | ||
} | ||
function test_useRecurringAllowance_success_noValue() public {} | ||
function test_useRecurringAllowance_revert_unauthorizedRecurringAllowance() | ||
public | ||
{} | ||
function test_useRecurringAllowance_revert_qithdrawValueOverflow() public {} | ||
function test_useRecurringAllowance_revert_exceededRecurringAllowance() | ||
public | ||
{} | ||
// TODO what are the various success logical cases? | ||
function test_userRecurringAllowance_success() public {} | ||
|
||
} |
Empty file.