11// SPDX-License-Identifier: Apache-2.0
22pragma solidity 0.8.26 ;
33
4- import {Test, console2 } from "forge-std/Test.sol " ;
4+ import {Test} from "forge-std/Test.sol " ;
55import {QueryTypeStakerFactory} from "src/QueryTypeStakerFactory.sol " ;
66import {QueryTypeStakingPool} from "src/QueryTypeStakingPool.sol " ;
77import {VmSafe} from "forge-std/Vm.sol " ;
@@ -20,9 +20,8 @@ contract QueryTypeStakerFactoryTest is Test {
2020 queryType = bytes32 (uint256 (1 ));
2121 }
2222
23- function _createPool () internal returns (address ) {
24- vm.prank (owner);
25- return factory.createStakingPool (queryType, owner, bytes32 (0 ));
23+ function _assumeSafeDecayRate (uint8 _decayRate ) internal pure returns (uint8 ) {
24+ return uint8 (bound (_decayRate, 0 , 100 ));
2625 }
2726}
2827
@@ -58,26 +57,33 @@ contract CreateStakingPool is QueryTypeStakerFactoryTest {
5857 function testFuzz_CreatesNewStakingPoolWithArbitraryQueryType (
5958 bytes32 _queryType ,
6059 address _poolOwner ,
61- bytes32 _initialEntry
60+ bytes32 _initialEntry ,
61+ uint8 _decayRate
6262 ) public {
63+ _decayRate = _assumeSafeDecayRate (_decayRate);
6364 vm.assume (_poolOwner != address (0 ));
6465 vm.prank (owner);
65- address poolAddress = factory.createStakingPool (_queryType, _poolOwner, _initialEntry);
66+ address poolAddress =
67+ factory.createStakingPool (_queryType, _poolOwner, _initialEntry, _decayRate);
6668
6769 assertTrue (poolAddress != address (0 ));
6870 assertEq (factory.queryTypePools (_queryType), poolAddress);
6971 assertEq (QueryTypeStakingPool (poolAddress).owner (), _poolOwner);
72+ assertEq (QueryTypeStakingPool (poolAddress).DECAY_RATE (), _decayRate);
7073 }
7174
7275 function testFuzz_EmitsCreateQueryTypeStakingPoolEventWithArbitraryQueryType (
7376 bytes32 _queryType ,
7477 address _poolOwner ,
75- bytes32 _initialEntry
78+ bytes32 _initialEntry ,
79+ uint8 _decayRate
7680 ) public {
81+ _decayRate = _assumeSafeDecayRate (_decayRate);
7782 vm.assume (_poolOwner != address (0 ));
7883 vm.recordLogs ();
7984 vm.prank (owner);
80- address poolAddress = factory.createStakingPool (_queryType, _poolOwner, _initialEntry);
85+ address poolAddress =
86+ factory.createStakingPool (_queryType, _poolOwner, _initialEntry, _decayRate);
8187
8288 VmSafe.Log[] memory entries = vm.getRecordedLogs ();
8389 assertEq (entries[2 ].topics[0 ], keccak256 ("CreateQueryTypeStakingPool(bytes32,address) " ));
@@ -88,27 +94,31 @@ contract CreateStakingPool is QueryTypeStakerFactoryTest {
8894 function testFuzz_RevertIf_CallerIsNotOwner (
8995 address _notOwner ,
9096 address _poolOwner ,
91- bytes32 _initialEntry
97+ bytes32 _initialEntry ,
98+ uint8 _decayRate
9299 ) public {
100+ _decayRate = _assumeSafeDecayRate (_decayRate);
93101 vm.assume (_notOwner != owner && _notOwner != address (0 ));
94102 vm.assume (_poolOwner != address (0 ));
95103
96104 vm.prank (_notOwner);
97105 vm.expectRevert (abi.encodeWithSignature ("OwnableUnauthorizedAccount(address) " , _notOwner));
98- factory.createStakingPool (queryType, _poolOwner, _initialEntry);
106+ factory.createStakingPool (queryType, _poolOwner, _initialEntry, _decayRate );
99107 }
100108
101109 function testFuzz_RevertIf_PoolAlreadyExistsWithArbitraryQueryType (
102110 bytes32 _queryType ,
103111 address _poolOwner ,
104- bytes32 _initialEntry
112+ bytes32 _initialEntry ,
113+ uint8 _decayRate
105114 ) public {
115+ _decayRate = _assumeSafeDecayRate (_decayRate);
106116 vm.assume (_poolOwner != address (0 ));
107117 vm.startPrank (owner);
108- factory.createStakingPool (_queryType, _poolOwner, _initialEntry);
118+ factory.createStakingPool (_queryType, _poolOwner, _initialEntry, _decayRate );
109119
110120 vm.expectRevert (QueryTypeStakerFactory.QueryTypeStakerFactory__PoolExists.selector );
111- factory.createStakingPool (_queryType, _poolOwner, _initialEntry);
121+ factory.createStakingPool (_queryType, _poolOwner, _initialEntry, _decayRate );
112122 vm.stopPrank ();
113123 }
114124}
0 commit comments