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:
1 parent
671a94cf4e
commit
73c96101bd
182 files changed
+74
-9665
No files matched your search
+5
-35
@@ -30,37 +30,11 @@ from binascii import unhexlify
|
||||
|
||||
import pytest
|
||||
|
||||
from electrumx.lib import coins
|
||||
from electrumx.lib.coins import Coin
|
||||
from electrumx.lib.hash import hex_str_to_hash
|
||||
from electrumx.lib.util import subclasses
|
||||
|
||||
|
||||
def _does_coin_require_testcase(coin: Coin) -> bool:
|
||||
if coin.NET != 'mainnet':
|
||||
return False
|
||||
# legacy whitelist: these coins do not have tests. FIXME
|
||||
if coin in [
|
||||
coins.BitcoinCash,
|
||||
coins.Viacoin,
|
||||
coins.Argentum,
|
||||
coins.FairCoin,
|
||||
coins.Einsteinium,
|
||||
coins.Crown,
|
||||
coins.Monaize,
|
||||
coins.Bitbay,
|
||||
coins.Fujicoin,
|
||||
coins.Neblio,
|
||||
coins.Bitzeny,
|
||||
coins.Sibcoin,
|
||||
coins.CanadaeCoin,
|
||||
coins.Auroracoin,
|
||||
]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
coin_classes_all = set([coin for coin in subclasses(Coin) if _does_coin_require_testcase(coin)])
|
||||
coin_classes_all = set([coin for coin in subclasses(Coin) if coin.NET == 'mainnet'])
|
||||
coin_classes_tested = set()
|
||||
|
||||
BLOCKS_DIR = os.path.join(
|
||||
@@ -69,15 +43,15 @@ BLOCKS_DIR = os.path.join(
|
||||
# Find testcases
|
||||
blocks = []
|
||||
|
||||
for name in os.listdir(BLOCKS_DIR):
|
||||
for name in sorted(os.listdir(BLOCKS_DIR)):
|
||||
try:
|
||||
name_parts = name.split("_")
|
||||
coin = Coin.lookup_coin_class(name_parts[0], name_parts[1])
|
||||
if _does_coin_require_testcase(coin):
|
||||
if coin.NET == 'mainnet':
|
||||
coin_classes_tested.add(coin)
|
||||
with open(os.path.join(BLOCKS_DIR, name)) as f:
|
||||
blocks.append((coin, json.load(f)))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
blocks.append(pytest.fail(name))
|
||||
|
||||
|
||||
@@ -92,11 +66,7 @@ def test_block(block_details):
|
||||
raw_block = unhexlify(block_info['block'])
|
||||
block = coin.block(raw_block, block_info['height'])
|
||||
|
||||
try:
|
||||
assert coin.header_hash_rev(
|
||||
block.header) == hex_str_to_hash(block_info['hash'])
|
||||
except ImportError as e:
|
||||
pytest.skip(str(e))
|
||||
assert coin.header_hash_rev(block.header) == hex_str_to_hash(block_info['hash'])
|
||||
assert (coin.header_prevhash_rev(block.header)
|
||||
== hex_str_to_hash(block_info['previousblockhash']))
|
||||
assert len(block_info['tx']) == len(block.transactions)
|
||||
|
||||
Reference in new issue
Block a user