-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
7e9ae29
commit 46bfc75
Showing
4 changed files
with
96 additions
and
0 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,34 @@ | ||
// SPDX-License-Identifier: APACHE | ||
pragma solidity ^0.8.0; | ||
|
||
import {IERC20, IQWChild, IQWManager, IQWRegistry, QWManager, QWRegistry} from '../../src/contracts/QWManager.sol'; | ||
Check warning on line 4 in test/smock/MockQWManager.sol GitHub Actions / Lint Commit Messages
Check warning on line 4 in test/smock/MockQWManager.sol GitHub Actions / Lint Commit Messages
Check warning on line 4 in test/smock/MockQWManager.sol GitHub Actions / Lint Commit Messages
Check warning on line 4 in test/smock/MockQWManager.sol GitHub Actions / Lint Commit Messages
|
||
import {Test} from 'forge-std/Test.sol'; | ||
|
||
contract MockQWManager is QWManager, Test { | ||
constructor() QWManager() {} | ||
|
||
function mock_call_execute( | ||
address[] memory _targetQwChild, | ||
bytes[] memory _callData, | ||
address _tokenAddress, | ||
uint256 _amount | ||
) public { | ||
vm.mockCall( | ||
address(this), | ||
abi.encodeWithSignature( | ||
'execute(address[],bytes[],address,uint256)', _targetQwChild, _callData, _tokenAddress, _amount | ||
), | ||
abi.encode() | ||
); | ||
} | ||
|
||
function mock_call_close(address[] memory _targetQwChild, bytes[] memory _callData) public { | ||
vm.mockCall( | ||
address(this), abi.encodeWithSignature('close(address[],bytes[])', _targetQwChild, _callData), abi.encode() | ||
); | ||
} | ||
|
||
function mock_call_withdraw(address user, uint256 amount) public { | ||
vm.mockCall(address(this), abi.encodeWithSignature('withdraw(address,uint256)', user, amount), abi.encode()); | ||
} | ||
} |
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.0; | ||
|
||
import {IQWChild, IQWRegistry, QWRegistry} from '../../src/contracts/QWRegistry.sol'; | ||
import {Test} from 'forge-std/Test.sol'; | ||
|
||
contract MockQWRegistry is QWRegistry, Test { | ||
function set_whitelist(address _key0, bool _value) public { | ||
whitelist[_key0] = _value; | ||
} | ||
|
||
function mock_call_whitelist(address _key0, bool _value) public { | ||
vm.mockCall(address(this), abi.encodeWithSignature('whitelist(address)', _key0), abi.encode(_value)); | ||
} | ||
|
||
constructor(address _qwManager) QWRegistry(_qwManager) {} | ||
|
||
function mock_call_registerChild(address _child) public { | ||
vm.mockCall(address(this), abi.encodeWithSignature('registerChild(address)', _child), abi.encode()); | ||
} | ||
} |
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.0; | ||
|
||
import {Test} from 'forge-std/Test.sol'; | ||
|
||
contract SmockHelper is Test { | ||
function deployMock( | ||
string memory _label, | ||
bytes memory _creationCode, | ||
bytes memory _encodedArgs | ||
) internal returns (address _deployed) { | ||
bytes memory _bytecode = abi.encodePacked(_creationCode, _encodedArgs); | ||
assembly { | ||
mstore(0x0, _creationCode) | ||
_deployed := create2(0, add(_bytecode, 0x20), mload(_bytecode), 'Wonderland') | ||
} | ||
vm.label(_deployed, _label); | ||
vm.allowCheatcodes(_deployed); | ||
} | ||
} |
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.0; | ||
|
||
import {IERC20, IPool, IQWChild, QWAave} from '../../../src/contracts/child/QWAave.sol'; | ||
Check warning on line 4 in test/smock/child/MockQWAave.sol GitHub Actions / Lint Commit Messages
Check warning on line 4 in test/smock/child/MockQWAave.sol GitHub Actions / Lint Commit Messages
|
||
import {Test} from 'forge-std/Test.sol'; | ||
|
||
contract MockQWAave is QWAave, Test { | ||
constructor(address _qwManager, address _pool) QWAave(_qwManager, _pool) {} | ||
|
||
function mock_call_create(bytes memory _callData, address _tokenAddress, uint256 _amount, bool success) public { | ||
vm.mockCall( | ||
address(this), | ||
abi.encodeWithSignature('create(bytes,address,uint256)', _callData, _tokenAddress, _amount), | ||
abi.encode(success) | ||
); | ||
} | ||
|
||
function mock_call_close(bytes memory _callData, bool success) public { | ||
vm.mockCall(address(this), abi.encodeWithSignature('close(bytes)', _callData), abi.encode(success)); | ||
} | ||
} |