Skip to content

Commit

Permalink
send exit signal on any error in monitoring (#135)
Browse files Browse the repository at this point in the history
* send exit signal on any error in monitoring

* ruff

* ton tests fix

* btc tests fix

* ignore SystemExit for now

* ruff fixes

---------

Co-authored-by: Oleksandr Prudnikov <[email protected]>
  • Loading branch information
Grommash9 and Oleksandr Prudnikov authored Dec 6, 2024
1 parent 917a0c5 commit d7317c6
Show file tree
Hide file tree
Showing 21 changed files with 764 additions and 111 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [5.0.0]
- send exit signal on any error in monitoring

## [4.12.0]
- Add tron get transaction info method (working on quicknode/tatum)

Expand Down
4 changes: 3 additions & 1 deletion aiotx/clients/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ async def start(
except Exception as e:
print(f"Error during block monitoring: {e}")
self._stop_signal.set()
raise
import sys

sys.exit(1)

async def poll_blocks(self, timeout: int, **kwargs):
# This method should be implemented by subclasses
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
BSC_TEST_NODE_URL = "https://bsc-testnet-rpc.publicnode.com"
ETH_TEST_NODE_URL = "https://ethereum-sepolia-rpc.publicnode.com"
LTC_TEST_NODE_URL = "https://api.tatum.io/v3/blockchain/node/litecoin-core-testnet/t-66b98fa76a2e46001c79a063-6be61af199b34129a4797ed2/"
BTC_TEST_NODE_URL = "https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/"
TON_MAINNET_NODE_URL = "https://go.getblock.io/875fb0dee2544bb0bc59dd08c6f39330"
BTC_TEST_NODE_URL = "https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/"
TON_MAINNET_NODE_URL = "https://go.getblock.io/7e6c1ce3a06d42e2a81891fb36062120"
POLYGON_TEST_NODE_URL = "https://polygon-amoy-bor-rpc.publicnode.com"
TON_TEST_NODE_URL = "https://testnet.toncenter.com/api/v2"
TRON_TEST_NODE_URL = "https://api.shasta.trongrid.io"
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/cassettes/btc/bulk_send.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: '{"method": "getblockcount", "params": [], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":2821482,"error":null,"id":"curltest"}
Expand Down Expand Up @@ -38,7 +38,7 @@ interactions:
"2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":{"feerate":0.01012551,"blocks":6},"error":null,"id":"curltest"}
Expand Down Expand Up @@ -73,7 +73,7 @@ interactions:
"jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":"b68f08d7e9e98c48460475eebd820dddc956f87857f573770f20aa67e70e8df9","error":null,"id":"curltest"}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/cassettes/btc/create_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: '{"method": "getblockcount", "params": [], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":2874563,"error":null,"id":"curltest"}'
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/cassettes/btc/create_client_mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interactions:
body: '{"method": "getblockcount", "params": [], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":2874563,"error":null,"id":"curltest"}'
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/cassettes/btc/get_raw_transaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interactions:
2], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":{"txid":"35158b7a8b6057bc67f6d904c64b5986adea8260f0bc96cbd755b530878e3cc2","hash":"a872541715e90ca454cb6a9666d82cdedbcda1efba207dc7047f7238aa2e9797","version":1,"size":331,"vsize":250,"weight":997,"locktime":0,"vin":[{"txid":"25d56f693d5c4d00d3f98e58c8bd66e8db930e38c8a556bd67737b66cbf31ab9","vout":0,"scriptSig":{"asm":"","hex":""},"txinwitness":["3044022043d9458b77a69e55477e3674ecc39160de9340703a81254a82dff7cf70c052b202202f29540d74e50f22c402986982789ccee7b1d0860139057217e4105a4c9e384101","032483516ae6532dbeaf537cb5c1da64f973a6066fbde788f665b3dbd45f7417a9"],"prevout":{"generated":false,"height":2814756,"value":0.00016263,"scriptPubKey":{"asm":"0
Expand Down Expand Up @@ -47,7 +47,7 @@ interactions:
2], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":{"txid":"77cb20c4b0325242b9e5f45f4850e5387dc585d6b72bb36ba65a126534436973","hash":"4251764ab66314bb4ddcbd2882da948d5d4db08078c26b959d5734068b3658bb","version":1,"size":195,"vsize":113,"weight":450,"locktime":0,"vin":[{"txid":"35158b7a8b6057bc67f6d904c64b5986adea8260f0bc96cbd755b530878e3cc2","vout":0,"scriptSig":{"asm":"","hex":""},"txinwitness":["3045022100b2cf6022cabe152a87f173542238565b953718159ad1932c9cc24fcd7af674a002201ca194aa7d32dfaadd1d3d7fbcd0bb1d7736b7b705734548cf41cfacb5946c4201","032483516ae6532dbeaf537cb5c1da64f973a6066fbde788f665b3dbd45f7417a9"],"prevout":{"generated":false,"height":2815299,"value":0.00006263,"scriptPubKey":{"asm":"0
Expand Down Expand Up @@ -84,7 +84,7 @@ interactions:
2], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":{"txid":"2ab5a6a291ece2240642369589442029a6ae4baaefb83ff6760893e542f2f8ac","hash":"5b41547261c8b7a3dfeda0aa0ce2f91f345e1f286650b9ccf2a67a94056f79b8","version":1,"size":169,"vsize":142,"weight":568,"locktime":0,"vin":[{"coinbase":"032a0d2b","txinwitness":["0000000000000000000000000000000000000000000000000000000000000000"],"sequence":4294967295}],"vout":[{"value":0.31754252,"n":0,"scriptPubKey":{"asm":"0
Expand Down Expand Up @@ -121,7 +121,7 @@ interactions:
2], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":null,"error":{"code":-8,"message":"parameter 1 must be of
Expand Down Expand Up @@ -157,7 +157,7 @@ interactions:
2], "jsonrpc": "2.0", "id": "curltest"}'
headers: {}
method: POST
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-eecc770265e8462e806b601f/
uri: https://api.tatum.io/v3/blockchain/node/bitcoin-testnet/t-66b98fa76a2e46001c79a063-692fb071f17244618fc5b2e9/
response:
body:
string: '{"result":null,"error":{"code":-8,"message":"parameter 1 must be of
Expand Down
Loading

0 comments on commit d7317c6

Please sign in to comment.