MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_bip86_index_boundaries

Function test_bip86_index_boundaries

tests/test_wallet.py:1977–2006  ·  view source on GitHub ↗

Test BIP86 behavior at index boundaries

(node_factory)

Source from the content-addressed store, hash-verified

1975
1976@unittest.skipIf(TEST_NETWORK != 'regtest', "BIP86 tests are regtest-specific")
1977def test_bip86_index_boundaries(node_factory):
1978 """Test BIP86 behavior at index boundaries"""
1979 l1 = setup_bip86_node(node_factory)
1980
1981 # Test that we can generate multiple addresses in sequence
1982 # This tests the internal index management
1983 addresses = []
1984 for i in range(5):
1985 addr = l1.rpc.newaddr('p2tr')['p2tr']
1986 addresses.append(addr)
1987 # Each address should be unique
1988 assert addr not in addresses[:-1], f"Duplicate address generated: {addr}"
1989
1990 # Test that addresses are deterministic - same node should generate same sequence
1991 l2 = setup_bip86_node(node_factory) # Same mnemonic
1992
1993 addresses2 = []
1994 for i in range(5):
1995 addr = l2.rpc.newaddr('p2tr')['p2tr']
1996 addresses2.append(addr)
1997
1998 # Should generate the same addresses in the same order
1999 assert addresses == addresses2, "BIP86 addresses not deterministic across nodes with same mnemonic"
2000
2001 # Test generating a large number of addresses to check for any overflow issues
2002 # Generate 100 more addresses to test higher indices
2003 for i in range(100):
2004 addr = l1.rpc.newaddr('p2tr')['p2tr']
2005 assert addr.startswith('bcrt1p'), f"Invalid BIP86 address format: {addr}"
2006 assert len(addr) > 50, f"BIP86 address too short: {addr}"
2007
2008
2009@unittest.skipIf(TEST_NETWORK != 'regtest', "BIP86 tests are regtest-specific")

Callers

nothing calls this directly

Calls 2

setup_bip86_nodeFunction · 0.85
newaddrMethod · 0.45

Tested by

no test coverage detected