Skip to content

Commit

Permalink
#14 Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
poupou-web3 committed Jun 28, 2023
1 parent 0dcee10 commit 8af3efc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ dmypy.json
.pyre/
/docs/source/_autosummary/

/sbscorer/sblegos/TransactionAnalyserTest.py
4 changes: 4 additions & 0 deletions test/sblegos/TransactionAnalyserTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def test_has_interacted_with_contributor(self):
address = "0x000b94c47e4a8d7a70be12c50fc35722a7596972"
self.assertFalse(self.tx_analyser.has_interacted_with_other_contributor(address))

def test_count_interacted_with_contributor(self):
address = "0xlcsad8bc3dfbe42d9a87686f67c69001a2006da4"
self.assertEqual(1, self.tx_analyser.count_interaction_with_other_contributor(address))

def test_has_interacted_with_contributor_true(self):
address = "0xlcsad8bc3dfbe42d9a87686f67c69001a2006da4"
self.assertTrue(self.tx_analyser.has_interacted_with_other_contributor(address))
Expand Down
38 changes: 38 additions & 0 deletions test/sblegos/TransactionAnalyserTestCodium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import unittest

import pandas as pd

from sbscorer.sblegos.TransactionAnalyser import TransactionAnalyser


class TransactionAnalyserTestCodium(unittest.TestCase):

# Tests that the class can be instantiated with a valid dataframe of transactions and addresses
def test_instantiation(self):
df_transactions = pd.DataFrame()
df_address = pd.DataFrame()
ta = TransactionAnalyser(df_transactions, df_address)
self.assertIsInstance(ta, TransactionAnalyser)

# Tests that the set_seed_wallet_naive method sets the seed wallet dataframe correctly
def test_set_seed_wallet_naive(self):
df_transactions = pd.DataFrame({
'from_address': ['0x1', '0x2', '0x3'],
'to_address': ['0x4', '0x5', '0x6'],
'block_timestamp': [1, 2, 3],
'EOA': ['0x1', '0x2', '0x3']
})

df_address = pd.DataFrame()
ta = TransactionAnalyser(df_transactions, df_address)
ta.set_seed_wallet_naive()
df_expected_seed = pd.DataFrame({
'from_address': ['0x1', '0x2', '0x3'],
'to_address': ['0x4', '0x5', '0x6']
},
index=['0x1', '0x2', '0x3'])
self.assertEqual(ta.df_seed_wallet_naive.to_dict(), df_expected_seed.to_dict())


if __name__ == '__main__':
unittest.main()

0 comments on commit 8af3efc

Please sign in to comment.