@@ -1295,4 +1295,40 @@ mod string_and_array {
1295
1295
assert_eq ! ( Ok ( expected) , rule. eval( & input, & mut output) ) ;
1296
1296
}
1297
1297
}
1298
+
1299
+ #[ test]
1300
+ fn test_get_dai_price_in_usd_eval ( ) {
1301
+ let mut input = get_default_input ( ) ;
1302
+ input. global . channel . deposit_asset = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359" . to_string ( ) ;
1303
+ let mut output = Output {
1304
+ show : true ,
1305
+ boost : 1.0 ,
1306
+ price : Default :: default ( ) ,
1307
+ } ;
1308
+
1309
+ let amount_dai = BigNum :: from_str ( "100000000000000000000" ) . expect ( "Should create BigNum" ) ; // 100 DAI
1310
+ let amount_usd = Some ( Value :: BigNum ( BigNum :: from ( 100 ) ) ) ;
1311
+ let rule = Rule :: Function ( Function :: new_get_price_in_usd (
1312
+ Rule :: Value ( Value :: BigNum ( amount_dai) ) ,
1313
+ ) ) ;
1314
+ assert_eq ! ( Ok ( amount_usd) , rule. eval( & input, & mut output) ) ;
1315
+ }
1316
+
1317
+ #[ test]
1318
+ fn test_get_tether_price_in_usd_eval ( ) {
1319
+ let mut input = get_default_input ( ) ;
1320
+ input. global . channel . deposit_asset = "0xdac17f958d2ee523a2206206994597c13d831ec7" . to_string ( ) ;
1321
+ let mut output = Output {
1322
+ show : true ,
1323
+ boost : 1.0 ,
1324
+ price : Default :: default ( ) ,
1325
+ } ;
1326
+
1327
+ let amount_tether = BigNum :: from_str ( "100000000" ) . expect ( "Should create BigNum" ) ; // 100 Tether
1328
+ let amount_usd = Some ( Value :: BigNum ( BigNum :: from ( 100 ) ) ) ;
1329
+ let rule = Rule :: Function ( Function :: new_get_price_in_usd (
1330
+ Rule :: Value ( Value :: BigNum ( amount_tether) ) ,
1331
+ ) ) ;
1332
+ assert_eq ! ( Ok ( amount_usd) , rule. eval( & input, & mut output) ) ;
1333
+ }
1298
1334
}
0 commit comments