mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
ui: Rename unconfirmed balance to pending, include immature balance.
This commit is contained in:
@@ -38,6 +38,7 @@ from basicswap.rpc import (
|
||||
from tests.basicswap.common import (
|
||||
BASE_RPC_PORT,
|
||||
BTC_BASE_RPC_PORT,
|
||||
LTC_BASE_RPC_PORT,
|
||||
)
|
||||
from tests.basicswap.util import (
|
||||
make_boolean,
|
||||
@@ -59,6 +60,7 @@ UI_PORT = 12700 + PORT_OFS
|
||||
|
||||
PARTICL_RPC_PORT_BASE = int(os.getenv('PARTICL_RPC_PORT_BASE', BASE_RPC_PORT))
|
||||
BITCOIN_RPC_PORT_BASE = int(os.getenv('BITCOIN_RPC_PORT_BASE', BTC_BASE_RPC_PORT))
|
||||
LITECOIN_RPC_PORT_BASE = int(os.getenv('LITECOIN_RPC_PORT_BASE', LTC_BASE_RPC_PORT))
|
||||
XMR_BASE_RPC_PORT = int(os.getenv('XMR_BASE_RPC_PORT', XMR_BASE_RPC_PORT))
|
||||
TEST_COINS_LIST = os.getenv('TEST_COINS_LIST', 'bitcoin,monero')
|
||||
|
||||
@@ -81,6 +83,11 @@ def callbtcrpc(node_id, method, params=[], wallet=None, base_rpc_port=BITCOIN_RP
|
||||
return callrpc(base_rpc_port + node_id, auth, method, params, wallet)
|
||||
|
||||
|
||||
def callltcrpc(node_id, method, params=[], wallet=None, base_rpc_port=LITECOIN_RPC_PORT_BASE + PORT_OFS):
|
||||
auth = 'test_ltc_{0}:test_ltc_pwd_{0}'.format(node_id)
|
||||
return callrpc(base_rpc_port + node_id, auth, method, params, wallet)
|
||||
|
||||
|
||||
def updateThread(cls):
|
||||
while not cls.delay_event.is_set():
|
||||
try:
|
||||
@@ -167,11 +174,28 @@ class Test(unittest.TestCase):
|
||||
logging.info('XMR blocks: %d', callrpc_xmr(XMR_BASE_RPC_PORT + 1, 'get_block_count', auth=xmr_auth)['count'])
|
||||
|
||||
self.btc_addr = callbtcrpc(0, 'getnewaddress', ['mining_addr', 'bech32'])
|
||||
num_blocks = 500 # Mine enough to activate segwit
|
||||
if callbtcrpc(0, 'getblockchaininfo')['blocks'] < num_blocks:
|
||||
num_blocks: int = 500 # Mine enough to activate segwit
|
||||
if callbtcrpc(0, 'getblockcount') < num_blocks:
|
||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, self.btc_addr)
|
||||
callbtcrpc(0, 'generatetoaddress', [num_blocks, self.btc_addr])
|
||||
logging.info('BTC blocks: %d', callbtcrpc(0, 'getblockchaininfo')['blocks'])
|
||||
logging.info('BTC blocks: %d', callbtcrpc(0, 'getblockcount'))
|
||||
|
||||
if 'litecoin' in TEST_COINS_LIST:
|
||||
self.ltc_addr = callltcrpc(0, 'getnewaddress', ['mining_addr'], wallet='wallet.dat')
|
||||
num_blocks: int = 431
|
||||
have_blocks: int = callltcrpc(0, 'getblockcount')
|
||||
if have_blocks < 500:
|
||||
logging.info('Mining %d Litecoin blocks to %s', num_blocks, self.ltc_addr)
|
||||
callltcrpc(0, 'generatetoaddress', [num_blocks - have_blocks, self.ltc_addr], wallet='wallet.dat')
|
||||
|
||||
# https://github.com/litecoin-project/litecoin/issues/807
|
||||
# Block 432 is when MWEB activates. It requires a peg-in. You'll need to generate an mweb address and send some coins to it. Then it will allow you to mine the next block.
|
||||
mweb_addr = callltcrpc(0, 'getnewaddress', ['mweb_addr', 'mweb'], wallet='mweb')
|
||||
callltcrpc(0, 'sendtoaddress', [mweb_addr, 1.0], wallet='wallet.dat')
|
||||
num_blocks = 69
|
||||
|
||||
have_blocks: int = callltcrpc(0, 'getblockcount')
|
||||
callltcrpc(0, 'generatetoaddress', [500 - have_blocks, self.ltc_addr], wallet='wallet.dat')
|
||||
|
||||
# Lower output split threshold for more stakeable outputs
|
||||
for i in range(NUM_NODES):
|
||||
|
||||
@@ -575,7 +575,7 @@ class BasicSwapTest(TestFunctions):
|
||||
swap_clients = self.swap_clients
|
||||
ci = self.swap_clients[0].ci(self.test_coin_from)
|
||||
|
||||
self.check_softfork_active('bip66')
|
||||
self.check_softfork_active('csv')
|
||||
|
||||
script = CScript([3, OP_CHECKSEQUENCEVERIFY, ])
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2021-2023 tecnovert
|
||||
# Copyright (c) 2021-2024 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -27,7 +27,8 @@ from tests.basicswap.common import (
|
||||
TEST_HTTP_PORT,
|
||||
LTC_BASE_RPC_PORT,
|
||||
)
|
||||
from .test_btc_xmr import BasicSwapTest, test_delay_event, callnoderpc
|
||||
from .test_btc_xmr import BasicSwapTest, test_delay_event
|
||||
from .test_xmr import pause_event
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@@ -38,13 +39,6 @@ class TestLTC(BasicSwapTest):
|
||||
start_ltc_nodes = True
|
||||
base_rpc_port = LTC_BASE_RPC_PORT
|
||||
|
||||
@classmethod
|
||||
def prepareExtraCoins(cls):
|
||||
logging.info('Mining {} chain to height 1352 to activate CVS (BIP66)'.format(cls.test_coin_from.name))
|
||||
chain_height = callnoderpc(0, 'getblockcount', base_rpc_port=LTC_BASE_RPC_PORT)
|
||||
num_blocks: int = 1352 - chain_height
|
||||
callnoderpc(0, 'generatetoaddress', [num_blocks, cls.ltc_addr], base_rpc_port=LTC_BASE_RPC_PORT)
|
||||
|
||||
def mineBlock(self, num_blocks=1):
|
||||
self.callnoderpc('generatetoaddress', [num_blocks, self.ltc_addr])
|
||||
|
||||
@@ -137,7 +131,24 @@ class TestLTC(BasicSwapTest):
|
||||
addr_info1 = ci1.rpc_wallet('getaddressinfo', [mweb_addr_1,])
|
||||
assert (addr_info1['ismweb'] is True)
|
||||
|
||||
txid = ci0.rpc_wallet('sendtoaddress', [mweb_addr_0, 10.0])
|
||||
trusted_before = ci0.rpc_wallet('getbalances')['mine']['trusted']
|
||||
ci0.rpc_wallet('sendtoaddress', [mweb_addr_0, 10.0])
|
||||
assert (trusted_before - float(ci0.rpc_wallet('getbalances')['mine']['trusted']) < 0.1)
|
||||
|
||||
try:
|
||||
pause_event.clear() # Stop mining
|
||||
ci0.rpc_wallet('sendtoaddress', [mweb_addr_1, 10.0])
|
||||
|
||||
found_unconfirmed: bool = False
|
||||
for i in range(20):
|
||||
test_delay_event.wait(1)
|
||||
ltc_wallet = read_json_api(TEST_HTTP_PORT + 1, 'wallets/ltc')
|
||||
if float(ltc_wallet['unconfirmed']) == 10.0:
|
||||
found_unconfirmed = True
|
||||
break
|
||||
finally:
|
||||
pause_event.set()
|
||||
assert (found_unconfirmed)
|
||||
|
||||
self.mineBlock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user