@@ -299,6 +299,19 @@ public void InitializeOwner_UpdateInitializesWhenOwnerMissing()
299299 Merge ( contract ) ;
300300 }
301301
302+ [ TestMethod ]
303+ public void InitializeOwner_UpdateWithUnmarkedOwner_Aborts ( )
304+ {
305+ var engine = CreateEngine ( ) ;
306+ var contract = Deploy ( engine , out _ , out _ ) ;
307+
308+ contract . SetOwnerWithoutInitializedForTest ( Bob . Account ) ;
309+
310+ Assert . ThrowsException < TestException > ( ( ) => contract . InitializeForTest ( Charlie . Account , true ) ) ;
311+ Assert . AreEqual ( Bob . Account , contract . GetOwner ( ) ) ;
312+ Merge ( contract ) ;
313+ }
314+
302315 [ TestMethod ]
303316 public void InitializeOwner_UpdateDoesNotReinitializeAfterRenounce ( )
304317 {
@@ -438,6 +451,12 @@ public static void ClearOwnershipStateForTest()
438451 Storage.Delete(new byte[] { 0xFD });
439452 Storage.Delete(new byte[] { 0xFB });
440453 }
454+
455+ public static void SetOwnerWithoutInitializedForTest(UInt160 owner)
456+ {
457+ Storage.Put(new byte[] { 0xFD }, owner);
458+ Storage.Delete(new byte[] { 0xFB });
459+ }
441460}" ;
442461
443462 var tempFile = Path . Combine ( Path . GetTempPath ( ) , $ "{ Guid . NewGuid ( ) : N} .cs") ;
@@ -503,6 +522,9 @@ public abstract class OwnableTwoStepProxy(SmartContractInitialize initialize)
503522 [ DisplayName ( "clearOwnershipStateForTest" ) ]
504523 public abstract void ClearOwnershipStateForTest ( ) ;
505524
525+ [ DisplayName ( "setOwnerWithoutInitializedForTest" ) ]
526+ public abstract void SetOwnerWithoutInitializedForTest ( UInt160 owner ) ;
527+
506528 [ DisplayName ( "transferOwnership" ) ]
507529 public abstract void TransferOwnership ( UInt160 newOwner ) ;
508530
0 commit comments