Closed deepesh-kn closed 5 years ago
Currently https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js handles the test case with 2 variations. Add flexibility to run the tests with arbitrary combinations of priceOracleDecimals and eip20TokenDecimals
priceOracleDecimals
eip20TokenDecimals
For Pricer.pay unit test, create a config file that can contain decimal pairs for price oracle and token
"pay_config":[ {"priceOracleDecimals": 18, "eip20TokenDecimals": 5}, {"priceOracleDecimals": 3, "eip20TokenDecimals": 10}, {"priceOracleDecimals": 13, "eip20TokenDecimals": 7} ]
In the pricerRule.pay there are 2 test cases that tests two variations. This can be changed to a single test.
https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js#L356 https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js#L483
Read the json file like const payConfig = process.env.PAY_CONFIG || <read the contents from the file>
const payConfig = process.env.PAY_CONFIG || <read the contents from the file>
Loop through the array of payConfig and execute the tests.
Assign the config and eip20TokenConfig from payConfig
config
eip20TokenConfig
payConfig
const config = { requiredPriceOracleDecimals: payConfig.priceOracleDecimals, }; const eip20TokenConfig = { decimals: payConfig.eip20TokenDecimals, };
Create a followup ticket. Add expected result values in the config.
Currently https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js handles the test case with 2 variations. Add flexibility to run the tests with arbitrary combinations of
priceOracleDecimals
andeip20TokenDecimals
For Pricer.pay unit test, create a config file that can contain decimal pairs for price oracle and token
In the pricerRule.pay there are 2 test cases that tests two variations. This can be changed to a single test.
https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js#L356 https://github.com/OpenST/openst-contracts/blob/develop/test/pricer_rule/pay.js#L483
Read the json file like
const payConfig = process.env.PAY_CONFIG || <read the contents from the file>
Loop through the array of payConfig and execute the tests.
Assign the
config
andeip20TokenConfig
frompayConfig