@@ -98,6 +98,7 @@ import {
9898 assertMetaLength ,
9999 assertNoPendingAuthorizationExists ,
100100 assertStatIsSet ,
101+ assertTickerLengthValid ,
101102 assertTickerValid ,
102103 calculateNextKey ,
103104 calculateRawStakingPayee ,
@@ -1792,6 +1793,52 @@ describe('assertTickerValid', () => {
17921793 } ) ;
17931794} ) ;
17941795
1796+ describe ( 'assertTickerLengthValid' , ( ) => {
1797+ it ( 'should throw an error if the ticker length exceeds the chain configured max ticker length' , async ( ) => {
1798+ const context = dsMockUtils . getContextInstance ( ) ;
1799+ const maxTickerLength = new BigNumber ( 6 ) ;
1800+
1801+ dsMockUtils . createQueryMock ( 'asset' , 'tickerConfig' , {
1802+ returnValue : dsMockUtils . createMockTickerRegistrationConfig ( {
1803+ maxTickerLength : dsMockUtils . createMockU8 ( maxTickerLength ) ,
1804+ registrationLength : dsMockUtils . createMockOption ( ) ,
1805+ } ) ,
1806+ } ) ;
1807+
1808+ await expect ( assertTickerLengthValid ( 'TOO_LONG' , context ) ) . rejects . toThrow (
1809+ `Ticker length must be between 1 and ${ maxTickerLength . toString ( ) } characters`
1810+ ) ;
1811+ } ) ;
1812+
1813+ it ( 'should throw an error if the ticker is empty' , async ( ) => {
1814+ const context = dsMockUtils . getContextInstance ( ) ;
1815+
1816+ dsMockUtils . createQueryMock ( 'asset' , 'tickerConfig' , {
1817+ returnValue : dsMockUtils . createMockTickerRegistrationConfig ( {
1818+ maxTickerLength : dsMockUtils . createMockU8 ( new BigNumber ( 12 ) ) ,
1819+ registrationLength : dsMockUtils . createMockOption ( ) ,
1820+ } ) ,
1821+ } ) ;
1822+
1823+ await expect ( assertTickerLengthValid ( '' , context ) ) . rejects . toThrow (
1824+ 'Ticker length must be between 1 and 12 characters'
1825+ ) ;
1826+ } ) ;
1827+
1828+ it ( 'should not throw an error if the ticker length is within the chain configured max ticker length' , async ( ) => {
1829+ const context = dsMockUtils . getContextInstance ( ) ;
1830+
1831+ dsMockUtils . createQueryMock ( 'asset' , 'tickerConfig' , {
1832+ returnValue : dsMockUtils . createMockTickerRegistrationConfig ( {
1833+ maxTickerLength : dsMockUtils . createMockU8 ( new BigNumber ( 12 ) ) ,
1834+ registrationLength : dsMockUtils . createMockOption ( ) ,
1835+ } ) ,
1836+ } ) ;
1837+
1838+ await expect ( assertTickerLengthValid ( 'FAKE_TICKER' , context ) ) . resolves . not . toThrow ( ) ;
1839+ } ) ;
1840+ } ) ;
1841+
17951842describe ( 'neededStatTypeForRestrictionInput' , ( ) => {
17961843 beforeAll ( ( ) => {
17971844 dsMockUtils . initMocks ( ) ;
0 commit comments