1+ # tests/integration/test_integration_wip.py
2+
13from eth_typing import Hash32
24
35from story_protocol_python_sdk .story_client import StoryClient
@@ -46,14 +48,24 @@ def test_deposit(self, story_client: StoryClient):
4648
4749
4850class TestWIPTransfer :
51+ """Test WIP transfer functionality"""
52+
4953 def test_transfer (self , story_client : StoryClient ):
5054 """Test transferring WIP"""
51- transfer_amount = web3 .to_wei ("0.01" , "ether " )
55+ transfer_amount = web3 .to_wei (1 , "wei " )
5256
5357 # Get balances before transfer
5458 sender_wip_before = story_client .WIP .balance_of (wallet_address_str )
5559 receiver_wip_before = story_client .WIP .balance_of (wallet_address_2_str )
5660
61+ # Ensure sender has enough WIP balance
62+ if sender_wip_before < transfer_amount :
63+ story_client .WIP .deposit (
64+ amount = transfer_amount - sender_wip_before ,
65+ )
66+
67+ sender_wip_before = story_client .WIP .balance_of (wallet_address_str )
68+
5769 # Transfer WIP to wallet_address_2
5870 response = story_client .WIP .transfer (
5971 to = wallet_address_2_str ,
@@ -77,6 +89,74 @@ def test_transfer(self, story_client: StoryClient):
7789 # and the TypeScript test also skips this test for the same reason
7890
7991
92+ class TestWIPApprove :
93+ """Test WIP approval functionality"""
94+
95+ def test_approve (self , story_client : StoryClient ):
96+ """Test basic approve functionality"""
97+ approve_amount = web3 .to_wei (1 , "wei" )
98+
99+ response = story_client .WIP .approve (
100+ spender = wallet_address_2_str ,
101+ amount = approve_amount ,
102+ )
103+
104+ assert response is not None
105+ assert "tx_hash" in response
106+ assert isinstance (response ["tx_hash" ], str )
107+
108+ # Verify allowance was set correctly
109+ final_allowance = story_client .WIP .allowance (
110+ owner = wallet_address_str , spender = wallet_address_2_str
111+ )
112+ assert final_allowance == approve_amount
113+
114+
115+ class TestWIPTransferFrom :
116+ """Test WIP transferFrom functionality"""
117+
118+ def test_transfer_from (
119+ self , story_client : StoryClient , story_client_2 : StoryClient
120+ ):
121+ """Test basic transferFrom functionality"""
122+ transfer_amount = web3 .to_wei ("1" , "wei" )
123+
124+ # Ensure wallet_address has enough WIP balance
125+ owner_balance = story_client .WIP .balance_of (wallet_address_str )
126+ if owner_balance < transfer_amount :
127+ deposit_amount = transfer_amount - owner_balance + web3 .to_wei ("1" , "wei" )
128+ story_client .WIP .deposit (amount = deposit_amount )
129+
130+ # Get initial balances
131+ owner_wip_before = story_client .WIP .balance_of (wallet_address_str )
132+ spender_wip_before = story_client .WIP .balance_of (wallet_address_2_str )
133+
134+ # Approve spender to transfer from owner
135+ story_client .WIP .approve (
136+ spender = wallet_address_2_str ,
137+ amount = transfer_amount ,
138+ )
139+
140+ # Execute transferFrom using spender's account
141+ response = story_client_2 .WIP .transfer_from (
142+ from_address = wallet_address_str ,
143+ to = wallet_address_2_str ,
144+ amount = transfer_amount ,
145+ )
146+
147+ assert response is not None
148+ assert "tx_hash" in response
149+ assert isinstance (response ["tx_hash" ], str )
150+
151+ # Get final balances
152+ owner_wip_after = story_client .WIP .balance_of (wallet_address_str )
153+ spender_wip_after = story_client .WIP .balance_of (wallet_address_2_str )
154+
155+ # Verify balances
156+ assert owner_wip_after == owner_wip_before - transfer_amount
157+ assert spender_wip_after == spender_wip_before + transfer_amount
158+
159+
80160class TestWIPWithdraw :
81161 def test_withdraw (self , story_client : StoryClient ):
82162 """Test withdrawing WIP to IP"""
0 commit comments