Skip to content

Commit

Permalink
More test fixes (#1463)
Browse files Browse the repository at this point in the history
* Update higher collateral test

* Correct two more failing tests

* Max out vault
  • Loading branch information
Bushstar authored Sep 12, 2022
1 parent 3d239f2 commit d8f7fc7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions test/functional/feature_higher_collateral_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ def take_dusd_loan(self):
self.nodes[0].generate(1)

# Deposit DUSD and DFI to vault
self.nodes[0].deposittovault(vault_id, self.address, f"1.5@{self.symbolDFI}")
self.nodes[0].deposittovault(vault_id, self.address, f"2.235@{self.symbolDFI}")
self.nodes[0].generate(1)
self.nodes[0].deposittovault(vault_id, self.address, f"1.5@{self.symbolDUSD}")
self.nodes[0].generate(1)

# Take DUSD loan greater than collateral amount
self.nodes[0].takeloan({ "vaultId": vault_id, "amounts": f"2.49@{self.symbolDUSD}"})
self.nodes[0].takeloan({ "vaultId": vault_id, "amounts": f"2.98@{self.symbolDUSD}"})
self.nodes[0].generate(1)

# Check that we are on 150% collateral ratio
vault = self.nodes[0].getvault(vault_id)
assert_equal(vault['collateralRatio'], 150)
assert_equal(vault['informativeRatio'], Decimal('150.00000000'))
assert_equal(vault['collateralValue'], Decimal('3.73500000'))
assert_equal(vault['loanValue'], Decimal('2.49000000'))
assert_equal(vault['collateralValue'], Decimal('4.47000000'))
assert_equal(vault['loanValue'], Decimal('2.98000000'))

def take_multiple_loans(self):

Expand Down
8 changes: 2 additions & 6 deletions test/functional/feature_loan_priceupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from test_framework.test_framework import DefiTestFramework
from decimal import Decimal, ROUND_DOWN

from test_framework.util import assert_equal
from test_framework.util import assert_equal, assert_raises_rpc_error

import calendar
import time
Expand Down Expand Up @@ -254,11 +254,7 @@ def run_test(self):
self.nodes[0].generate(1)
takenLoanAmount += loanAmount

try:
self.nodes[0].withdrawfromvault(vaultId1, account, "900@DFI")
except JSONRPCException as e:
errorString = e.error['message']
assert("At least 50% of the collateral must be in DFI" in errorString)
assert_raises_rpc_error(-32600, "At least 50% of the minimum required collateral must be in DFI", self.nodes[0].withdrawfromvault, vaultId1, account, "900@DFI")

vault = self.nodes[0].getvault(vaultId1)
self.nodes[0].withdrawfromvault(vaultId1, account, "100@BTC")
Expand Down
7 changes: 4 additions & 3 deletions test/functional/feature_negative_interest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def createTokens(self):

self.idDFI = list(self.nodes[0].gettoken(self.symbolDFI).keys())[0]

# Create loan scheme
self.nodes[0].createloanscheme(150, 1, 'LOAN1')
self.nodes[0].generate(1)

self.nodes[0].setcollateraltoken({
'token': self.idDFI,
'factor': 1,
Expand Down Expand Up @@ -172,9 +176,6 @@ def setup(self):
# Loan scheme interest->1% and loantoken interest-> -1%
# Resulting interest must be 0.
def vault_interest_zero(self):
# Create loan scheme
self.nodes[0].createloanscheme(150, 1, 'LOAN1')
self.nodes[0].generate(1)

# Init vault (create, deposit takeloan)
self.nodes[0].utxostoaccount({self.account0: "4000@DFI"})
Expand Down

0 comments on commit d8f7fc7

Please sign in to comment.