From 4636e8cc6f9103143bfcba46a166b91921995e88 Mon Sep 17 00:00:00 2001 From: gpsanant Date: Thu, 11 Jan 2024 09:22:35 -0800 Subject: [PATCH] feat: add tree and start on tests for op state ret --- test/tree/OperatorStateRetrieverUnit.tree | 35 ++++++++++++++++++++++ test/unit/OperatorStateRetrieverUnit.t.sol | 5 ++++ 2 files changed, 40 insertions(+) create mode 100644 test/tree/OperatorStateRetrieverUnit.tree diff --git a/test/tree/OperatorStateRetrieverUnit.tree b/test/tree/OperatorStateRetrieverUnit.tree new file mode 100644 index 00000000..fa901c13 --- /dev/null +++ b/test/tree/OperatorStateRetrieverUnit.tree @@ -0,0 +1,35 @@ +. +└── OperatorStateRetriever tree (*** denotes that integration tests are needed to validate path) + ├── when getOperatorState(IRegistryCoordinator,bytes32,uint32) is called + │ ├── when the given operator has never registered with the given registryCoordinator (their quorumBitmapHistory has length 0) + │ │ └── it should revert with "RegistryCoordinator.getQuorumBitmapIndicesAtBlockNumber: operator has no bitmap history at blockNumber" + │ └── when the given operator has registered for the first time with the given registryCoordinator + │ ├── after the given blockNumber + │ │ └── it should revert with "RegistryCoordinator.getQuorumBitmapIndicesAtBlockNumber: operator has no bitmap history at blockNumber" + │ └── before the given blockNumber + │ ├── and was not registered for any quorums at the given blockNumber + │ │ └── it should return (0, []) + │ └── and was registered for a set of quorums at the given blockNumber + │ └── it should return their quorum bitmap as the first argument and a list of the list of operators (by id and stake) ordered by index for each quorum in the set ascending by quorumNumber + ├── when getOperatorState(IRegistryCoordinator,bytes memory,uint32) is called + │ ├── when at any of the given quorumNumbers are not created at the time of call + │ │ └── it should revert with "IndexRegistry._operatorCountAtBlockNumber: quorum does not exist" + │ ├── when at any of the given quorumNumbers are not created before or at the given blockNumber + │ │ └── it should revert with "IndexRegistry._operatorCountAtBlockNumber: quorum did not exist at given block number" + │ └── when the given quorumNumbers are created on the given registry registryCoordinator + │ └── it should return their quorum bitmap as the first argument and a list of the list of operators (by id and stake) ordered by index for each quorum in the set ascending by quorumNumber + └── when getCheckSignaturesIndices is called + └── when any of the given nonSignerOperatorIds were never registered with the given registryCoordinator + ├── it should revert with "RegistryCoordinator.getQuorumBitmapIndicesAtBlockNumber: operator has no bitmap history" + ├── when any of the given operator has registered for the first time with the given registryCoordinator after the given blockNumber + │ └── it should revert with "RegistryCoordinator.getQuorumBitmapIndicesAtBlockNumber: operator has no bitmap history at blockNumber" + ├── when any of the given quorumNumbers are not created at the time of the call + │ └── it should revert with "StakeRegistry.getTotalStakeIndicesAtBlockNumber: quorum does not exist" + ├── when any of the given quorumNumbers were not created before or at the given blockNumber + │ └── it should revert with "StakeRegistry.getTotalStakeIndicesAtBlockNumber: quorum has no stake history at blockNumber" + └── otherwise + └── it should return + ├── a list of the indices of the QuorumBitmapUpdates at the given blockNumber for the given nonSignerOperatorIds in the inputted quorumNumber order as the first argument + ├── a list of the indices of the ApkUpdates at the given blockNumber for each quorum in the inputted quorumNumber order as the second argument + ├── a list of the indices of the StakeUpdates at the given blockNumber for the total stake for each quorum in the inputted quorumNumber order as the third argument + └── a list of (a list of the indices of the stakes of each operator in each of the quorums the operator was in at the blockNumber from lowest to greatest quorumNumber they were apart of) in the order of the inputted nonSigners \ No newline at end of file diff --git a/test/unit/OperatorStateRetrieverUnit.t.sol b/test/unit/OperatorStateRetrieverUnit.t.sol index eb85cc3f..12b77867 100644 --- a/test/unit/OperatorStateRetrieverUnit.t.sol +++ b/test/unit/OperatorStateRetrieverUnit.t.sol @@ -10,6 +10,11 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { _deployMockEigenLayerAndAVS(); } + function test_getOperatorState_revert_neverRegistered() public { + cheats.expectRevert("RegistryCoordinator.getQuorumBitmapIndexAtBlockNumber: no bitmap update found for operatorId at block number"); + operatorStateRetriever.getOperatorState(registryCoordinator, defaultOperatorId, uint32(block.number)); + } + function testGetOperatorState_Valid(uint256 pseudoRandomNumber) public { // register random operators and get the expected indices within the quorums and the metadata for the operators (