Skip to content

Commit

Permalink
Use mocktime in deposittovault tests (#896)
Browse files Browse the repository at this point in the history
* Sets mocktime
* Fix lint
  • Loading branch information
dcorral authored Nov 11, 2021
1 parent a0359e9 commit cd1c422
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/functional/feature_loan_deposittovault.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than
import calendar
import time

class DepositToVaultTest (DefiTestFramework):
Expand Down Expand Up @@ -69,8 +68,9 @@ def run_test(self):
{"currency": "USD", "tokenAmount": "1@DFI"},
{"currency": "USD", "tokenAmount": "1@BTC"},
{"currency": "USD", "tokenAmount": "1@TSLA"}]
timestamp = calendar.timegm(time.gmtime())
self.nodes[0].setoracledata(oracle_id1, timestamp, oracle1_prices)
mock_time = int(time.time())
self.nodes[0].setmocktime(mock_time)
self.nodes[0].setoracledata(oracle_id1, mock_time, oracle1_prices)

self.nodes[0].generate(1)
self.sync_blocks()
Expand Down Expand Up @@ -163,8 +163,9 @@ def run_test(self):
{"currency": "USD", "tokenAmount": "1@DFI"},
{"currency": "USD", "tokenAmount": "1@TSLA"},
{"currency": "USD", "tokenAmount": "1@BTC"}]
timestamp = calendar.timegm(time.gmtime())
self.nodes[0].setoracledata(oracle_id1, timestamp, oracle1_prices)
mock_time = int(time.time())
self.nodes[0].setmocktime(mock_time)
self.nodes[0].setoracledata(oracle_id1, mock_time, oracle1_prices)

self.nodes[0].generate(8)
self.sync_blocks()
Expand All @@ -187,8 +188,9 @@ def run_test(self):

# make vault enter under liquidation state
oracle1_prices = [{"currency": "USD", "tokenAmount": "4@TSLA"}]
timestamp = calendar.timegm(time.gmtime())
self.nodes[0].setoracledata(oracle_id1, timestamp, oracle1_prices)
mock_time = int(time.time())
self.nodes[0].setmocktime(mock_time)
self.nodes[0].setoracledata(oracle_id1, mock_time, oracle1_prices)
self.nodes[0].generate(6) # let fixed price update
self.sync_blocks()

Expand Down

0 comments on commit cd1c422

Please sign in to comment.