@@ -649,4 +649,82 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer {
649
649
}
650
650
}
651
651
}
652
+
653
+ function test_getBatchOperatorId_emptyArray () public {
654
+ address [] memory operators = new address [](0 );
655
+ bytes32 [] memory operatorIds =
656
+ operatorStateRetriever.getBatchOperatorId (registryCoordinator, operators);
657
+ assertEq (operatorIds.length , 0 , "Should return empty array for empty input " );
658
+ }
659
+
660
+ function test_getBatchOperatorId_unregisteredOperators () public {
661
+ address [] memory operators = new address [](2 );
662
+ operators[0 ] = address (1 );
663
+ operators[1 ] = address (2 );
664
+
665
+ bytes32 [] memory operatorIds =
666
+ operatorStateRetriever.getBatchOperatorId (registryCoordinator, operators);
667
+
668
+ assertEq (operatorIds.length , 2 , "Should return array of same length as input " );
669
+ assertEq (operatorIds[0 ], bytes32 (0 ), "Unregistered operator should return 0 " );
670
+ assertEq (operatorIds[1 ], bytes32 (0 ), "Unregistered operator should return 0 " );
671
+ }
672
+
673
+ function test_getBatchOperatorId_mixedRegistration () public {
674
+ // Register one operator
675
+ cheats.roll (registrationBlockNumber);
676
+ _registerOperatorWithCoordinator (defaultOperator, 1 , defaultPubKey);
677
+
678
+ // Create test array with one registered and one unregistered operator
679
+ address [] memory operators = new address [](2 );
680
+ operators[0 ] = defaultOperator;
681
+ operators[1 ] = address (2 ); // unregistered
682
+
683
+ bytes32 [] memory operatorIds =
684
+ operatorStateRetriever.getBatchOperatorId (registryCoordinator, operators);
685
+
686
+ assertEq (operatorIds.length , 2 , "Should return array of same length as input " );
687
+ assertEq (
688
+ operatorIds[0 ], defaultOperatorId, "Should return correct ID for registered operator "
689
+ );
690
+ assertEq (operatorIds[1 ], bytes32 (0 ), "Should return 0 for unregistered operator " );
691
+ }
692
+
693
+ function test_getBatchOperatorFromId_emptyArray () public {
694
+ bytes32 [] memory operatorIds = new bytes32 [](0 );
695
+ address [] memory operators =
696
+ operatorStateRetriever.getBatchOperatorFromId (registryCoordinator, operatorIds);
697
+ assertEq (operators.length , 0 , "Should return empty array for empty input " );
698
+ }
699
+
700
+ function test_getBatchOperatorFromId_unregisteredIds () public {
701
+ bytes32 [] memory operatorIds = new bytes32 [](2 );
702
+ operatorIds[0 ] = bytes32 (uint256 (1 ));
703
+ operatorIds[1 ] = bytes32 (uint256 (2 ));
704
+
705
+ address [] memory operators =
706
+ operatorStateRetriever.getBatchOperatorFromId (registryCoordinator, operatorIds);
707
+
708
+ assertEq (operators.length , 2 , "Should return array of same length as input " );
709
+ assertEq (operators[0 ], address (0 ), "Unregistered ID should return address(0) " );
710
+ assertEq (operators[1 ], address (0 ), "Unregistered ID should return address(0) " );
711
+ }
712
+
713
+ function test_getBatchOperatorFromId_mixedRegistration () public {
714
+ // Register one operator
715
+ cheats.roll (registrationBlockNumber);
716
+ _registerOperatorWithCoordinator (defaultOperator, 1 , defaultPubKey);
717
+
718
+ // Create test array with one registered and one unregistered operator ID
719
+ bytes32 [] memory operatorIds = new bytes32 [](2 );
720
+ operatorIds[0 ] = defaultOperatorId;
721
+ operatorIds[1 ] = bytes32 (uint256 (2 )); // unregistered
722
+
723
+ address [] memory operators =
724
+ operatorStateRetriever.getBatchOperatorFromId (registryCoordinator, operatorIds);
725
+
726
+ assertEq (operators.length , 2 , "Should return array of same length as input " );
727
+ assertEq (operators[0 ], defaultOperator, "Should return correct address for registered ID " );
728
+ assertEq (operators[1 ], address (0 ), "Should return address(0) for unregistered ID " );
729
+ }
652
730
}
0 commit comments