Hard: investigate sdk.RelativePow runtime panic (#762)

* interest rate practical test

* add clarification comment
This commit is contained in:
Denali Marsh 2021-01-12 10:03:09 +01:00 committed by GitHub
parent a0d70e1c81
commit f6efc2597b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -289,8 +289,6 @@ func (suite *InterestTestSuite) TestCalculateBorrowInterestFactor() {
expectedValue: sdk.MustNewDecFromStr("40628388.864535408465693310"),
},
},
// If we raise the per second interest rate too much we'll cause an integer overflow.
// For example, perSecondInterestRate: '1.000005555555' will cause a panic.
{
"1 year: highest interest rate",
args{
@ -299,6 +297,14 @@ func (suite *InterestTestSuite) TestCalculateBorrowInterestFactor() {
expectedValue: sdk.MustNewDecFromStr("2017093013158200407564.613502861572552603"),
},
},
{
"largest per second interest rate with practical elapsed time",
args{
perSecondInterestRate: sdk.MustNewDecFromStr("18.445"), // Begins to panic at ~18.45 (1845%/second interest rate)
timeElapsed: sdk.NewInt(30), // Assume a 30 second period, longer than any expected individual block
expectedValue: sdk.MustNewDecFromStr("94702138679846565921082258202543002089.215969366091911769"),
},
},
}
for _, tc := range testCases {