Skip to content

Commit

Permalink
Store cost
Browse files Browse the repository at this point in the history
  • Loading branch information
moraygrieve committed Jan 10, 2025
1 parent 07281e8 commit ad74db2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/python/ten/test/basetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, descriptor, outsubdir, runner):
self.ephemeral_pks = []
self.transfer_costs = []
self.average_transfer_cost = 21000000000000
self.cost = 0
self.eth_price = self.rates_db.get_latest_rate('ETH', 'USD')

for fn in Properties().accounts():
Expand All @@ -71,6 +72,7 @@ def __test_cost(self):
self.log.info(" %s: %s%d WEI", 'Test cost', sign, delta, extra=BaseLogFormatter.tag(LOG_TRACEBACK, 0))
self.log.info(" %s: %s%.9f ETH", 'Test cost', sign, Web3().from_wei(delta, 'ether'), extra=BaseLogFormatter.tag(LOG_TRACEBACK, 0))
if self.eth_price is not None:
self.cost = round(self.eth_price*float(Web3().from_wei((self.balance - balance), 'ether')), 3)
change = float(Web3().from_wei(delta, 'ether'))
self.log.info(" %s: %s%.3f USD", 'Test cost', sign, self.eth_price*change, extra=BaseLogFormatter.tag(LOG_TRACEBACK, 0))

Expand Down
7 changes: 4 additions & 3 deletions src/python/ten/test/persistence/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class OutomeResultsPersistence:
"environment VARCHAR(64), " \
"time INTEGER, " \
"duration REAL, " \
"cost REAL, " \
"outcome VARCHAR(64))"
SQL_INSERT = "INSERT INTO results_outcome VALUES (?, ?, ?, ?, ?, ?, ?)"
SQL_INSERT = "INSERT INTO results_outcome VALUES (?, ?, ?, ?, ?, ?, ?, ?)"

@classmethod
def init(cls, use_remote, user_dir, host):
Expand All @@ -36,9 +37,9 @@ def create(self):
"""Create the cursor to the underlying persistence."""
self.cursor.execute(self.SQL_CREATE)

def insert(self, uuid, test, environment, time, duration, outcome):
def insert(self, uuid, test, environment, time, duration, cost, outcome):
"""Insert a new performance result into the persistence. """
self.cursor.execute(self.sqlins, (uuid, self.host, test, environment, time, duration, outcome))
self.cursor.execute(self.sqlins, (uuid, self.host, test, environment, time, duration, cost, outcome))
self.dbconnection.connection.commit()

def close(self):
Expand Down
1 change: 1 addition & 0 deletions src/python/ten/test/writer/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ def processResult(self, testObj, **kwargs):
self.env,
int(kwargs['testStart']),
kwargs['testTime'],
testObj.cost,
str(testObj.getOutcome()))

0 comments on commit ad74db2

Please sign in to comment.