@@ -511,3 +511,48 @@ def test_get_last_bets(self):
511
511
expected_calls = [expected_call ]
512
512
self .assertEqual (
513
513
m_get_transaction_page .call_args_list , expected_calls )
514
+
515
+ def test_get_logs_url (self ):
516
+ with \
517
+ mock .patch ('etherscan.contracts.Contract.get_abi' ) \
518
+ as m_get_abi , \
519
+ mock .patch ('pyetheroll.get_etherscan_api_key' ) \
520
+ as m_get_etherscan_api_key :
521
+ m_get_abi .return_value = '[]'
522
+ m_get_etherscan_api_key .return_value = 'apikey'
523
+ etheroll = Etheroll ()
524
+ address = '0x46044beaa1e985c67767e04de58181de5daaa00f'
525
+ from_block = 1
526
+ logs_url = etheroll .get_logs_url (
527
+ address = address , from_block = from_block )
528
+ self .assertEqual (
529
+ logs_url ,
530
+ (
531
+ 'https://api.etherscan.io/api?'
532
+ 'module=logs&action=getLogs&apikey=apikey'
533
+ '&address=0x46044beaa1e985c67767e04de58181de5daaa00f&'
534
+ 'fromBlock=1&toBlock=latest&'
535
+ )
536
+ )
537
+ # makes sure Testnet is also supported
538
+ with \
539
+ mock .patch ('etherscan.contracts.Contract.get_abi' ) \
540
+ as m_get_abi , \
541
+ mock .patch ('pyetheroll.get_etherscan_api_key' ) \
542
+ as m_get_etherscan_api_key :
543
+ m_get_abi .return_value = '[]'
544
+ m_get_etherscan_api_key .return_value = 'apikey'
545
+ etheroll = Etheroll (chain_id = ChainID .ROPSTEN )
546
+ address = '0x46044beaa1e985c67767e04de58181de5daaa00f'
547
+ from_block = 1
548
+ logs_url = etheroll .get_logs_url (
549
+ address = address , from_block = from_block )
550
+ self .assertEqual (
551
+ logs_url ,
552
+ (
553
+ 'https://api-ropsten.etherscan.io/api?'
554
+ 'module=logs&action=getLogs&apikey=apikey&'
555
+ 'address=0x46044beaa1e985c67767e04de58181de5daaa00f&'
556
+ 'fromBlock=1&toBlock=latest&'
557
+ )
558
+ )
0 commit comments