@@ -668,3 +668,191 @@ async def test_svm_wrapper_swaps(self):
668
668
)
669
669
670
670
assert result == ["solana_swap" ]
671
+
672
+
673
+ class TestEVMWrapperMissingMethods :
674
+ """Test EVMWrapper methods not covered by existing tests."""
675
+
676
+ @pytest .mark .anyio
677
+ async def test_evm_wrapper_transfers (self ):
678
+ """Test EVMWrapper.transfers method."""
679
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
680
+
681
+ with patch .object (api , "_evm_transfers" ) as mock_transfers :
682
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
683
+ mock_transfers .return_value = [{"hash" : "0xtx123" }]
684
+ mock_convert .return_value = ["transfer" ]
685
+
686
+ result = await api .evm .transfers (
687
+ from_address = "0xfrom" , to_address = "0xto" , contract = "0xtoken" , limit = 5 , network = "mainnet"
688
+ )
689
+
690
+ assert result == ["transfer" ]
691
+ mock_transfers .assert_called_with (
692
+ from_address = "0xfrom" , to_address = "0xto" , contract = "0xtoken" , limit = 5 , network = "mainnet"
693
+ )
694
+
695
+ @pytest .mark .anyio
696
+ async def test_evm_wrapper_swaps (self ):
697
+ """Test EVMWrapper.swaps method."""
698
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
699
+
700
+ with patch .object (api , "_evm_swaps" ) as mock_swaps :
701
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
702
+ mock_swaps .return_value = [{"protocol" : "uniswap_v3" }]
703
+ mock_convert .return_value = ["swap" ]
704
+
705
+ result = await api .evm .swaps (pool = "0xpool" , protocol = Protocol .UNISWAP_V3 , limit = 10 , network = "polygon" )
706
+
707
+ assert result == ["swap" ]
708
+ mock_swaps .assert_called_with (pool = "0xpool" , protocol = Protocol .UNISWAP_V3 , limit = 10 , network = "polygon" )
709
+
710
+ @pytest .mark .anyio
711
+ async def test_evm_wrapper_swaps_advanced (self ):
712
+ """Test EVMWrapper.swaps_advanced method."""
713
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
714
+
715
+ with patch .object (api , "_evm_swaps_advanced" ) as mock_swaps_advanced :
716
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
717
+ mock_swaps_advanced .return_value = [{"transaction_id" : "0xtx" }]
718
+ mock_convert .return_value = ["swap" ]
719
+
720
+ result = await api .evm .swaps_advanced (
721
+ pool = "0xpool" ,
722
+ caller = "0xcaller" ,
723
+ sender = "0xsender" ,
724
+ recipient = "0xrecipient" ,
725
+ protocol = Protocol .UNISWAP_V2 ,
726
+ transaction_id = "0xtx123" ,
727
+ start_time = 1640995200 ,
728
+ end_time = 1640995300 ,
729
+ order_by = OrderBy .TIMESTAMP ,
730
+ order_direction = OrderDirection .DESC ,
731
+ limit = 20 ,
732
+ network = "arbitrum" ,
733
+ )
734
+
735
+ assert result == ["swap" ]
736
+ mock_swaps_advanced .assert_called_with (
737
+ pool = "0xpool" ,
738
+ caller = "0xcaller" ,
739
+ sender = "0xsender" ,
740
+ recipient = "0xrecipient" ,
741
+ protocol = Protocol .UNISWAP_V2 ,
742
+ transaction_id = "0xtx123" ,
743
+ start_time = 1640995200 ,
744
+ end_time = 1640995300 ,
745
+ order_by = OrderBy .TIMESTAMP ,
746
+ order_direction = OrderDirection .DESC ,
747
+ limit = 20 ,
748
+ network = "arbitrum" ,
749
+ )
750
+
751
+ @pytest .mark .anyio
752
+ async def test_evm_wrapper_pools (self ):
753
+ """Test EVMWrapper.pools method."""
754
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
755
+
756
+ with patch .object (api , "_evm_pools" ) as mock_pools :
757
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
758
+ mock_pools .return_value = [{"pool" : "0xpool123" }]
759
+ mock_convert .return_value = ["pool" ]
760
+
761
+ result = await api .evm .pools (
762
+ pool = "0xpool" , token = "0xtoken" , protocol = Protocol .UNISWAP_V3 , limit = 15 , network = "optimism"
763
+ )
764
+
765
+ assert result == ["pool" ]
766
+ mock_pools .assert_called_with (
767
+ pool = "0xpool" , token = "0xtoken" , protocol = Protocol .UNISWAP_V3 , limit = 15 , network = "optimism"
768
+ )
769
+
770
+ @pytest .mark .anyio
771
+ async def test_evm_wrapper_price_history (self ):
772
+ """Test EVMWrapper.price_history method."""
773
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
774
+
775
+ with patch .object (api , "_evm_price_history" ) as mock_price_history :
776
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
777
+ mock_price_history .return_value = [{"close" : 1500.0 }]
778
+ mock_convert .return_value = ["ohlc" ]
779
+
780
+ result = await api .evm .price_history (
781
+ token = "0xtoken" , interval = Interval .ONE_DAY , days = 7 , limit = 168 , network = "base"
782
+ )
783
+
784
+ assert result == ["ohlc" ]
785
+ mock_price_history .assert_called_with (
786
+ token = "0xtoken" , interval = Interval .ONE_DAY , days = 7 , limit = 168 , network = "base"
787
+ )
788
+
789
+ @pytest .mark .anyio
790
+ async def test_evm_wrapper_pool_history (self ):
791
+ """Test EVMWrapper.pool_history method."""
792
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
793
+
794
+ with patch .object (api , "_evm_pool_history" ) as mock_pool_history :
795
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
796
+ mock_pool_history .return_value = [{"volume" : 1000.0 }]
797
+ mock_convert .return_value = ["ohlc" ]
798
+
799
+ result = await api .evm .pool_history (
800
+ pool = "0xpool" , interval = Interval .FOUR_HOURS , days = 3 , limit = 18 , network = "avalanche"
801
+ )
802
+
803
+ assert result == ["ohlc" ]
804
+ mock_pool_history .assert_called_with (
805
+ pool = "0xpool" , interval = Interval .FOUR_HOURS , days = 3 , limit = 18 , network = "avalanche"
806
+ )
807
+
808
+ @pytest .mark .anyio
809
+ async def test_evm_wrapper_token_holders (self ):
810
+ """Test EVMWrapper.token_holders method."""
811
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
812
+
813
+ with patch .object (api , "_evm_token_holders" ) as mock_token_holders :
814
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
815
+ mock_token_holders .return_value = [{"address" : "0xholder" }]
816
+ mock_convert .return_value = ["token_holder" ]
817
+
818
+ result = await api .evm .token_holders (contract = "0xtoken" , limit = 50 , network = "bsc" )
819
+
820
+ assert result == ["token_holder" ]
821
+ mock_token_holders .assert_called_with (contract = "0xtoken" , limit = 50 , network = "bsc" )
822
+
823
+
824
+ class TestSVMWrapperMissingMethods :
825
+ """Test SVMWrapper methods not covered by existing tests."""
826
+
827
+ @pytest .mark .anyio
828
+ async def test_svm_wrapper_transfers (self ):
829
+ """Test SVMWrapper.transfers method."""
830
+ api = TokenAPI (api_key = "test_key" , auto_load_env = False )
831
+
832
+ with patch .object (api , "_svm_transfers" ) as mock_transfers :
833
+ with patch ("thegraph_token_api.simple.convert_list_to_models" ) as mock_convert :
834
+ mock_transfers .return_value = [{"signature" : "sig123" }]
835
+ mock_convert .return_value = ["solana_transfer" ]
836
+
837
+ result = await api .svm .transfers (
838
+ signature = "sig123" ,
839
+ program_id = SolanaPrograms .TOKEN ,
840
+ mint = "So11111111111111111111111111111111111111112" ,
841
+ authority = "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM" ,
842
+ source = "4ct7br2vTPzfdmY3S5HLtTxcGSBfn6pnw98hsS6v359A" ,
843
+ destination = "5dt8br2vTPzfdmY3S5HLtTxcGSBfn6pnw98hsS6v360B" ,
844
+ limit = 25 ,
845
+ network = "solana" ,
846
+ )
847
+
848
+ assert result == ["solana_transfer" ]
849
+ mock_transfers .assert_called_with (
850
+ signature = "sig123" ,
851
+ program_id = SolanaPrograms .TOKEN ,
852
+ mint = "So11111111111111111111111111111111111111112" ,
853
+ authority = "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM" ,
854
+ source = "4ct7br2vTPzfdmY3S5HLtTxcGSBfn6pnw98hsS6v359A" ,
855
+ destination = "5dt8br2vTPzfdmY3S5HLtTxcGSBfn6pnw98hsS6v360B" ,
856
+ limit = 25 ,
857
+ network = "solana" ,
858
+ )
0 commit comments