99 createToken ,
1010 createTokenMapUsingConfigDetails ,
1111 createTokenMapUsingTrimmedConfigDetails ,
12+ createTokenUsingTrimmedConfigDetails ,
1213 EosCoin ,
1314 Erc20Coin ,
1415 EthereumNetwork ,
@@ -1162,6 +1163,7 @@ describe('create token map using config details', () => {
11621163 JSON . stringify ( tokenNetwork ) . should . eql ( JSON . stringify ( staticNetwork ) ) ;
11631164 } ) ;
11641165 } ) ;
1166+
11651167 it ( 'should give precedence to static coin map over ams coin map' , ( ) => {
11661168 const tokenMap = createTokenMapUsingConfigDetails ( incorrectAmsTokenConfig ) ;
11671169 const tokenName = 'thbar:usdc' ;
@@ -1171,6 +1173,7 @@ describe('create token map using config details', () => {
11711173 token . decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
11721174 token . baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
11731175 } ) ;
1176+
11741177 it ( 'should create a coin map and get formatted tokens from it' , ( ) => {
11751178 const coinMap = createTokenMapUsingConfigDetails ( amsTokenConfigWithCustomToken ) ;
11761179 const formattedTokens = getFormattedTokens ( coinMap ) ;
@@ -1179,10 +1182,12 @@ describe('create token map using config details', () => {
11791182 formattedTokens . testnet . eth . tokens . some ( ( token ) => token . type === 'hteth:faketoken' ) . should . eql ( true ) ;
11801183 formattedTokens . testnet . ofc . tokens . some ( ( token ) => token . type === 'ofcterc2' ) . should . eql ( true ) ;
11811184 } ) ;
1185+
11821186 it ( 'should not create an base coin object in coin map for token with unsupported network' , ( ) => {
11831187 const tokenMap = createTokenMapUsingTrimmedConfigDetails ( amsTokenWithUnsupportedNetwork ) ;
11841188 tokenMap . has ( 'hteth:faketoken' ) . should . eql ( false ) ;
11851189 } ) ;
1190+
11861191 it ( 'should create a coin map using reduced token config details' , ( ) => {
11871192 const coinMap1 = createTokenMapUsingTrimmedConfigDetails ( reducedAmsTokenConfig ) ;
11881193 const amsToken1 = coinMap1 . get ( 'hteth:faketoken' ) ;
@@ -1199,6 +1204,7 @@ describe('create token map using config details', () => {
11991204 JSON . stringify ( tokenNetwork1 ) . should . eql ( JSON . stringify ( tokenNetwork2 ) ) ;
12001205 JSON . stringify ( tokenNetwork3 ) . should . eql ( JSON . stringify ( tokenNetwork4 ) ) ;
12011206 } ) ;
1207+
12021208 it ( 'should be able to add single ams token into coin map' , ( ) => {
12031209 const coinMap = CoinMap . fromCoins ( [ ] ) ;
12041210 const staticsCoin = createToken ( amsTokenConfigWithCustomToken [ 'hteth:faketoken' ] [ 0 ] ) ;
@@ -1207,6 +1213,7 @@ describe('create token map using config details', () => {
12071213 }
12081214 coinMap . has ( 'hteth:faketoken' ) . should . be . true ( ) ;
12091215 } ) ;
1216+
12101217 it ( 'should be able to create token config of a single base coin' , ( ) => {
12111218 const tokenName = 'hteth:faketoken' ;
12121219 const coinMap = createTokenMapUsingTrimmedConfigDetails ( reducedAmsTokenConfig ) ;
@@ -1222,14 +1229,27 @@ describe('create token map using config details', () => {
12221229 decimalPlaces : amsTokenConfig . decimalPlaces ,
12231230 tokenContractAddress : amsTokenConfig . contractAddress . toLowerCase ( ) ,
12241231 } ) ;
1225- it ( 'should return the base coin present in default coin map' , ( ) => {
1226- const tokenName = 'thbar:usdc' ;
1227- const token = createToken ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] ) ;
1228- token ?. should . not . be . undefined ( ) ;
1229- token ?. decimalPlaces . should . eql ( coins . get ( tokenName ) . decimalPlaces ) ;
1230- token ?. baseUnit . should . eql ( coins . get ( tokenName ) . baseUnit ) ;
1231- token ?. decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
1232- token ?. baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
1233- } ) ;
1232+ } ) ;
1233+
1234+ it ( 'should return the base coin present in default coin map' , ( ) => {
1235+ const tokenName = 'thbar:usdc' ;
1236+ const token = createToken ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] ) ;
1237+ token ?. should . not . be . undefined ( ) ;
1238+ token ?. decimalPlaces . should . eql ( coins . get ( tokenName ) . decimalPlaces ) ;
1239+ token ?. baseUnit . should . eql ( coins . get ( tokenName ) . baseUnit ) ;
1240+ token ?. decimalPlaces . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . decimalPlaces ) ;
1241+ token ?. baseUnit . should . not . eql ( incorrectAmsTokenConfig [ tokenName ] [ 0 ] . baseUnit ) ;
1242+ } ) ;
1243+
1244+ it ( 'should be able to create base coin from trimmed token config' , ( ) => {
1245+ const tokenName = 'hteth:faketoken' ;
1246+ const reducedTokenConfig = reducedAmsTokenConfig [ tokenName ] [ 0 ] ;
1247+ const token = createTokenUsingTrimmedConfigDetails ( reducedTokenConfig ) ;
1248+ token ?. should . not . be . undefined ( ) ;
1249+ token ?. name . should . eql ( reducedTokenConfig . name ) ;
1250+ token ?. decimalPlaces . should . eql ( reducedTokenConfig . decimalPlaces ) ;
1251+ const bgerchToken = coins . get ( 'bgerch' ) ;
1252+ const bgerchNetwork = bgerchToken ?. network ;
1253+ JSON . stringify ( bgerchNetwork ) . should . eql ( JSON . stringify ( token ?. network ) ) ;
12341254 } ) ;
12351255} ) ;
0 commit comments