From 74f1a12c1b9d1ef062bcfc191ccab384f9638b3e Mon Sep 17 00:00:00 2001 From: hudsonhrh Date: Thu, 13 Mar 2025 12:53:39 -0500 Subject: [PATCH] feat: bulloak example --- trees/CommunityVault.t.sol | 142 +++++++++++++++++++++++++++++++++++++ trees/CommunityVault.tree | 56 +++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 trees/CommunityVault.t.sol create mode 100644 trees/CommunityVault.tree diff --git a/trees/CommunityVault.t.sol b/trees/CommunityVault.t.sol new file mode 100644 index 0000000..fc5138d --- /dev/null +++ b/trees/CommunityVault.t.sol @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.0; + +contract CommunityVaultTest { + function test_WhenInitialized() external { + // It should set the security context. + // It should revert if security context is zero address. + } + + modifier whenDepositIsCalled() { + _; + } + + function test_WhenDepositingETH() external whenDepositIsCalled { + // It should accept ETH when msg.value matches amount. + // It should revert if msg.value does not match amount. + } + + function test_WhenDepositingERC20() external whenDepositIsCalled { + // It should transfer tokens from sender and update balance. + } + + modifier whenWithdrawIsCalled() { + _; + } + + modifier whenCallerHasSYSTEM_ROLEForWithdraw() { + _; + } + + function test_WhenCallerHasSYSTEM_ROLEForWithdraw() + external + whenWithdrawIsCalled + whenCallerHasSYSTEM_ROLEForWithdraw + { + // It should revert if insufficient balance. + } + + function test_WhenWithdrawingETH() external whenWithdrawIsCalled whenCallerHasSYSTEM_ROLEForWithdraw { + // It should send ETH to recipient. + // It should revert if ETH transfer fails. + } + + function test_WhenWithdrawingERC20() external whenWithdrawIsCalled whenCallerHasSYSTEM_ROLEForWithdraw { + // It should transfer tokens and reduce balance. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForWithdraw() external whenWithdrawIsCalled { + // It should revert. + } + + modifier whenDistributeIsCalled() { + _; + } + + function test_WhenCallerHasSYSTEM_ROLEForDistribute() external whenDistributeIsCalled { + // It should distribute tokens to recipients. + // It should revert if recipients and amounts mismatch. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForDistribute() external whenDistributeIsCalled { + // It should revert. + } + + modifier whenDistributeRewardsIsCalled() { + _; + } + + modifier whenCallerHasSYSTEM_ROLEForDistributeRewards() { + _; + } + + function test_WhenRewardsCalculatorAndPurchaseTrackerAreSet() + external + whenDistributeRewardsIsCalled + whenCallerHasSYSTEM_ROLEForDistributeRewards + { + // It should calculate and distribute rewards. + } + + function test_WhenRewardsCalculatorOrPurchaseTrackerNotSet() + external + whenDistributeRewardsIsCalled + whenCallerHasSYSTEM_ROLEForDistributeRewards + { + // It should do nothing. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForDistributeRewards() external whenDistributeRewardsIsCalled { + // It should revert. + } + + function test_WhenClaimRewardsIsCalled() external { + // It should distribute rewards to msg.sender using rewardsCalculator. + } + + modifier whenSetGovernanceVaultIsCalled() { + _; + } + + function test_WhenCallerHasSYSTEM_ROLEForGovernanceVault() external whenSetGovernanceVaultIsCalled { + // It should set the governanceVault address. + // It should approve lootToken with max allowance. + // It should revert if vault or lootToken is zero. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForGovernanceVault() external whenSetGovernanceVaultIsCalled { + // It should revert. + } + + modifier whenSetPurchaseTrackerIsCalled() { + _; + } + + function test_WhenCallerHasSYSTEM_ROLEForPurchaseTracker() external whenSetPurchaseTrackerIsCalled { + // It should set the purchase tracker. + // It should revert if address is zero. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForPurchaseTracker() external whenSetPurchaseTrackerIsCalled { + // It should revert. + } + + modifier whenSetCommunityRewardsCalculatorIsCalled() { + _; + } + + function test_WhenCallerHasSYSTEM_ROLEForRewardsCalculator() external whenSetCommunityRewardsCalculatorIsCalled { + // It should set the rewards calculator. + } + + function test_RevertWhen_CallerLacksSYSTEM_ROLEForRewardsCalculator() + external + whenSetCommunityRewardsCalculatorIsCalled + { + // It should revert. + } + + function test_WhenGetBalanceIsCalled() external { + // It should return the correct token balance. + } +} diff --git a/trees/CommunityVault.tree b/trees/CommunityVault.tree new file mode 100644 index 0000000..1102cc3 --- /dev/null +++ b/trees/CommunityVault.tree @@ -0,0 +1,56 @@ +CommunityVaultTest +├── When initialized +│ ├── It should set the security context. +│ └── It should revert if security context is zero address. +├── When deposit is called +│ ├── When depositing ETH +│ │ ├── It should accept ETH when msg.value matches amount. +│ │ └── It should revert if msg.value does not match amount. +│ └── When depositing ERC20 +│ └── It should transfer tokens from sender and update balance. +├── When withdraw is called +│ ├── When caller has SYSTEM_ROLE for withdraw +│ │ ├── When withdrawing ETH +│ │ │ ├── It should send ETH to recipient. +│ │ │ └── It should revert if ETH transfer fails. +│ │ ├── When withdrawing ERC20 +│ │ │ └── It should transfer tokens and reduce balance. +│ │ └── It should revert if insufficient balance. +│ └── When caller lacks SYSTEM_ROLE for withdraw +│ └── It should revert. +├── When distribute is called +│ ├── When caller has SYSTEM_ROLE for distribute +│ │ ├── It should distribute tokens to recipients. +│ │ └── It should revert if recipients and amounts mismatch. +│ └── When caller lacks SYSTEM_ROLE for distribute +│ └── It should revert. +├── When distributeRewards is called +│ ├── When caller has SYSTEM_ROLE for distributeRewards +│ │ ├── When rewardsCalculator and purchaseTracker are set +│ │ │ └── It should calculate and distribute rewards. +│ │ └── When rewardsCalculator or purchaseTracker not set +│ │ └── It should do nothing. +│ └── When caller lacks SYSTEM_ROLE for distributeRewards +│ └── It should revert. +├── When claimRewards is called +│ └── It should distribute rewards to msg.sender using rewardsCalculator. +├── When setGovernanceVault is called +│ ├── When caller has SYSTEM_ROLE for governanceVault +│ │ ├── It should set the governanceVault address. +│ │ ├── It should approve lootToken with max allowance. +│ │ └── It should revert if vault or lootToken is zero. +│ └── When caller lacks SYSTEM_ROLE for governanceVault +│ └── It should revert. +├── When setPurchaseTracker is called +│ ├── When caller has SYSTEM_ROLE for purchaseTracker +│ │ ├── It should set the purchase tracker. +│ │ └── It should revert if address is zero. +│ └── When caller lacks SYSTEM_ROLE for purchaseTracker +│ └── It should revert. +├── When setCommunityRewardsCalculator is called +│ ├── When caller has SYSTEM_ROLE for rewardsCalculator +│ │ └── It should set the rewards calculator. +│ └── When caller lacks SYSTEM_ROLE for rewardsCalculator +│ └── It should revert. +└── When getBalance is called + └── It should return the correct token balance.