@@ -38,6 +38,13 @@ describe('Ownership Transfer Caveat', () => {
3838 let bobSmartAccount : MetaMaskSmartAccount ;
3939 let contractAddress : Address ;
4040
41+ /**
42+ * These tests verify the OwnershipTransferEnforcer behavior:
43+ * - Allows ownership transfer ONLY to the specific contract address in the delegation terms
44+ * - Allows transfer to the requested newOwner address (does NOT force transfer to redeemer)
45+ * - Rejects attempts to transfer ownership of unauthorized contracts
46+ */
47+
4148 beforeEach ( async ( ) => {
4249 // Create Alice's smart account
4350 const alicePrivateKey = generatePrivateKey ( ) ;
@@ -92,6 +99,9 @@ describe('Ownership Transfer Caveat', () => {
9299 const environment = delegator . environment ;
93100 const delegatorAddress = delegator . address ;
94101
102+ // Store initial owner to verify transfer happened
103+ const initialOwner = await getContractOwner ( contractAddress ) ;
104+
95105 const delegation = createDelegation ( {
96106 to : delegate ,
97107 from : delegatorAddress ,
@@ -140,9 +150,17 @@ describe('Ownership Transfer Caveat', () => {
140150
141151 await expectUserOperationToSucceed ( userOpHash ) ;
142152
143- // Verify ownership was transferred
153+ // Verify ownership was transferred successfully
144154 const finalOwner = await getContractOwner ( contractAddress ) ;
155+
156+ // The ownership should have changed from the initial owner
157+ expect ( finalOwner ) . not . toBe ( initialOwner ) ;
158+
159+ // The OwnershipTransferEnforcer allows transfer to the requested newOwner address
145160 expect ( finalOwner ) . toBe ( newOwner ) ;
161+
162+ // Additional validation: ensure it's a valid Ethereum address
163+ expect ( finalOwner ) . toMatch ( / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / ) ;
146164 } ;
147165
148166 const runTest_expectFailure = async (
@@ -238,6 +256,9 @@ describe('Ownership Transfer Caveat', () => {
238256 contractAddress : Address ,
239257 newOwner : Address ,
240258 ) => {
259+ // Store initial owner to verify transfer happened
260+ const initialOwner = await getContractOwner ( contractAddress ) ;
261+
241262 const delegation = createDelegation ( {
242263 environment : aliceSmartAccount . environment ,
243264 to : bobSmartAccount . address ,
@@ -285,9 +306,17 @@ describe('Ownership Transfer Caveat', () => {
285306
286307 await expectUserOperationToSucceed ( userOpHash ) ;
287308
288- // Verify ownership was transferred
309+ // Verify ownership was transferred successfully
289310 const finalOwner = await getContractOwner ( contractAddress ) ;
311+
312+ // The ownership should have changed from the initial owner
313+ expect ( finalOwner ) . not . toBe ( initialOwner ) ;
314+
315+ // The OwnershipTransferEnforcer allows transfer to the requested newOwner address
290316 expect ( finalOwner ) . toBe ( newOwner ) ;
317+
318+ // Additional validation: ensure it's a valid Ethereum address
319+ expect ( finalOwner ) . toMatch ( / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / ) ;
291320 } ;
292321
293322 const runScopeTest_expectFailure = async (
0 commit comments