Skip to content

Commit

Permalink
mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Oct 9, 2024
1 parent 46a39d5 commit 1ed4378
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/test/layer1/preconf/Lookahead.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ import "test/shared/TaikoTest.sol";
// require(_lookaheadBufferSize % LibEpoch.SLOTS_IN_EPOCH == 0, InvalidParam());

contract LookaheadTest is TaikoTest {
// Lookahead lookahead = new Lookahead();
// Lookahead lookahead = new Lookahead();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ pragma solidity ^0.8.24;
import "src/layer1/preconf/iface/IPreconfRegistry.sol";

contract MockPreconfRegistry {
mapping(address preconfer => uint256 index) internal preconferToIndex;
mapping(uint256 index => address preconfer) internal indexToPreconfer;
mapping(bytes32 pubKeyhash => IPreconfRegistry.Validator validator) internal validators;
mapping(address preconfer => uint256 index) public getPreconferIndex;
mapping(uint256 index => address preconfer) internal getPreconferAtIndex;
mapping(bytes32 pubKeyhash => IPreconfRegistry.Validator validator) internal getValidator;

uint256 internal nextPreconferIndex = 1;

function registerPreconfer(address preconfer) external {
preconferToIndex[preconfer] = nextPreconferIndex;
indexToPreconfer[nextPreconferIndex++] = preconfer;
getPreconferIndex[preconfer] = nextPreconferIndex;
getPreconferAtIndex[nextPreconferIndex++] = preconfer;
}

function addValidator(
Expand All @@ -24,26 +24,10 @@ contract MockPreconfRegistry {
external
{
bytes32 key = keccak256(abi.encodePacked(bytes16(0), pubKey));
validators[key] = IPreconfRegistry.Validator(preconfer, validSince, validUntil);
getValidator[key] = IPreconfRegistry.Validator(preconfer, validSince, validUntil);
}

function getNextPreconferIndex() external view returns (uint256) {
return nextPreconferIndex;
}

function getPreconferIndex(address preconfer) external view returns (uint256) {
return preconferToIndex[preconfer];
}

function getPreconferAtIndex(uint256 index) external view returns (address) {
return indexToPreconfer[index];
}

function getValidator(bytes32 pubKeyHash)
external
view
returns (IPreconfRegistry.Validator memory)
{
return validators[pubKeyHash];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract MockPreconfServiceManager {
mapping(address => uint256) public stakeLockTimestamps;
mapping(address => bool) public operatorSlashed;

function lockStakeUntil(address operator, uint256 timestamp) external {
stakeLockTimestamps[operator] = timestamp;
}

function slashOperator(address operator) external {
operatorSlashed[operator] = true;
}
}

0 comments on commit 1ed4378

Please sign in to comment.