-
Notifications
You must be signed in to change notification settings - Fork 30
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
4 changed files
with
63 additions
and
29 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
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
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 |
---|---|---|
@@ -1,39 +1,63 @@ | ||
pragma solidity ^0.8.15; | ||
import "forge-std/Test.sol"; | ||
import "../../../src/zkbob/manager/MPCOperatorManager.sol"; | ||
import "../ZkBobPool.t.sol"; | ||
import "../../shared/Env.t.sol"; | ||
|
||
import "../../shared/ForkTests.t.sol"; | ||
|
||
contract MPCOperatorManagerTest is | ||
AbstractZkBobPoolTest, | ||
AbstractPolygonForkTest | ||
{ | ||
address[] signers; | ||
|
||
constructor() { | ||
D = 1; | ||
token = address(0xB0B195aEFA3650A6908f15CdaC7D92F8a5791B0B); | ||
weth = address(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); | ||
tempToken = address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174); | ||
poolType = PoolType.BOB; | ||
autoApproveQueue = false; | ||
permitType = PermitType.BOBPermit; | ||
denominator = 1_000_000_000; | ||
precision = 1_000_000_000; | ||
} | ||
|
||
contract MPCOperatorManagerTest is Test { | ||
|
||
// MPCOperatorManager _manager; | ||
|
||
|
||
address bar = makeAddr("bar"); | ||
address signer1Addr; | ||
uint256 signer1Key; | ||
|
||
address[] signers ; | ||
function testIsOperator() public { | ||
address operator = makeAddr("operator"); | ||
|
||
function setUp() public { | ||
|
||
(signer1Addr, signer1Key) = makeAddrAndKey("signer1"); | ||
// (address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer2"); | ||
// (address signer3Addr, uint256 signer3Key) = makeAddrAndKey("signer3"); | ||
|
||
MPCOperatorManager _manager = new MPCOperatorManager( | ||
operator, | ||
operator, | ||
"_" | ||
); | ||
_manager.transferOwnership(operator); | ||
|
||
(address signer1Addr, uint256 signer1Key) = makeAddrAndKey("signer1"); | ||
(address signer2Addr, uint256 signer2Key) = makeAddrAndKey("signer1"); | ||
signers.push(signer1Addr); | ||
// signers.push(signer2Addr); | ||
// signers.push(signer3Addr); | ||
} | ||
signers.push(signer2Addr); | ||
vm.prank(operator); | ||
_manager.setSigners(signers); | ||
|
||
function testInit() public { | ||
bytes memory data = _encodeDeposit(1 ether, 0.1 ether); | ||
data = abi.encodePacked(data, uint8(2)); | ||
data = appendSignature(data, signer1Key); | ||
data = appendSignature(data, signer2Key); | ||
|
||
MPCOperatorManager _manager = new MPCOperatorManager(signer1Addr, signer1Addr, ""); | ||
assert(_manager.isOperator(operator)); | ||
|
||
// _manager.setSigners(_signers); | ||
// | ||
} | ||
|
||
function testIsOperator() public { | ||
// vm.prank(foo); | ||
|
||
function appendSignature(bytes memory data, uint256 key ) internal returns ( bytes memory updated ) { | ||
(uint8 v, bytes32 r, bytes32 s) = vm.sign( | ||
key, | ||
keccak256(data) | ||
); | ||
updated = abi.encodePacked(data, r, uint256(s) + (v == 28 ? (1 << 255) : 0)); | ||
} | ||
} |