Remove all coins except Palladium

coins.py keeps only Coin and the Palladium classes. The Bitcoin base class is
folded into Palladium. COIN now defaults to Palladium.

Tests and fixtures of the other coins are removed. test_blocks.py and
test_transactions.py are simplified: one test each, fed by the palladium
fixtures.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-10-22 15:03:56 +02:00
1 parent 671a94cf4e
commit 73c96101bd
182 files changed
+74 -9665

No files matched your search

+11 -32
View File
@@ -6,29 +6,23 @@ import logging
import pytest
from aiorpcx import JSONRPCv1, JSONRPCLoose, RPCError, ignore_after, Request
from electrumx.lib.coins import BitcoinCash, CoinError, Bitzeny, Dash
from electrumx.server.daemon import Daemon, FakeEstimateFeeDaemon
from electrumx.lib.coins import Palladium, CoinError
from electrumx.server.daemon import Daemon
coin = BitcoinCash
coin = Palladium
# These should be full, canonical URLs
urls = ['http://rpc_user:rpc_pass@127.0.0.1:8332/',
'http://rpc_user:rpc_pass@192.168.0.1:8332/']
urls = ['http://rpc_user:rpc_pass@127.0.0.1:2332/',
'http://rpc_user:rpc_pass@192.168.0.1:2332/']
@pytest.fixture(params=[BitcoinCash, Bitzeny])
@pytest.fixture(params=[Palladium])
def daemon(request):
coin = request.param
return coin.DAEMON(coin, ','.join(urls))
@pytest.fixture(params=[Dash])
def dash_daemon(request):
coin = request.param
return coin.DAEMON(coin, ','.join(urls))
class ResponseBase:
def __init__(self, headers, status):
@@ -161,7 +155,7 @@ async def test_set_urls_one(caplog):
assert daemon.current_url() == urls[0]
assert len(daemon.urls) == 1
logged_url = daemon.logged_url()
assert logged_url == '127.0.0.1:8332/'
assert logged_url == '127.0.0.1:2332/'
assert in_caplog(caplog, f'daemon #1 at {logged_url} (current)')
@@ -172,9 +166,9 @@ async def test_set_urls_two(caplog):
assert daemon.current_url() == urls[0]
assert len(daemon.urls) == 2
logged_url = daemon.logged_url()
assert logged_url == '127.0.0.1:8332/'
assert logged_url == '127.0.0.1:2332/'
assert in_caplog(caplog, f'daemon #1 at {logged_url} (current)')
assert in_caplog(caplog, 'daemon #2 at 192.168.0.1:8332')
assert in_caplog(caplog, 'daemon #2 at 192.168.0.1:2332')
@pytest.mark.asyncio
@@ -246,10 +240,7 @@ async def test_broadcast_package(daemon):
@pytest.mark.asyncio
async def test_relayfee(daemon):
if isinstance(daemon, FakeEstimateFeeDaemon):
sats = daemon.coin.ESTIMATE_FEE
else:
sats = 2
sats = 2
response = {"relayfee": sats, "other:": "cruft"}
daemon.session = ClientSessionGood(('getnetworkinfo', [], response))
assert await daemon.relayfee() == sats
@@ -288,10 +279,7 @@ async def test_deserialised_block(daemon):
@pytest.mark.asyncio
async def test_estimatefee(daemon):
method_not_found = RPCError(JSONRPCv1.METHOD_NOT_FOUND, 'nope')
if isinstance(daemon, FakeEstimateFeeDaemon):
result = daemon.coin.ESTIMATE_FEE
else:
result = -1
result = -1
daemon.session = ClientSessionGood(
('estimatesmartfee', [], method_not_found),
('estimatefee', [2], result)
@@ -302,8 +290,6 @@ async def test_estimatefee(daemon):
@pytest.mark.asyncio
async def test_estimatefee_smart(daemon):
bad_args = RPCError(JSONRPCv1.INVALID_ARGS, 'bad args')
if isinstance(daemon, FakeEstimateFeeDaemon):
return
rate = 0.0002
result = {'feerate': rate}
daemon.session = ClientSessionGood(
@@ -332,13 +318,6 @@ async def test_getrawtransaction(daemon):
hex_hash, True) == verbose
@pytest.mark.asyncio
async def test_protx(dash_daemon):
protx_hash = 'deadbeaf'
dash_daemon.session = ClientSessionGood(('protx', ['info', protx_hash], {}))
assert await dash_daemon.protx(['info', protx_hash]) == {}
# Batch tests
@pytest.mark.asyncio
+12 -45
View File
@@ -91,56 +91,23 @@ def test_COIN_NET():
'''Test COIN and NET defaults and redirection.'''
setup_base_env()
e = Env()
assert e.coin == lib_coins.BitcoinMainnet
assert e.coin == lib_coins.Palladium
os.environ['NET'] = 'testnet'
e = Env()
assert e.coin == lib_coins.BitcoinTestnet3
assert e.coin == lib_coins.PalladiumTestnet
os.environ['NET'] = ' testnet '
e = Env()
assert e.coin == lib_coins.BitcoinTestnet3
os.environ.pop('NET')
os.environ['COIN'] = ' Litecoin '
e = Env()
assert e.coin == lib_coins.Litecoin
os.environ['NET'] = 'testnet'
e = Env()
assert e.coin == lib_coins.LitecoinTestnet
os.environ.pop('NET')
os.environ['COIN'] = ' BitcoinGold '
e = Env()
assert e.coin == lib_coins.BitcoinGold
os.environ['NET'] = 'testnet'
e = Env()
assert e.coin == lib_coins.BitcoinGoldTestnet
assert e.coin == lib_coins.PalladiumTestnet
os.environ['NET'] = 'regtest'
e = Env()
assert e.coin == lib_coins.BitcoinGoldRegtest
assert e.coin == lib_coins.PalladiumRegtest
os.environ.pop('NET')
os.environ['COIN'] = ' Decred '
os.environ['COIN'] = ' Palladium '
e = Env()
assert e.coin == lib_coins.Decred
os.environ['NET'] = 'testnet'
e = Env()
assert e.coin == lib_coins.DecredTestnet
os.environ.pop('NET')
os.environ['COIN'] = ' BitcoinGreen '
e = Env()
assert e.coin == lib_coins.Bitg
os.environ['NET'] = 'mainnet'
e = Env()
os.environ.pop('NET')
os.environ['COIN'] = ' Pivx '
os.environ['NET'] = 'mainnet'
e = Env()
assert e.coin == lib_coins.Pivx
os.environ['NET'] = 'testnet'
e = Env()
assert e.coin == lib_coins.PivxTestnet
os.environ.pop('NET')
os.environ['NET'] = 'mainnet'
os.environ['COIN'] = ' TokenPay '
e = Env()
assert e.coin == lib_coins.TokenPay
assert e.coin == lib_coins.Palladium
os.environ['COIN'] = 'Bitcoin'
with pytest.raises(lib_coins.CoinError):
Env()
def test_CACHE_MB():
@@ -273,7 +240,7 @@ def test_REPORT_SERVICES_localhost():
def test_REORG_LIMIT():
assert_integer('REORG_LIMIT', 'reorg_limit',
lib_coins.Bitcoin.REORG_LIMIT)
lib_coins.Palladium.REORG_LIMIT)
def test_COST_HARD_LIMIT():
@@ -426,5 +393,5 @@ def test_ban_versions():
def test_coin_class_provided():
e = Env(lib_coins.Bitcoin)
assert e.coin == lib_coins.Bitcoin
e = Env(lib_coins.Palladium)
assert e.coin == lib_coins.Palladium
+2 -2
View File
@@ -12,13 +12,13 @@ import pytest
from aiorpcx import Event, sleep, ignore_after
from electrumx.server.mempool import MemPool, MemPoolAPI
from electrumx.lib.coins import BitcoinCash
from electrumx.lib.coins import Palladium
from electrumx.lib.hash import HASHX_LEN, hex_str_to_hash, hash_to_hex_str
from electrumx.lib.tx import Tx, TxInput, TxOutput
from electrumx.lib.util import OldTaskGroup
coin = BitcoinCash
coin = Palladium
tx_hash_fn = coin.DESERIALIZER.TX_HASH_FN
# Change seed daily
seed(datetime.date.today().toordinal())