46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""B3 — smoke of the local regtest: the node, Fulcrum and our profile agree (ADR-58, ELC-30)."""
|
|
|
|
import asyncio
|
|
|
|
from plm_engine.electrum.scripthash import address_to_scripthash
|
|
from plm_engine.network import REGTEST
|
|
|
|
|
|
def test_the_node_is_on_regtest_and_mines_a_block(regtest_node):
|
|
before = regtest_node.height()
|
|
hashes = regtest_node.mine(1)
|
|
assert len(hashes) == 1 and regtest_node.height() == before + 1
|
|
|
|
|
|
def test_the_node_accepts_our_regtest_addresses(regtest_node, fresh_address):
|
|
assert fresh_address.startswith("rplm1")
|
|
assert regtest_node.rpc("validateaddress", fresh_address)["isvalid"] is True
|
|
|
|
|
|
def test_the_node_has_the_genesis_of_our_profile(regtest_node):
|
|
assert regtest_node.rpc("getblockhash", 0) == REGTEST.genesis_hash
|
|
|
|
|
|
async def test_fulcrum_follows_the_node_tip(regtest_node, electrum):
|
|
"""Fulcrum indexes asynchronously: give it a moment after a new block."""
|
|
regtest_node.mine(1)
|
|
expected = regtest_node.height()
|
|
for _ in range(40):
|
|
tip = (await electrum.subscribe_headers())["height"]
|
|
if tip == expected:
|
|
break
|
|
await asyncio.sleep(0.25)
|
|
assert tip == expected
|
|
|
|
|
|
async def test_funds_sent_to_an_address_are_seen_through_electrum(regtest_node, electrum, fresh_address):
|
|
regtest_node.fund(fresh_address, 1.5)
|
|
scripthash = address_to_scripthash(fresh_address)
|
|
utxos = []
|
|
for _ in range(40):
|
|
utxos = await electrum.listunspent(scripthash)
|
|
if utxos:
|
|
break
|
|
await asyncio.sleep(0.25)
|
|
assert [u["value"] for u in utxos] == [150_000_000]
|