Skip to content

Commit

Permalink
Support Chia 1.5.1 (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
djerfy committed Aug 26, 2022
1 parent 26e2951 commit cd4aa90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/chia_log/parsers/wallet_added_coin_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class WalletAddedCoinParser:
def __init__(self):
logging.info("Enabled parser for wallet activity - added coins.")
self._regex = re.compile(
r"([0-9:.]*) wallet (?:src|chia).wallet.wallet_state_manager(?:\s?): "
r"INFO\s*Adding( | record to state manager )?coin: {'amount': ([0-9]*),"
r"([0-9:.]*) wallet (?:src|chia).wallet.wallet_(?:state_manager|node)(?:\s*)?: "
r"INFO\s*(?:Adding|Adding record to state manager|request) coin: (?:\w*{'coin': )?{'amount': ([0-9]*),"
)

def parse(self, logs: str) -> List[WalletAddedCoinMessage]:
Expand All @@ -42,7 +42,7 @@ def parse(self, logs: str) -> List[WalletAddedCoinMessage]:
parsed_messages.append(
WalletAddedCoinMessage(
timestamp=dateutil_parser.parse(match[0]),
amount_mojos=int(match[2]),
amount_mojos=int(match[1]),
)
)

Expand Down
2 changes: 2 additions & 0 deletions tests/chia_log/logs/wallet_added_coin/nominal-after-1.5.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
15:37:11.668 wallet chia.wallet.wallet_node : INFO request coin: cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc{'coin': {'amount': 250000000000,
16:53:59.677 wallet chia.wallet.wallet_node : INFO request coin: 1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff{'coin': {'amount': 1750000000000,
8 changes: 5 additions & 3 deletions tests/chia_log/parsers/test_wallet_added_coin_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ def setUp(self) -> None:
self.parser = WalletAddedCoinParser()
self.example_logs_path = Path(__file__).resolve().parents[1] / "logs/wallet_added_coin"
with open(self.example_logs_path / "nominal-before-1.4.0.txt", encoding="UTF-8") as f:
self.nominal_logs_before = f.read()
self.nominal_logs_before_140 = f.read()
with open(self.example_logs_path / "nominal-after-1.4.0.txt", encoding="UTF-8") as f:
self.nominal_logs_after = f.read()
self.nominal_logs_after_140 = f.read()
with open(self.example_logs_path / "nominal-after-1.5.1.txt", encoding="UTF-8") as f:
self.nominal_logs_after_151 = f.read()

def testBasicParsing(self):
for nominal_logs in [self.nominal_logs_before, self.nominal_logs_after]:
for nominal_logs in [self.nominal_logs_before_140, self.nominal_logs_after_140, self.nominal_logs_after_151]:
added_coins = self.parser.parse(nominal_logs)
total_mojos = 0
for coin in added_coins:
Expand Down

0 comments on commit cd4aa90

Please sign in to comment.