@@ -35,7 +35,7 @@ contract BatchInbox_Test is Test {
3535
3636 function setUp () public virtual {
3737 authenticator = new MockBatchAuthenticator ();
38- inbox = new BatchInbox (nonTeeBatcher, IBatchAuthenticator (address (authenticator)));
38+ inbox = new BatchInbox (nonTeeBatcher, IBatchAuthenticator (address (authenticator)), deployer );
3939 }
4040}
4141
@@ -44,16 +44,17 @@ contract BatchInbox_Test is Test {
4444contract BatchInbox_Constructor_Test is Test {
4545 address nonTeeBatcher = address (0x5678 );
4646 address batchAuthenticator = address (0x9ABC );
47+ address owner = address (0xABCD );
4748
4849 /// @notice Test that constructor reverts when non-TEE batcher is zero address
4950 function test_constructor_revertsWhenNonTeeBatcherIsZero () external {
5051 vm.expectRevert ("BatchInbox: zero address for non tee batcher " );
51- new BatchInbox (address (0 ), IBatchAuthenticator (batchAuthenticator));
52+ new BatchInbox (address (0 ), IBatchAuthenticator (batchAuthenticator), owner );
5253 }
5354
5455 /// @notice Test that constructor succeeds with valid addresses
5556 function test_constructor_succeedsWithValidAddresses () external {
56- BatchInbox testInbox = new BatchInbox (nonTeeBatcher, IBatchAuthenticator (batchAuthenticator));
57+ BatchInbox testInbox = new BatchInbox (nonTeeBatcher, IBatchAuthenticator (batchAuthenticator), owner );
5758
5859 assertEq (testInbox.nonTeeBatcher (), nonTeeBatcher, "Non-TEE batcher should match " );
5960 assertEq (address (testInbox.batchAuthenticator ()), batchAuthenticator, "Batch authenticator should match " );
@@ -70,13 +71,25 @@ contract BatchInbox_SwitchBatcher_Test is BatchInbox_Test {
7071 assertTrue (inbox.activeIsTee (), "Should start with TEE batcher active " );
7172
7273 // Switch to non-TEE batcher
74+ vm.prank (deployer);
7375 inbox.switchBatcher ();
7476 assertFalse (inbox.activeIsTee (), "Should switch to non-TEE batcher " );
7577
7678 // Switch back to TEE batcher
79+ vm.prank (deployer);
7780 inbox.switchBatcher ();
7881 assertTrue (inbox.activeIsTee (), "Should switch back to TEE batcher " );
7982 }
83+
84+ /// @notice Test that only the owner can switch the active batcher
85+ function test_switchBatcher_revertsForNonOwner () external {
86+ // Initially TEE batcher is active
87+ assertTrue (inbox.activeIsTee (), "Should start with TEE batcher active " );
88+
89+ vm.prank (unauthorized);
90+ vm.expectRevert ("Ownable: caller is not the owner " );
91+ inbox.switchBatcher ();
92+ }
8093}
8194
8295/// @title BatchInbox_Fallback_Test
@@ -85,6 +98,7 @@ contract BatchInbox_Fallback_Test is BatchInbox_Test {
8598 /// @notice Test that non-TEE batcher can post after switching
8699 function test_fallback_nonTeeBatcherCanPostAfterSwitch () external {
87100 // Switch to non-TEE batcher
101+ vm.prank (deployer);
88102 inbox.switchBatcher ();
89103
90104 // Non-TEE batcher should be able to post
@@ -96,6 +110,7 @@ contract BatchInbox_Fallback_Test is BatchInbox_Test {
96110 /// @notice Test that inactive batcher reverts
97111 function test_fallback_inactiveBatcherReverts () external {
98112 // Switch to non-TEE batcher (making TEE batcher inactive)
113+ vm.prank (deployer);
99114 inbox.switchBatcher ();
100115
101116 // TEE batcher (now inactive) should revert
@@ -143,6 +158,7 @@ contract BatchInbox_Fallback_Test is BatchInbox_Test {
143158 /// @notice Test that non-TEE batcher doesn't require authentication
144159 function test_fallback_nonTeeBatcherDoesNotRequireAuth () external {
145160 // Switch to non-TEE batcher
161+ vm.prank (deployer);
146162 inbox.switchBatcher ();
147163
148164 bytes memory data = "no-auth-needed " ;
@@ -157,6 +173,7 @@ contract BatchInbox_Fallback_Test is BatchInbox_Test {
157173 /// @notice Test that unauthorized address cannot post
158174 function test_fallback_unauthorizedAddressReverts () external {
159175 // Switch to non-TEE batcher. In this case the batch inbox should revert if the batcher is not authorized.
176+ vm.prank (deployer);
160177 inbox.switchBatcher ();
161178 vm.prank (unauthorized);
162179 (bool success ,) = address (inbox).call ("unauthorized " );
0 commit comments