From ddb919fe56f059db638211e5ba423db75d57fef4 Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 23 Oct 2024 16:58:12 +0900 Subject: [PATCH 1/2] Fix recipient address to avatar for claim_items data --- tests/raid_test.py | 13 +++++++++++++ world_boss/app/raid.py | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/raid_test.py b/tests/raid_test.py index e770b74..d4d0f40 100644 --- a/tests/raid_test.py +++ b/tests/raid_test.py @@ -24,6 +24,7 @@ get_transfer_assets_plain_value, get_tx_delay_factor, list_tx_nonce, + row_to_recipient, update_agent_address, write_ranking_rewards_csv, write_tx_result_csv, @@ -604,3 +605,15 @@ def test_get_prepare_reward_assets_plain_value(fx_session): 23890, ], ] + + +@pytest.mark.parametrize("ticker", ["CRYSTAL", "Item_NT_500000", "RUNESTONE_FENRIR1"]) +def test_row_to_recipient(ticker: str): + content = f"3,25,0x01069aaf336e6aEE605a8A54D0734b43B62f8Fe4,5b65f5D0e23383FA18d74A62FbEa383c7D11F29d,150000,{ticker},18,175" + row = content.split(",") + recipient: Recipient = row_to_recipient(row) + assert recipient["recipient"] == "5b65f5D0e23383FA18d74A62FbEa383c7D11F29d" + amount = recipient["amount"] + assert amount["quantity"] == 150000 + assert amount["decimalPlaces"] == 18 + assert amount["ticker"] == ticker diff --git a/world_boss/app/raid.py b/world_boss/app/raid.py index 1a036a5..45ba9a7 100644 --- a/world_boss/app/raid.py +++ b/world_boss/app/raid.py @@ -171,14 +171,12 @@ def write_ranking_rewards_csv( def row_to_recipient(row: RecipientRow) -> Recipient: - agent_address = row[2] avatar_address = row[3] amount = int(row[4]) ticker = row[5] decimal_places = int(row[6]) - recipient = agent_address if ticker == "CRYSTAL" else avatar_address return { - "recipient": recipient, + "recipient": avatar_address, "amount": { "quantity": amount, "decimalPlaces": decimal_places, From bb00166f7bd5c45214e07472d2a63833dea26a5b Mon Sep 17 00:00:00 2001 From: Yang Chun Ung Date: Wed, 23 Oct 2024 20:18:25 +0900 Subject: [PATCH 2/2] Set tx result null --- tests/raid_test.py | 4 +++- world_boss/app/raid.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/raid_test.py b/tests/raid_test.py index d4d0f40..06a0232 100644 --- a/tests/raid_test.py +++ b/tests/raid_test.py @@ -413,7 +413,9 @@ def test_bulk_insert_transactions(fx_session): "memo", ) - assert len(fx_session.query(Transaction).first().amounts) == 7 + tx = fx_session.query(Transaction).first() + assert len(tx.amounts) == 7 + assert tx.tx_result is None world_boss_rewards = fx_session.query(WorldBossReward) for i, world_boss_reward in enumerate(world_boss_rewards): diff --git a/world_boss/app/raid.py b/world_boss/app/raid.py index 45ba9a7..2a07f40 100644 --- a/world_boss/app/raid.py +++ b/world_boss/app/raid.py @@ -447,7 +447,6 @@ def bulk_insert_transactions( "nonce": n, "signer": signer_address, "payload": signed_transaction.hex(), - "tx_result": "CREATED", } ) tx_ids[n] = tx_id