99 createToken ,
1010 createTokenMapUsingConfigDetails ,
1111 createTokenMapUsingTrimmedConfigDetails ,
12+ createTokenUsingTrimmedConfigDetails ,
1213 EosCoin ,
1314 Erc20Coin ,
1415 EthereumNetwork ,
@@ -1165,6 +1166,7 @@ describe('create token map using config details', () => {
11651166 JSON . stringify ( tokenNetwork ) . should . eql ( JSON . stringify ( staticNetwork ) ) ;
11661167 } ) ;
11671168 } ) ;
1169+
11681170 it ( 'should give precedence to static coin map over ams coin map' , ( ) => {
11691171 const tokenMap = createTokenMapUsingConfigDetails ( incorrectAmsTokenConfig ) ;
11701172 const tokenName = 'thbar:usdc' ;
@@ -1174,6 +1176,7 @@ describe('create token map using config details', () => {
11741176 token . decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
11751177 token . baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
11761178 } ) ;
1179+
11771180 it ( 'should create a coin map and get formatted tokens from it' , ( ) => {
11781181 const coinMap = createTokenMapUsingConfigDetails ( amsTokenConfigWithCustomToken ) ;
11791182 const formattedTokens = getFormattedTokens ( coinMap ) ;
@@ -1182,10 +1185,12 @@ describe('create token map using config details', () => {
11821185 formattedTokens . testnet . eth . tokens . some ( ( token ) => token . type === 'hteth:faketoken' ) . should . eql ( true ) ;
11831186 formattedTokens . testnet . ofc . tokens . some ( ( token ) => token . type === 'ofcterc2' ) . should . eql ( true ) ;
11841187 } ) ;
1188+
11851189 it ( 'should not create an base coin object in coin map for token with unsupported network' , ( ) => {
11861190 const tokenMap = createTokenMapUsingTrimmedConfigDetails ( amsTokenWithUnsupportedNetwork ) ;
11871191 tokenMap . has ( 'hteth:faketoken' ) . should . eql ( false ) ;
11881192 } ) ;
1193+
11891194 it ( 'should create a coin map using reduced token config details' , ( ) => {
11901195 const coinMap1 = createTokenMapUsingTrimmedConfigDetails ( reducedAmsTokenConfig ) ;
11911196 const amsToken1 = coinMap1 . get ( 'hteth:faketoken' ) ;
@@ -1202,6 +1207,7 @@ describe('create token map using config details', () => {
12021207 JSON . stringify ( tokenNetwork1 ) . should . eql ( JSON . stringify ( tokenNetwork2 ) ) ;
12031208 JSON . stringify ( tokenNetwork3 ) . should . eql ( JSON . stringify ( tokenNetwork4 ) ) ;
12041209 } ) ;
1210+
12051211 it ( 'should be able to add single ams token into coin map' , ( ) => {
12061212 const coinMap = CoinMap . fromCoins ( [ ] ) ;
12071213 const staticsCoin = createToken ( amsTokenConfigWithCustomToken [ 'hteth:faketoken' ] [ 0 ] ) ;
@@ -1210,6 +1216,7 @@ describe('create token map using config details', () => {
12101216 }
12111217 coinMap . has ( 'hteth:faketoken' ) . should . be . true ( ) ;
12121218 } ) ;
1219+
12131220 it ( 'should be able to create token config of a single base coin' , ( ) => {
12141221 const tokenName = 'hteth:faketoken' ;
12151222 const coinMap = createTokenMapUsingTrimmedConfigDetails ( reducedAmsTokenConfig ) ;
@@ -1225,14 +1232,27 @@ describe('create token map using config details', () => {
12251232 decimalPlaces : amsTokenConfig . decimalPlaces ,
12261233 tokenContractAddress : amsTokenConfig . contractAddress . toLowerCase ( ) ,
12271234 } ) ;
1228- it ( 'should return the base coin present in default coin map' , ( ) => {
1229- const tokenName = 'thbar:usdc' ;
1230- const token = createToken ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] ) ;
1231- token ?. should . not . be . undefined ( ) ;
1232- token ?. decimalPlaces . should . eql ( coins . get ( tokenName ) . decimalPlaces ) ;
1233- token ?. baseUnit . should . eql ( coins . get ( tokenName ) . baseUnit ) ;
1234- token ?. decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
1235- token ?. baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
1236- } ) ;
1235+ } ) ;
1236+
1237+ it ( 'should return the base coin present in default coin map' , ( ) => {
1238+ const tokenName = 'thbar:usdc' ;
1239+ const token = createToken ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] ) ;
1240+ token ?. should . not . be . undefined ( ) ;
1241+ token ?. decimalPlaces . should . eql ( coins . get ( tokenName ) . decimalPlaces ) ;
1242+ token ?. baseUnit . should . eql ( coins . get ( tokenName ) . baseUnit ) ;
1243+ token ?. decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
1244+ token ?. baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
1245+ } ) ;
1246+
1247+ it ( 'should be able to create base coin from trimmed token config' , ( ) => {
1248+ const tokenName = 'hteth:faketoken' ;
1249+ const reducedTokenConfig = reducedAmsTokenConfig [ tokenName ] [ 0 ] ;
1250+ const token = createTokenUsingTrimmedConfigDetails ( reducedTokenConfig ) ;
1251+ token ?. should . not . be . undefined ( ) ;
1252+ token ?. name . should . eql ( reducedTokenConfig . name ) ;
1253+ token ?. decimalPlaces . should . eql ( reducedTokenConfig . decimalPlaces ) ;
1254+ const bgerchToken = coins . get ( 'bgerch' ) ;
1255+ const bgerchNetwork = bgerchToken ?. network ;
1256+ JSON . stringify ( bgerchNetwork ) . should . eql ( JSON . stringify ( token ?. network ) ) ;
12371257 } ) ;
12381258} ) ;
0 commit comments