mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
ui: Split wallet page
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
import urllib
|
||||
import signal
|
||||
import logging
|
||||
import urllib
|
||||
from urllib.request import urlopen
|
||||
|
||||
from basicswap.rpc import callrpc
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2020-2021 tecnovert
|
||||
# Copyright (c) 2020-2022 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -149,18 +149,18 @@ class XmrTestBase(unittest.TestCase):
|
||||
|
||||
waitForServer(self.delay_event, 12701)
|
||||
|
||||
def waitForDepositAddress():
|
||||
def waitForMainAddress():
|
||||
for i in range(20):
|
||||
if self.delay_event.is_set():
|
||||
raise ValueError('Test stopped.')
|
||||
try:
|
||||
wallets = json.loads(urlopen('http://127.0.0.1:12701/json/wallets').read())
|
||||
return wallets['6']['deposit_address']
|
||||
return wallets['6']['main_address']
|
||||
except Exception as e:
|
||||
print('Waiting for deposit address {}'.format(str(e)))
|
||||
print('Waiting for main address {}'.format(str(e)))
|
||||
self.delay_event.wait(1)
|
||||
raise ValueError('waitForDepositAddress timedout')
|
||||
xmr_addr1 = waitForDepositAddress()
|
||||
raise ValueError('waitForMainAddress timedout')
|
||||
xmr_addr1 = waitForMainAddress()
|
||||
|
||||
num_blocks = 100
|
||||
|
||||
@@ -178,11 +178,15 @@ class XmrTestBase(unittest.TestCase):
|
||||
for i in range(60):
|
||||
if self.delay_event.is_set():
|
||||
raise ValueError('Test stopped.')
|
||||
wallets = json.loads(urlopen('http://127.0.0.1:12701/json/wallets').read())
|
||||
particl_blocks = wallets['1']['blocks']
|
||||
print('particl_blocks', particl_blocks)
|
||||
if particl_blocks >= num_blocks:
|
||||
break
|
||||
try:
|
||||
wallets = json.loads(urlopen('http://127.0.0.1:12701/json/wallets').read())
|
||||
particl_blocks = wallets['1']['blocks']
|
||||
print('particl_blocks', particl_blocks)
|
||||
if particl_blocks >= num_blocks:
|
||||
break
|
||||
except Exception as e:
|
||||
print('Error reading wallets', str(e))
|
||||
|
||||
self.delay_event.wait(1)
|
||||
assert(particl_blocks >= num_blocks)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2021 tecnovert
|
||||
# Copyright (c) 2021-2022 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -266,7 +266,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
wallets = json.loads(urlopen('http://127.0.0.1:{}/json/wallets'.format(UI_PORT + 1)).read())
|
||||
|
||||
self.xmr_addr = wallets['6']['deposit_address']
|
||||
self.xmr_addr = wallets['6']['main_address']
|
||||
num_blocks = 100
|
||||
if callrpc_xmr_na(XMR_BASE_RPC_PORT + 1, 'get_block_count')['count'] < num_blocks:
|
||||
logging.info('Mining {} Monero blocks to {}.'.format(num_blocks, self.xmr_addr))
|
||||
|
||||
48
tests/basicswap/selenium/test_wallets.py
Normal file
48
tests/basicswap/selenium/test_wallets.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2022 tecnovert
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
"""
|
||||
cd /tmp
|
||||
wget -4 https://chromedriver.storage.googleapis.com/96.0.4664.45/chromedriver_linux64.zip
|
||||
7z x chromedriver_linux64.zip
|
||||
sudo mv chromedriver /opt/chromedriver96
|
||||
|
||||
|
||||
python tests/basicswap/extended/test_xmr_persistent.py
|
||||
|
||||
python tests/basicswap/selenium/test_wallets.py
|
||||
|
||||
html = driver.page_source
|
||||
print('html', html)
|
||||
|
||||
"""
|
||||
|
||||
import time
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
|
||||
|
||||
def test_html():
|
||||
base_url = 'http://localhost:12701'
|
||||
|
||||
driver = webdriver.Chrome(service=Service('/opt/chromedriver96'))
|
||||
url = base_url + '/wallets'
|
||||
driver.get(url)
|
||||
|
||||
time.sleep(1)
|
||||
driver.refresh()
|
||||
|
||||
driver.find_element(By.ID, "refresh").click()
|
||||
time.sleep(1)
|
||||
driver.refresh()
|
||||
|
||||
driver.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_html()
|
||||
Reference in New Issue
Block a user