@@ -21,6 +21,7 @@ func RunTests(t *testing.T, s currency.Store, teardown func()) {
2121 testMetadataSaveWithVersioning ,
2222 testMetadataUniqueNameConstraint ,
2323 testIsNameAvailable ,
24+ testAbandonedCurrencyNameReuse ,
2425 testGetAllMetadataByState ,
2526 testGetAllMints ,
2627 testCountMints ,
@@ -349,6 +350,114 @@ func testIsNameAvailable(t *testing.T, s currency.Store) {
349350 assert .True (t , available )
350351}
351352
353+ func testAbandonedCurrencyNameReuse (t * testing.T , s currency.Store ) {
354+ ctx := context .Background ()
355+
356+ record := & currency.MetadataRecord {
357+ Name : "AbandonedCurrency" ,
358+ Symbol : "AB1" ,
359+ Description : "A currency that will be abandoned" ,
360+ ImageUrl : "https://example.com/ab1.png" ,
361+ BillColors : []string {"#000000" },
362+ SocialLinks : []currency.SocialLink {{Type : currency .SocialLinkTypeWebsite , Value : "https://example.com" }},
363+
364+ Seed : "abandonedseed1" ,
365+ Authority : "abandonedauth1" ,
366+
367+ Mint : "abandonedmint111111111111111111111111111111111" ,
368+ MintBump : 255 ,
369+ Decimals : currencycreator .DefaultMintDecimals ,
370+
371+ CurrencyConfig : "abandonedconfig1111111111111111111111111111" ,
372+ CurrencyConfigBump : 255 ,
373+
374+ LiquidityPool : "abandonedpool11111111111111111111111111111111" ,
375+ LiquidityPoolBump : 255 ,
376+
377+ VaultMint : "abandonedvmint1111111111111111111111111111111" ,
378+ VaultMintBump : 255 ,
379+
380+ VaultCore : "abandonedvcore1111111111111111111111111111111" ,
381+ VaultCoreBump : 255 ,
382+
383+ SellFeeBps : currencycreator .DefaultSellFeeBps ,
384+
385+ Alt : "abandonedalt1111111111111111111111111111111111" ,
386+
387+ CreatedBy : "abandonedcreator1" ,
388+ CreatedAt : time .Now (),
389+ }
390+
391+ require .NoError (t , s .SaveMetadata (ctx , record ))
392+
393+ // Name should not be available while active
394+ available , err := s .IsNameAvailable (ctx , "AbandonedCurrency" )
395+ require .NoError (t , err )
396+ assert .False (t , available )
397+
398+ // Case-insensitive should also not be available
399+ available , err = s .IsNameAvailable (ctx , "abandonedcurrency" )
400+ require .NoError (t , err )
401+ assert .False (t , available )
402+
403+ // Transition to abandoned state
404+ record .State = currency .MetadataStateAbandoned
405+ require .NoError (t , s .SaveMetadata (ctx , record ))
406+
407+ // Name should now be available
408+ available , err = s .IsNameAvailable (ctx , "AbandonedCurrency" )
409+ require .NoError (t , err )
410+ assert .True (t , available )
411+
412+ // Case-insensitive should also be available
413+ available , err = s .IsNameAvailable (ctx , "abandonedcurrency" )
414+ require .NoError (t , err )
415+ assert .True (t , available )
416+
417+ // Should be able to create a new currency with the same name
418+ record2 := & currency.MetadataRecord {
419+ Name : "AbandonedCurrency" ,
420+ Symbol : "AB2" ,
421+ Description : "Reusing the abandoned name" ,
422+ ImageUrl : "https://example.com/ab2.png" ,
423+ BillColors : []string {"#FFFFFF" },
424+ SocialLinks : []currency.SocialLink {{Type : currency .SocialLinkTypeWebsite , Value : "https://example2.com" }},
425+
426+ Seed : "abandonedseed2" ,
427+ Authority : "abandonedauth2" ,
428+
429+ Mint : "abandonedmint222222222222222222222222222222222" ,
430+ MintBump : 255 ,
431+ Decimals : currencycreator .DefaultMintDecimals ,
432+
433+ CurrencyConfig : "abandonedconfig2222222222222222222222222222" ,
434+ CurrencyConfigBump : 255 ,
435+
436+ LiquidityPool : "abandonedpool22222222222222222222222222222222" ,
437+ LiquidityPoolBump : 255 ,
438+
439+ VaultMint : "abandonedvmint2222222222222222222222222222222" ,
440+ VaultMintBump : 255 ,
441+
442+ VaultCore : "abandonedvcore2222222222222222222222222222222" ,
443+ VaultCoreBump : 255 ,
444+
445+ SellFeeBps : currencycreator .DefaultSellFeeBps ,
446+
447+ Alt : "abandonedalt2222222222222222222222222222222222" ,
448+
449+ CreatedBy : "abandonedcreator2" ,
450+ CreatedAt : time .Now (),
451+ }
452+
453+ require .NoError (t , s .SaveMetadata (ctx , record2 ))
454+
455+ // New currency's name should no longer be available
456+ available , err = s .IsNameAvailable (ctx , "AbandonedCurrency" )
457+ require .NoError (t , err )
458+ assert .False (t , available )
459+ }
460+
352461func testGetAllMetadataByState (t * testing.T , s currency.Store ) {
353462 t .Run ("testGetAllMetadataByState" , func (t * testing.T ) {
354463 ctx := context .Background ()
0 commit comments