diff --git a/test/zkbob/ZkBobPool.t.sol b/test/zkbob/ZkBobPool.t.sol index 070e6dd..cea4040 100644 --- a/test/zkbob/ZkBobPool.t.sol +++ b/test/zkbob/ZkBobPool.t.sol @@ -175,16 +175,16 @@ abstract contract AbstractZkBobPoolTest is AbstractForkTest { address[] memory users = new address[](2); users[0] = operatorContract; users[1] = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); - accounting.setLimits( - 1, - 2_000_000 ether / D / denominator, - 200_000 ether / D / denominator, - 200_000 ether / D / denominator, - 20_000 ether / D / denominator, - 20_000 ether / D / denominator, - 25 ether / D / denominator, - 10 ether / D / denominator - ); + accounting.setLimits( + 1, + 2_000_000 ether / D / denominator, + 200_000 ether / D / denominator, + 200_000 ether / D / denominator, + 20_000 ether / D / denominator, + 20_000 ether / D / denominator, + 25 ether / D / denominator, + 10 ether / D / denominator + ); accounting.setUsersTier(1, users); } else { operatorManager = new MutableOperatorManager(user2, user3, "https://example.com"); diff --git a/test/zkbob/manager/MPCGuard.t.sol b/test/zkbob/manager/MPCGuard.t.sol index 1831dcc..e267390 100644 --- a/test/zkbob/manager/MPCGuard.t.sol +++ b/test/zkbob/manager/MPCGuard.t.sol @@ -9,11 +9,7 @@ import "../../shared/ForkTests.t.sol"; import "../../../src/zkbob/manager/MPCGuard.sol"; - -contract MPCOperatorManagerTest is - AbstractZkBobPoolTest, - AbstractPolygonForkTest -{ +contract MPCOperatorManagerTest is AbstractZkBobPoolTest, AbstractPolygonForkTest { constructor() { isMPC = true; D = 1; @@ -35,16 +31,12 @@ contract MPCOperatorManagerTest is } function testPermitDepositMPC() public { - bytes memory data = withMPC( - _encodePermitDeposit(0.1 ether, 0.01 ether) - ); //752 + bytes memory data = withMPC(_encodePermitDeposit(0.1 ether, 0.01 ether)); //752 _transactMPC(data); } function testTransferMPC() public { - bytes memory data = withMPC( - _encodePermitDeposit(0.1 ether, 0.01 ether) - ); //752 + bytes memory data = withMPC(_encodePermitDeposit(0.1 ether, 0.01 ether)); //752 _transactMPC(data); data = withMPC(_encodeTransfer(0.01 ether)); @@ -62,31 +54,24 @@ contract MPCOperatorManagerTest is address operator = makeAddr("operatorEOA"); address wrapper = operatorManager.operator(); vm.prank(operator); - (bool status, ) = address(wrapper).call(data); + (bool status,) = address(wrapper).call(data); require(status, "transact() reverted"); } function withMPC(bytes memory data) internal returns (bytes memory) { - ZkBobPool poolContract = ZkBobPool(address(pool)); uint256 current_root = poolContract.roots(poolContract.pool_index()); uint48 transfer_index = uint48(0); uint256 transfer_root = poolContract.roots(transfer_index); - bytes memory challenge = abi.encodePacked( - data, - transfer_root, - current_root, - poolContract.pool_id() - ); + bytes memory challenge = abi.encodePacked(data, transfer_root, current_root, poolContract.pool_id()); (, uint256 guard1Key) = makeAddrAndKey("guard1"); (, uint256 guard2Key) = makeAddrAndKey("guard2"); - return - abi.encodePacked( - data, - uint8(2), //753 - sign(challenge, guard1Key), //817 - sign(challenge, guard2Key) //881 - ); + return abi.encodePacked( + data, + uint8(2), //753 + sign(challenge, guard1Key), //817 + sign(challenge, guard2Key) //881 + ); } function testAppendDirectDepositsMPC() public { @@ -107,14 +92,10 @@ contract MPCOperatorManagerTest is bytes memory data = abi.encodePacked( outCommitment, bytes10(0xc2767ac851b6b1e19eda), // first deposit receiver zk address (42 bytes) - bytes32( - 0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef - ), + bytes32(0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef), uint64(9.9 ether / D / denominator), // first deposit amount bytes10(0xc2767ac851b6b1e19eda), // second deposit receiver zk address (42 bytes) - bytes32( - 0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef - ), + bytes32(0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef), uint64(4.9 ether / D / denominator), // second deposit amount new bytes(14 * 50) ); @@ -122,8 +103,9 @@ contract MPCOperatorManagerTest is verifier, abi.encodeWithSelector( IBatchDepositVerifier.verifyProof.selector, - [uint256(keccak256(data)) % - 21888242871839275222246405745257275088548364400416034343698204186575808495617] + [ + uint256(keccak256(data)) % 21888242871839275222246405745257275088548364400416034343698204186575808495617 + ] ) ); vm.expectEmit(true, false, false, true); @@ -132,15 +114,11 @@ contract MPCOperatorManagerTest is bytes4(0x02000001), // uint16(2) in little endian ++ MESSAGE_PREFIX_DIRECT_DEPOSIT_V1 uint64(0), // first deposit nonce bytes10(0xc2767ac851b6b1e19eda), // first deposit receiver zk address (42 bytes) - bytes32( - 0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef - ), + bytes32(0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef), uint64(9.9 ether / D / denominator), // first deposit amount uint64(1), // second deposit nonce bytes10(0xc2767ac851b6b1e19eda), // second deposit receiver zk address (42 bytes) - bytes32( - 0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef - ), + bytes32(0x2f6f6ef223959602c05afd2b73ea8952fe0a10ad19ed665b3ee5a0b0b9e4e3ef), uint64(4.9 ether / D / denominator) // second deposit amount ); // vm.expectEmit(true, false, false, true); @@ -171,22 +149,13 @@ contract MPCOperatorManagerTest is outCommitment, batch_deposit_proof, tree_proof, - abi.encodePacked( - sign(mpcMessage, guard1Key), - sign(mpcMessage, guard2Key) - ) + abi.encodePacked(sign(mpcMessage, guard1Key), sign(mpcMessage, guard2Key)) ); } - function sign( - bytes memory data, - uint256 key - ) internal pure returns (bytes memory signatureData) { + function sign(bytes memory data, uint256 key) internal pure returns (bytes memory signatureData) { bytes32 digest = ECDSA.toEthSignedMessageHash(keccak256(data)); (uint8 v, bytes32 r, bytes32 s) = vm.sign(key, digest); - signatureData = abi.encodePacked( - r, - uint256(s) + (v == 28 ? (1 << 255) : 0) - ); + signatureData = abi.encodePacked(r, uint256(s) + (v == 28 ? (1 << 255) : 0)); } }