mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
refactor: E275 missing whitespace after keyword
This commit is contained in:
@@ -83,11 +83,11 @@ def prepareDataDir(datadir, node_id, conf_file, dir_prefix, base_p2p_port=BASE_P
|
||||
|
||||
def checkForks(ro):
|
||||
if 'bip9_softforks' in ro:
|
||||
assert(ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
assert(ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
else:
|
||||
assert(ro['softforks']['csv']['active'])
|
||||
assert(ro['softforks']['segwit']['active'])
|
||||
assert (ro['softforks']['csv']['active'])
|
||||
assert (ro['softforks']['segwit']['active'])
|
||||
|
||||
|
||||
def stopDaemons(daemons):
|
||||
@@ -118,7 +118,7 @@ def wait_for_bid(delay_event, swap_client, bid_id, state=None, sent=False, wait_
|
||||
'bid_id': bid_id,
|
||||
}
|
||||
bids = swap_client.listBids(sent=sent, filters=filters)
|
||||
assert(len(bids) < 2)
|
||||
assert (len(bids) < 2)
|
||||
for bid in bids:
|
||||
if bid[2] == bid_id:
|
||||
if type(state) == list:
|
||||
@@ -377,9 +377,9 @@ def compare_bid_states(states, expect_states, exact_match=True):
|
||||
del states[i]
|
||||
|
||||
if exact_match:
|
||||
assert(len(states) == len(expect_states))
|
||||
assert (len(states) == len(expect_states))
|
||||
else:
|
||||
assert(len(states) >= len(expect_states))
|
||||
assert (len(states) >= len(expect_states))
|
||||
|
||||
for i in range(len(expect_states)):
|
||||
s = states[i]
|
||||
@@ -391,5 +391,5 @@ def compare_bid_states(states, expect_states, exact_match=True):
|
||||
logging.warning(f'Expected state {expect_states[i]} found out of order at the same time as {s[1]}.')
|
||||
continue
|
||||
raise ValueError(f'Expected state {expect_states[i]}, found {s[1]}')
|
||||
assert(s[1] == expect_states[i])
|
||||
assert (s[1] == expect_states[i])
|
||||
return True
|
||||
|
||||
@@ -322,7 +322,7 @@ class XmrTestBase(TestBase):
|
||||
print('Error reading wallets', str(e))
|
||||
|
||||
self.delay_event.wait(1)
|
||||
assert(particl_blocks >= num_blocks)
|
||||
assert particl_blocks >= num_blocks
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
|
||||
@@ -59,7 +59,7 @@ def run_test():
|
||||
driver.get(base_url)
|
||||
link = driver.find_element_by_xpath('//a[@href="/offers"]')
|
||||
num_offers_end = int(link.text.split(':')[1].strip())
|
||||
assert(num_offers_end == num_offers_start + 1)
|
||||
assert num_offers_end == num_offers_start + 1
|
||||
|
||||
driver.quit()
|
||||
|
||||
|
||||
@@ -319,11 +319,11 @@ class Test(unittest.TestCase):
|
||||
|
||||
ro = nmcRpc('getblockchaininfo')
|
||||
try:
|
||||
assert(ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
except Exception:
|
||||
logging.info('nmc: csv is not active')
|
||||
try:
|
||||
assert(ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
except Exception:
|
||||
logging.info('nmc: segwit is not active')
|
||||
|
||||
@@ -354,7 +354,7 @@ class Test(unittest.TestCase):
|
||||
if particl_blocks >= num_blocks:
|
||||
break
|
||||
delay_event.wait(1)
|
||||
assert(particl_blocks >= num_blocks)
|
||||
assert (particl_blocks >= num_blocks)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -382,7 +382,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
wait_for_offer(delay_event, swap_clients[1], offer_id)
|
||||
offers = swap_clients[1].listOffers()
|
||||
assert(len(offers) == 1)
|
||||
assert (len(offers) == 1)
|
||||
for offer in offers:
|
||||
if offer.offer_id == offer_id:
|
||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
||||
@@ -398,8 +398,8 @@ class Test(unittest.TestCase):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_03_nmc_part(self):
|
||||
logging.info('---------- Test NMC to PART')
|
||||
@@ -423,8 +423,8 @@ class Test(unittest.TestCase):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_04_nmc_btc(self):
|
||||
logging.info('---------- Test NMC to BTC')
|
||||
@@ -451,8 +451,8 @@ class Test(unittest.TestCase):
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_05_refund(self):
|
||||
# Seller submits initiate txn, buyer doesn't respond
|
||||
@@ -477,8 +477,8 @@ class Test(unittest.TestCase):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_06_self_bid(self):
|
||||
logging.info('---------- Test same client, BTC to NMC')
|
||||
@@ -501,8 +501,8 @@ class Test(unittest.TestCase):
|
||||
wait_for_bid(delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_0['num_recv_bids'] == js_0_before['num_recv_bids'] + 1 and js_0['num_sent_bids'] == js_0_before['num_sent_bids'] + 1)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_recv_bids'] == js_0_before['num_recv_bids'] + 1 and js_0['num_sent_bids'] == js_0_before['num_sent_bids'] + 1)
|
||||
|
||||
def test_07_error(self):
|
||||
logging.info('---------- Test error, BTC to NMC, set fee above bid value')
|
||||
|
||||
@@ -82,19 +82,19 @@ class Test(unittest.TestCase):
|
||||
waitForServer(self.delay_event, 12700)
|
||||
|
||||
wallets_0 = read_json_api(12700, 'wallets')
|
||||
assert(wallets_0['PART']['expected_seed'] is True)
|
||||
assert(wallets_0['XMR']['expected_seed'] is True)
|
||||
assert (wallets_0['PART']['expected_seed'] is True)
|
||||
assert (wallets_0['XMR']['expected_seed'] is True)
|
||||
|
||||
waitForServer(self.delay_event, 12701)
|
||||
wallets_1 = read_json_api(12701, 'wallets')
|
||||
|
||||
assert(wallets_0['PART']['expected_seed'] is True)
|
||||
assert(wallets_1['XMR']['expected_seed'] is True)
|
||||
assert (wallets_0['PART']['expected_seed'] is True)
|
||||
assert (wallets_1['XMR']['expected_seed'] is True)
|
||||
|
||||
# TODO: Check other coins
|
||||
|
||||
assert(wallets_0['PART']['deposit_address'] == wallets_1['1']['deposit_address'])
|
||||
assert(wallets_0['XMR']['deposit_address'] == wallets_1['6']['deposit_address'])
|
||||
assert (wallets_0['PART']['deposit_address'] == wallets_1['1']['deposit_address'])
|
||||
assert (wallets_0['XMR']['deposit_address'] == wallets_1['6']['deposit_address'])
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class Test(TestBase):
|
||||
|
||||
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
||||
summary = read_json_api(12700)
|
||||
assert(summary['num_sent_offers'] == 1)
|
||||
assert (summary['num_sent_offers'] == 1)
|
||||
|
||||
logger.info('Waiting for offer')
|
||||
waitForNumOffers(self.delay_event, 12701, 1)
|
||||
@@ -170,8 +170,8 @@ class Test(TestBase):
|
||||
|
||||
ltc_original = read_json_api(12700, 'wallets/ltc')
|
||||
ltc_restored = read_json_api(12703, 'wallets/ltc')
|
||||
assert(float(ltc_original['balance']) + float(ltc_original['unconfirmed']) > 0.0)
|
||||
assert(float(ltc_original['balance']) + float(ltc_original['unconfirmed']) == float(ltc_restored['balance']) + float(ltc_restored['unconfirmed']))
|
||||
assert (float(ltc_original['balance']) + float(ltc_original['unconfirmed']) > 0.0)
|
||||
assert (float(ltc_original['balance']) + float(ltc_original['unconfirmed']) == float(ltc_restored['balance']) + float(ltc_restored['unconfirmed']))
|
||||
|
||||
wallets_original = read_json_api(12700, 'wallets')
|
||||
# TODO: After restoring a new deposit address should be generated, should be automated
|
||||
@@ -180,7 +180,7 @@ class Test(TestBase):
|
||||
next_addr = read_json_api(12703, 'wallets/part/nextdepositaddr')
|
||||
wallets_restored = read_json_api(12703, 'wallets')
|
||||
for k, w in wallets_original.items():
|
||||
assert(w['deposit_address'] == wallets_restored[k]['deposit_address'])
|
||||
assert (w['deposit_address'] == wallets_restored[k]['deposit_address'])
|
||||
|
||||
logging.info('Test passed.')
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ class Test(unittest.TestCase):
|
||||
self.delay_event.wait(1)
|
||||
|
||||
logging.info('PART blocks: %d', callpartrpc(0, 'getblockchaininfo')['blocks'])
|
||||
assert(particl_blocks >= num_blocks)
|
||||
assert particl_blocks >= num_blocks
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
|
||||
@@ -88,12 +88,12 @@ class Test(BaseTest):
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
js_1 = read_json_api(1801, 'wallets')
|
||||
node1_from_after = self.getBalance(js_1)
|
||||
assert(node1_from_after > node1_from_before + (amount_from - 0.05))
|
||||
assert (node1_from_after > node1_from_before + (amount_from - 0.05))
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets')
|
||||
node0_from_after = self.getBalance(js_0)
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_after < node0_from_before - amount_from)
|
||||
# assert (node0_from_after < node0_from_before - amount_from)
|
||||
|
||||
js_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||
js_1_xmr_after = read_json_api(1801, 'wallets/xmr')
|
||||
@@ -103,7 +103,7 @@ class Test(BaseTest):
|
||||
amount_to_float = float(format_amount(amount_to, 12))
|
||||
node1_xmr_after = float(js_1_xmr_after['unconfirmed']) + float(js_1_xmr_after['balance'])
|
||||
node1_xmr_before = float(js_1_xmr['unconfirmed']) + float(js_1_xmr['balance'])
|
||||
assert(node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
assert (node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
|
||||
def test_02_leader_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test {} to XMR leader recovers coin a lock tx'.format(str(self.test_coin_from)))
|
||||
@@ -125,7 +125,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
|
||||
@@ -138,7 +138,7 @@ class Test(BaseTest):
|
||||
node0_from_after = self.getBalance(js_w0_after)
|
||||
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_before - node0_from_after < 0.02)
|
||||
# assert (node0_from_before - node0_from_after < 0.02)
|
||||
|
||||
def test_03_follower_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test {} to XMR follower recovers coin a lock tx'.format(str(self.test_coin_from)))
|
||||
@@ -160,7 +160,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
swap_clients[0].setBidDebugInd(bid_id, DebugTypes.BID_DONT_SPEND_COIN_A_LOCK_REFUND)
|
||||
@@ -176,7 +176,7 @@ class Test(BaseTest):
|
||||
node1_from_after = self.getBalance(js_w1_after)
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
# TODO: Discard block rewards
|
||||
# assert(node1_from_after - node1_from_before > (amount_from - 0.02))
|
||||
# assert (node1_from_after - node1_from_before > (amount_from - 0.02))
|
||||
|
||||
swap_clients[0].abandonBid(bid_id)
|
||||
|
||||
@@ -204,7 +204,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||
swap_clients[0].acceptXmrBid(bid_id)
|
||||
@@ -219,11 +219,11 @@ class Test(BaseTest):
|
||||
node0_from_after = self.getBalance(js_w0_after)
|
||||
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_before - node0_from_after < 0.02)
|
||||
# assert (node0_from_before - node0_from_after < 0.02)
|
||||
|
||||
node1_xmr_before = self.getXmrBalance(js_w1_before)
|
||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
||||
assert(node1_xmr_before - node1_xmr_after < 0.02)
|
||||
assert (node1_xmr_before - node1_xmr_after < 0.02)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -109,12 +109,12 @@ class Test(BaseTest):
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
js_1 = read_json_api(1801, 'wallets')
|
||||
node1_from_after = self.getBalance(js_1)
|
||||
assert(node1_from_after > node1_from_before + (amount_from - 0.05))
|
||||
assert (node1_from_after > node1_from_before + (amount_from - 0.05))
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets')
|
||||
node0_from_after = self.getBalance(js_0)
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_after < node0_from_before - amount_from)
|
||||
# assert (node0_from_after < node0_from_before - amount_from)
|
||||
|
||||
js_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||
js_1_xmr_after = read_json_api(1801, 'wallets/xmr')
|
||||
@@ -124,7 +124,7 @@ class Test(BaseTest):
|
||||
amount_to_float = float(format_amount(amount_to, 12))
|
||||
node1_xmr_after = float(js_1_xmr_after['unconfirmed']) + float(js_1_xmr_after['balance'])
|
||||
node1_xmr_before = float(js_1_xmr['unconfirmed']) + float(js_1_xmr['balance'])
|
||||
assert(node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
assert (node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
|
||||
def test_02_leader_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test {} to XMR leader recovers coin a lock tx'.format(str(self.test_coin_from)))
|
||||
@@ -146,7 +146,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
|
||||
@@ -159,7 +159,7 @@ class Test(BaseTest):
|
||||
node0_from_after = self.getBalance(js_w0_after)
|
||||
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_before - node0_from_after < 0.02)
|
||||
# assert (node0_from_before - node0_from_after < 0.02)
|
||||
|
||||
def test_03_follower_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test {} to XMR follower recovers coin a lock tx'.format(str(self.test_coin_from)))
|
||||
@@ -181,7 +181,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
swap_clients[0].setBidDebugInd(bid_id, DebugTypes.BID_DONT_SPEND_COIN_A_LOCK_REFUND)
|
||||
@@ -196,7 +196,7 @@ class Test(BaseTest):
|
||||
node1_from_after = self.getBalance(js_w1_after)
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
# TODO: Discard block rewards
|
||||
# assert(node1_from_after - node1_from_before > (amount_from - 0.02))
|
||||
# assert (node1_from_after - node1_from_before > (amount_from - 0.02))
|
||||
|
||||
swap_clients[0].abandonBid(bid_id)
|
||||
|
||||
@@ -224,7 +224,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||
swap_clients[0].acceptXmrBid(bid_id)
|
||||
@@ -239,11 +239,11 @@ class Test(BaseTest):
|
||||
node0_from_after = self.getBalance(js_w0_after)
|
||||
|
||||
# TODO: Discard block rewards
|
||||
# assert(node0_from_before - node0_from_after < 0.02)
|
||||
# assert (node0_from_before - node0_from_after < 0.02)
|
||||
|
||||
node1_xmr_before = self.getXmrBalance(js_w1_before)
|
||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
||||
assert(node1_xmr_before - node1_xmr_after < 0.02)
|
||||
assert (node1_xmr_before - node1_xmr_after < 0.02)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -44,8 +44,8 @@ class Test(unittest.TestCase):
|
||||
def test_case(v, nb=None):
|
||||
b = SerialiseNum(v)
|
||||
if nb is not None:
|
||||
assert(len(b) == nb)
|
||||
assert(v == DeserialiseNum(b))
|
||||
assert (len(b) == nb)
|
||||
assert (v == DeserialiseNum(b))
|
||||
test_case(0, 1)
|
||||
test_case(1, 1)
|
||||
test_case(16, 1)
|
||||
@@ -66,35 +66,35 @@ class Test(unittest.TestCase):
|
||||
time_val = 48 * 60 * 60
|
||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
||||
decoded = ci.decodeSequence(encoded)
|
||||
assert(decoded >= time_val)
|
||||
assert(decoded <= time_val + 512)
|
||||
assert (decoded >= time_val)
|
||||
assert (decoded <= time_val + 512)
|
||||
|
||||
time_val = 24 * 60
|
||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
||||
decoded = ci.decodeSequence(encoded)
|
||||
assert(decoded >= time_val)
|
||||
assert(decoded <= time_val + 512)
|
||||
assert (decoded >= time_val)
|
||||
assert (decoded <= time_val + 512)
|
||||
|
||||
blocks_val = 123
|
||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_BLOCKS, blocks_val)
|
||||
decoded = ci.decodeSequence(encoded)
|
||||
assert(decoded == blocks_val)
|
||||
assert (decoded == blocks_val)
|
||||
|
||||
def test_make_int(self):
|
||||
def test_case(vs, vf, expect_int):
|
||||
i = make_int(vs)
|
||||
assert(i == expect_int and isinstance(i, int))
|
||||
assert (i == expect_int and isinstance(i, int))
|
||||
i = make_int(vf)
|
||||
assert(i == expect_int and isinstance(i, int))
|
||||
assert (i == expect_int and isinstance(i, int))
|
||||
vs_out = format_amount(i, 8)
|
||||
# Strip
|
||||
for i in range(7):
|
||||
if vs_out[-1] == '0':
|
||||
vs_out = vs_out[:-1]
|
||||
if '.' in vs:
|
||||
assert(vs_out == vs)
|
||||
assert (vs_out == vs)
|
||||
else:
|
||||
assert(vs_out[:-2] == vs)
|
||||
assert (vs_out[:-2] == vs)
|
||||
test_case('0', 0, 0)
|
||||
test_case('1', 1, 100000000)
|
||||
test_case('10', 10, 1000000000)
|
||||
@@ -113,49 +113,49 @@ class Test(unittest.TestCase):
|
||||
|
||||
try:
|
||||
make_int('0.123456789')
|
||||
assert(False)
|
||||
assert (False)
|
||||
except Exception as e:
|
||||
assert(str(e) == 'Mantissa too long')
|
||||
assert (str(e) == 'Mantissa too long')
|
||||
validate_amount('0.12345678')
|
||||
|
||||
# floor
|
||||
assert(make_int('0.123456789', r=-1) == 12345678)
|
||||
assert (make_int('0.123456789', r=-1) == 12345678)
|
||||
# Round up
|
||||
assert(make_int('0.123456789', r=1) == 12345679)
|
||||
assert (make_int('0.123456789', r=1) == 12345679)
|
||||
|
||||
def test_make_int12(self):
|
||||
def test_case(vs, vf, expect_int):
|
||||
i = make_int(vs, 12)
|
||||
assert(i == expect_int and isinstance(i, int))
|
||||
assert (i == expect_int and isinstance(i, int))
|
||||
i = make_int(vf, 12)
|
||||
assert(i == expect_int and isinstance(i, int))
|
||||
assert (i == expect_int and isinstance(i, int))
|
||||
vs_out = format_amount(i, 12)
|
||||
# Strip
|
||||
for i in range(7):
|
||||
if vs_out[-1] == '0':
|
||||
vs_out = vs_out[:-1]
|
||||
if '.' in vs:
|
||||
assert(vs_out == vs)
|
||||
assert (vs_out == vs)
|
||||
else:
|
||||
assert(vs_out[:-2] == vs)
|
||||
assert (vs_out[:-2] == vs)
|
||||
test_case('0.123456789', 0.123456789, 123456789000)
|
||||
test_case('0.123456789123', 0.123456789123, 123456789123)
|
||||
try:
|
||||
make_int('0.1234567891234', 12)
|
||||
assert(False)
|
||||
assert (False)
|
||||
except Exception as e:
|
||||
assert(str(e) == 'Mantissa too long')
|
||||
assert (str(e) == 'Mantissa too long')
|
||||
validate_amount('0.123456789123', 12)
|
||||
try:
|
||||
validate_amount('0.1234567891234', 12)
|
||||
assert(False)
|
||||
assert (False)
|
||||
except Exception as e:
|
||||
assert('Too many decimal places' in str(e))
|
||||
assert ('Too many decimal places' in str(e))
|
||||
try:
|
||||
validate_amount(0.1234567891234, 12)
|
||||
assert(False)
|
||||
assert (False)
|
||||
except Exception as e:
|
||||
assert('Too many decimal places' in str(e))
|
||||
assert ('Too many decimal places' in str(e))
|
||||
|
||||
def test_ed25519(self):
|
||||
privkey = edu.get_secret()
|
||||
@@ -163,7 +163,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
privkey_bytes = i2b(privkey)
|
||||
pubkey_test = ed25519_get_pubkey(privkey_bytes)
|
||||
assert(pubkey == pubkey_test)
|
||||
assert (pubkey == pubkey_test)
|
||||
|
||||
def test_ecdsa_otves(self):
|
||||
coin_settings = {'rpcport': 0, 'rpcauth': 'none'}
|
||||
@@ -178,15 +178,15 @@ class Test(unittest.TestCase):
|
||||
|
||||
cipher_text = ecdsaotves_enc_sign(vk_sign, pk_encrypt, sign_hash)
|
||||
|
||||
assert(ecdsaotves_enc_verify(pk_sign, pk_encrypt, sign_hash, cipher_text))
|
||||
assert (ecdsaotves_enc_verify(pk_sign, pk_encrypt, sign_hash, cipher_text))
|
||||
|
||||
sig = ecdsaotves_dec_sig(vk_encrypt, cipher_text)
|
||||
|
||||
assert(ci.verifySig(pk_sign, sign_hash, sig))
|
||||
assert (ci.verifySig(pk_sign, sign_hash, sig))
|
||||
|
||||
recovered_key = ecdsaotves_rec_enc_key(pk_encrypt, cipher_text, sig)
|
||||
|
||||
assert(vk_encrypt == recovered_key)
|
||||
assert (vk_encrypt == recovered_key)
|
||||
|
||||
def test_sign(self):
|
||||
coin_settings = {'rpcport': 0, 'rpcauth': 'none'}
|
||||
@@ -211,7 +211,7 @@ class Test(unittest.TestCase):
|
||||
vk = i2b(ci.getNewSecretKey())
|
||||
pk = ci.getPubkey(vk)
|
||||
sig = ci.signCompact(vk, 'test signing message')
|
||||
assert(len(sig) == 64)
|
||||
assert (len(sig) == 64)
|
||||
ci.verifyCompact(pk, 'test signing message', sig)
|
||||
|
||||
def test_pubkey_to_address(self):
|
||||
@@ -220,7 +220,7 @@ class Test(unittest.TestCase):
|
||||
ci = BTCInterface(coin_settings, 'regtest')
|
||||
pk = h2b('02c26a344e7d21bcc6f291532679559f2fd234c881271ff98714855edc753763a6')
|
||||
addr = ci.pubkey_to_address(pk)
|
||||
assert(addr == 'mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8')
|
||||
assert (addr == 'mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8')
|
||||
|
||||
def test_dleag(self):
|
||||
coin_settings = {'rpcport': 0, 'walletrpcport': 0, 'walletrpcauth': 'none'}
|
||||
@@ -230,7 +230,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
key = i2b(ci.getNewSecretKey())
|
||||
proof = ci.proveDLEAG(key)
|
||||
assert(ci.verifyDLEAG(proof))
|
||||
assert (ci.verifyDLEAG(proof))
|
||||
|
||||
def test_rate(self):
|
||||
scale_from = 8
|
||||
@@ -239,11 +239,11 @@ class Test(unittest.TestCase):
|
||||
rate = make_int(0.1, scale_to)
|
||||
|
||||
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
||||
assert('100.00000000' == format_amount(amount_from, scale_from))
|
||||
assert('10.000000000000' == format_amount(amount_to, scale_to))
|
||||
assert ('100.00000000' == format_amount(amount_from, scale_from))
|
||||
assert ('10.000000000000' == format_amount(amount_to, scale_to))
|
||||
|
||||
rate_check = make_int((amount_to / amount_from), scale_from)
|
||||
assert(rate == rate_check)
|
||||
assert (rate == rate_check)
|
||||
|
||||
scale_from = 12
|
||||
scale_to = 8
|
||||
@@ -251,11 +251,11 @@ class Test(unittest.TestCase):
|
||||
rate = make_int(12, scale_to)
|
||||
|
||||
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
||||
assert('1.000000000000' == format_amount(amount_from, scale_from))
|
||||
assert('12.00000000' == format_amount(amount_to, scale_to))
|
||||
assert ('1.000000000000' == format_amount(amount_from, scale_from))
|
||||
assert ('12.00000000' == format_amount(amount_to, scale_to))
|
||||
|
||||
rate_check = make_int((amount_to / amount_from), scale_from)
|
||||
assert(rate == rate_check)
|
||||
assert (rate == rate_check)
|
||||
|
||||
scale_from = 8
|
||||
scale_to = 8
|
||||
@@ -263,7 +263,7 @@ class Test(unittest.TestCase):
|
||||
amount_to = make_int(10, scale_to)
|
||||
rate = make_int(amount_to / amount_from, scale_to, r=1)
|
||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
||||
assert('10.00000000' == format_amount(amount_to_recreate, scale_to))
|
||||
assert ('10.00000000' == format_amount(amount_to_recreate, scale_to))
|
||||
|
||||
scale_from = 8
|
||||
scale_to = 12
|
||||
@@ -271,7 +271,7 @@ class Test(unittest.TestCase):
|
||||
amount_to = make_int(0.06935, scale_to)
|
||||
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
||||
assert('0.069350000000' == format_amount(amount_to_recreate, scale_to))
|
||||
assert ('0.069350000000' == format_amount(amount_to_recreate, scale_to))
|
||||
|
||||
scale_from = 12
|
||||
scale_to = 8
|
||||
@@ -279,18 +279,18 @@ class Test(unittest.TestCase):
|
||||
amount_to = make_int(10.0, scale_to)
|
||||
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
||||
assert('10.00000000' == format_amount(amount_to_recreate, scale_to))
|
||||
assert ('10.00000000' == format_amount(amount_to_recreate, scale_to))
|
||||
|
||||
def test_rfc2440(self):
|
||||
password = 'test'
|
||||
salt = bytes.fromhex('B7A94A7E4988630E')
|
||||
password_hash = rfc2440_hash_password(password, salt=salt)
|
||||
|
||||
assert(password_hash == '16:B7A94A7E4988630E6095334BA67F06FBA509B2A7136A04C9C1B430F539')
|
||||
assert (password_hash == '16:B7A94A7E4988630E6095334BA67F06FBA509B2A7136A04C9C1B430F539')
|
||||
|
||||
def test_ripemd160(self):
|
||||
input_data = b'hash this'
|
||||
assert(ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17')
|
||||
assert (ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -56,7 +56,7 @@ class Test(BaseTest):
|
||||
'type_to': 'blind',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/wallets/part/withdraw', post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
|
||||
logging.info('Waiting for blind balance')
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1800/json/wallets/part', 'blind_balance', 100.0 + node0_blind_before)
|
||||
@@ -74,7 +74,7 @@ class Test(BaseTest):
|
||||
swap_clients = self.swap_clients
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets/part')
|
||||
assert(float(js_0['blind_balance']) > 10.0)
|
||||
assert (float(js_0['blind_balance']) > 10.0)
|
||||
node0_blind_before = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
||||
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
@@ -102,11 +102,11 @@ class Test(BaseTest):
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
node1_blind_after = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
||||
assert(node1_blind_after > node1_blind_before + (amount_from - 0.05))
|
||||
assert (node1_blind_after > node1_blind_before + (amount_from - 0.05))
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets/part')
|
||||
node0_blind_after = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
||||
assert(node0_blind_after < node0_blind_before - amount_from)
|
||||
assert (node0_blind_after < node0_blind_before - amount_from)
|
||||
|
||||
js_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||
js_1_xmr_after = read_json_api(1801, 'wallets/xmr')
|
||||
@@ -116,7 +116,7 @@ class Test(BaseTest):
|
||||
amount_to_float = float(format_amount(amount_to, 12))
|
||||
node1_xmr_after = float(js_1_xmr_after['unconfirmed']) + float(js_1_xmr_after['balance'])
|
||||
node1_xmr_before = float(js_1_xmr['unconfirmed']) + float(js_1_xmr['balance'])
|
||||
assert(node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
assert (node1_xmr_after > node1_xmr_before + (amount_to_float - 0.02))
|
||||
|
||||
def test_02_leader_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test PARTct to XMR leader recovers coin a lock tx')
|
||||
@@ -138,7 +138,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
|
||||
@@ -149,7 +149,7 @@ class Test(BaseTest):
|
||||
|
||||
js_w0_after = read_json_api(1800, 'wallets')
|
||||
node0_blind_after = self.getBalance(js_w0_after)
|
||||
assert(node0_blind_before - node0_blind_after < 0.02)
|
||||
assert (node0_blind_before - node0_blind_after < 0.02)
|
||||
|
||||
def test_03_follower_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test PARTct to XMR follower recovers coin a lock tx')
|
||||
@@ -171,7 +171,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||
swap_clients[0].setBidDebugInd(bid_id, DebugTypes.BID_DONT_SPEND_COIN_A_LOCK_REFUND)
|
||||
@@ -186,7 +186,7 @@ class Test(BaseTest):
|
||||
node1_blind_before = self.getBalance(js_w1_before)
|
||||
node1_blind_after = self.getBalance(js_w1_after)
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
assert(node1_blind_after - node1_blind_before > (amount_from - 0.02))
|
||||
assert (node1_blind_after - node1_blind_before > (amount_from - 0.02))
|
||||
|
||||
swap_clients[0].abandonBid(bid_id)
|
||||
swap_clients[1].abandonBid(bid_id)
|
||||
@@ -204,7 +204,7 @@ class Test(BaseTest):
|
||||
'remote_key': offerer_key
|
||||
}).encode()
|
||||
redeemed_txid = json.loads(urlopen('http://127.0.0.1:1801/json/bids/{}'.format(bid_id.hex()), data=data).read())['txid']
|
||||
assert(len(redeemed_txid) == 64)
|
||||
assert (len(redeemed_txid) == 64)
|
||||
|
||||
def test_04_follower_recover_b_lock_tx(self):
|
||||
logging.info('---------- Test PARTct to XMR follower recovers coin b lock tx')
|
||||
@@ -227,7 +227,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||
|
||||
@@ -241,11 +241,11 @@ class Test(BaseTest):
|
||||
|
||||
node0_blind_before = self.getBalance(js_w0_before)
|
||||
node0_blind_after = self.getBalance(js_w0_after)
|
||||
assert(node0_blind_before - node0_blind_after < 0.02)
|
||||
assert (node0_blind_before - node0_blind_after < 0.02)
|
||||
|
||||
node1_xmr_before = self.getXmrBalance(js_w1_before)
|
||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
||||
assert(node1_xmr_before - node1_xmr_after < 0.02)
|
||||
assert (node1_xmr_before - node1_xmr_after < 0.02)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -98,7 +98,7 @@ class Test(unittest.TestCase):
|
||||
if blocks >= num_blocks:
|
||||
break
|
||||
delay_event.wait(2)
|
||||
assert(blocks >= num_blocks)
|
||||
assert (blocks >= num_blocks)
|
||||
|
||||
data = {
|
||||
'addr_from': '-1',
|
||||
@@ -110,7 +110,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
offer_id = post_json_api(12700, 'offers/new', data)
|
||||
summary = read_json_api(12700)
|
||||
assert(summary['num_sent_offers'] == 1)
|
||||
assert (summary['num_sent_offers'] == 1)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -135,7 +135,7 @@ class Test(unittest.TestCase):
|
||||
'accept': True
|
||||
}
|
||||
rv = post_json_api(12700, 'bids/{}'.format(bid['bid_id']), data)
|
||||
assert(rv['bid_state'] == 'Accepted')
|
||||
assert (rv['bid_state'] == 'Accepted')
|
||||
|
||||
waitForNumSwapping(delay_event, 12701, 1)
|
||||
|
||||
@@ -148,7 +148,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
waitForServer(delay_event, 12701)
|
||||
rv = read_json_api(12701)
|
||||
assert(rv['num_swapping'] == 1)
|
||||
assert (rv['num_swapping'] == 1)
|
||||
|
||||
update_thread = threading.Thread(target=updateThread)
|
||||
update_thread.start()
|
||||
@@ -160,7 +160,7 @@ class Test(unittest.TestCase):
|
||||
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
||||
if rv['bid_state'] == 'Completed':
|
||||
break
|
||||
assert(rv['bid_state'] == 'Completed')
|
||||
assert (rv['bid_state'] == 'Completed')
|
||||
|
||||
delay_event.set()
|
||||
update_thread.join()
|
||||
|
||||
@@ -95,24 +95,24 @@ class Test(BaseTest):
|
||||
for c in Coins:
|
||||
coin = next((x for x in js_coins if x['id'] == int(c)), None)
|
||||
if c in (Coins.PART, Coins.BTC, Coins.LTC, Coins.PART_ANON, Coins.PART_BLIND):
|
||||
assert(coin['active'] is True)
|
||||
assert (coin['active'] is True)
|
||||
else:
|
||||
assert(coin['active'] is False)
|
||||
assert (coin['active'] is False)
|
||||
if c in (Coins.PART_ANON, Coins.PART_BLIND):
|
||||
assert(coin['ticker'] == 'PART')
|
||||
assert (coin['ticker'] == 'PART')
|
||||
|
||||
def test_002_lookup_rates(self):
|
||||
rv = self.swap_clients[0].lookupRates(Coins.BTC, Coins.PART)
|
||||
assert('coingecko' in rv)
|
||||
assert('bittrex' in rv)
|
||||
assert ('coingecko' in rv)
|
||||
assert ('bittrex' in rv)
|
||||
|
||||
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.BTC)
|
||||
assert('coingecko' in rv)
|
||||
assert('bittrex' in rv)
|
||||
assert ('coingecko' in rv)
|
||||
assert ('bittrex' in rv)
|
||||
|
||||
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.PART)
|
||||
assert('coingecko' in rv)
|
||||
assert('bittrex' in rv)
|
||||
assert ('coingecko' in rv)
|
||||
assert ('bittrex' in rv)
|
||||
|
||||
def test_01_verifyrawtransaction(self):
|
||||
txn = '0200000001eb6e5c4ebba4efa32f40c7314cad456a64008e91ee30b2dd0235ab9bb67fbdbb01000000ee47304402200956933242dde94f6cf8f195a470f8d02aef21ec5c9b66c5d3871594bdb74c9d02201d7e1b440de8f4da672d689f9e37e98815fb63dbc1706353290887eb6e8f7235012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d205a803b28fe2f86c17db91fa99d7ed2598f79b5677ffe869de2e478c0d1c02cc7514c606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888acffffffff01e0167118020000001976a9140044e188928710cecba8311f1cf412135b98145c88ac00000000'
|
||||
@@ -123,13 +123,13 @@ class Test(BaseTest):
|
||||
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888ac',
|
||||
'amount': 1.0}
|
||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||
assert(ro['inputs_valid'] is False)
|
||||
assert(ro['validscripts'] == 1)
|
||||
assert (ro['inputs_valid'] is False)
|
||||
assert (ro['validscripts'] == 1)
|
||||
|
||||
prevout['amount'] = 100.0
|
||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||
assert(ro['inputs_valid'] is True)
|
||||
assert(ro['validscripts'] == 1)
|
||||
assert (ro['inputs_valid'] is True)
|
||||
assert (ro['validscripts'] == 1)
|
||||
|
||||
txn = 'a000000000000128e8ba6a28673f2ebb5fd983b27a791fd1888447a47638b3cd8bfdd3f54a6f1e0100000000a90040000101e0c69a3b000000001976a9146c0f1ea47ca2bf84ed87bf3aa284e18748051f5788ac04473044022026b01f3a90e46883949404141467b741cd871722a4aaae8ddc8c4d6ab6fb1c77022047a2f3be2dcbe4c51837d2d5e0329aaa8a13a8186b03186b127cc51185e4f3ab012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d0100606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac'
|
||||
prevout = {
|
||||
@@ -139,13 +139,13 @@ class Test(BaseTest):
|
||||
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac',
|
||||
'amount': 1.0}
|
||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||
assert(ro['inputs_valid'] is False)
|
||||
assert(ro['validscripts'] == 0) # Amount covered by signature
|
||||
assert (ro['inputs_valid'] is False)
|
||||
assert (ro['validscripts'] == 0) # Amount covered by signature
|
||||
|
||||
prevout['amount'] = 90.0
|
||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||
assert(ro['inputs_valid'] is True)
|
||||
assert(ro['validscripts'] == 1)
|
||||
assert (ro['inputs_valid'] is True)
|
||||
assert (ro['validscripts'] == 1)
|
||||
|
||||
def test_02_part_ltc(self):
|
||||
logging.info('---------- Test PART to LTC')
|
||||
@@ -155,7 +155,7 @@ class Test(BaseTest):
|
||||
|
||||
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||
offers = swap_clients[1].listOffers()
|
||||
assert(len(offers) == 1)
|
||||
assert (len(offers) == 1)
|
||||
for offer in offers:
|
||||
if offer.offer_id == offer_id:
|
||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
||||
@@ -171,16 +171,16 @@ class Test(BaseTest):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
bid_id_hex = bid_id.hex()
|
||||
path = f'bids/{bid_id_hex}/states'
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[0]) is True)
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[0]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||
|
||||
def test_03_ltc_part(self):
|
||||
logging.info('---------- Test LTC to PART')
|
||||
@@ -202,8 +202,8 @@ class Test(BaseTest):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_04_ltc_btc(self):
|
||||
logging.info('---------- Test LTC to BTC')
|
||||
@@ -225,8 +225,8 @@ class Test(BaseTest):
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
def test_05_refund(self):
|
||||
# Seller submits initiate txn, buyer doesn't respond
|
||||
@@ -249,21 +249,21 @@ class Test(BaseTest):
|
||||
|
||||
js_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||
js_1_bid = read_json_api(1801, 'bids/{}'.format(bid_id.hex()))
|
||||
assert(js_0_bid['itx_state'] == 'Refunded')
|
||||
assert(js_1_bid['ptx_state'] == 'Unknown')
|
||||
assert (js_0_bid['itx_state'] == 'Refunded')
|
||||
assert (js_1_bid['ptx_state'] == 'Unknown')
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
bid_id_hex = bid_id.hex()
|
||||
path = f'bids/{bid_id_hex}/states'
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert(bidder_states[-1][1] == 'Bid Abandoned')
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert (bidder_states[-1][1] == 'Bid Abandoned')
|
||||
|
||||
def test_06_self_bid(self):
|
||||
logging.info('---------- Test same client, BTC to LTC')
|
||||
@@ -285,8 +285,8 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_0['num_recv_bids'] == js_0_before['num_recv_bids'] + 1 and js_0['num_sent_bids'] == js_0_before['num_sent_bids'] + 1)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_recv_bids'] == js_0_before['num_recv_bids'] + 1 and js_0['num_sent_bids'] == js_0_before['num_sent_bids'] + 1)
|
||||
|
||||
def test_07_error(self):
|
||||
logging.info('---------- Test error, BTC to LTC, set fee above bid value')
|
||||
@@ -327,7 +327,7 @@ class Test(BaseTest):
|
||||
|
||||
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||
offers = swap_clients[1].listOffers()
|
||||
assert(len(offers) >= 1)
|
||||
assert (len(offers) >= 1)
|
||||
for offer in offers:
|
||||
if offer.offer_id == offer_id:
|
||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
||||
@@ -358,21 +358,21 @@ class Test(BaseTest):
|
||||
|
||||
js_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||
js_1_bid = read_json_api(1801, 'bids/{}'.format(bid_id.hex()))
|
||||
assert(js_0_bid['itx_state'] == 'Refunded')
|
||||
assert(js_1_bid['ptx_state'] == 'Refunded')
|
||||
assert (js_0_bid['itx_state'] == 'Refunded')
|
||||
assert (js_1_bid['ptx_state'] == 'Refunded')
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
|
||||
bid_id_hex = bid_id.hex()
|
||||
path = f'bids/{bid_id_hex}/states'
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||
|
||||
'''
|
||||
def test_11_refund(self):
|
||||
@@ -398,13 +398,13 @@ class Test(BaseTest):
|
||||
|
||||
js_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||
js_1_bid = read_json_api(1801, 'bids/{}'.format(bid_id.hex()))
|
||||
assert(js_0_bid['itx_state'] == 'Refunded')
|
||||
assert(js_1_bid['ptx_state'] == 'Unknown')
|
||||
assert (js_0_bid['itx_state'] == 'Refunded')
|
||||
assert (js_1_bid['ptx_state'] == 'Unknown')
|
||||
|
||||
js_0 = read_json_api(1800)
|
||||
js_1 = read_json_api(1801)
|
||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert(js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
assert (js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
||||
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||
'''
|
||||
|
||||
def test_12_withdrawal(self):
|
||||
@@ -412,7 +412,7 @@ class Test(BaseTest):
|
||||
|
||||
ltc_addr = callnoderpc(0, 'getnewaddress', ['Withdrawal test', 'legacy'], base_rpc_port=LTC_BASE_RPC_PORT)
|
||||
wallets0 = read_json_api(TEST_HTTP_PORT + 0, 'wallets')
|
||||
assert(float(wallets0['LTC']['balance']) > 100)
|
||||
assert (float(wallets0['LTC']['balance']) > 100)
|
||||
|
||||
post_json = {
|
||||
'value': 100,
|
||||
@@ -420,7 +420,7 @@ class Test(BaseTest):
|
||||
'subfee': False,
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:{}/json/wallets/ltc/withdraw'.format(TEST_HTTP_PORT + 0), post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
|
||||
def test_13_itx_refund(self):
|
||||
logging.info('---------- Test ITX refunded')
|
||||
@@ -469,11 +469,11 @@ class Test(BaseTest):
|
||||
high_fee_value_btc = int(0.001 * COIN)
|
||||
high_fee_value_ltc = int(0.01 * COIN) # TODO Set fees directly, see listtransactions
|
||||
|
||||
assert(node0_btc_after > node0_btc_before + btc_swap_value - high_fee_value_btc)
|
||||
assert(node0_ltc_after > node0_ltc_before - high_fee_value_ltc)
|
||||
assert (node0_btc_after > node0_btc_before + btc_swap_value - high_fee_value_btc)
|
||||
assert (node0_ltc_after > node0_ltc_before - high_fee_value_ltc)
|
||||
|
||||
assert(node1_btc_after < node1_btc_before - btc_swap_value)
|
||||
assert(node1_ltc_before == node1_ltc_after)
|
||||
assert (node1_btc_after < node1_btc_before - btc_swap_value)
|
||||
assert (node1_ltc_before == node1_ltc_after)
|
||||
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
||||
|
||||
@@ -482,8 +482,8 @@ class Test(BaseTest):
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[2]) is True)
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[2], exact_match=False) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[2]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[2], exact_match=False) is True)
|
||||
|
||||
def pass_99_delay(self):
|
||||
logging.info('Delay')
|
||||
|
||||
@@ -555,13 +555,13 @@ class Test(BaseTest):
|
||||
swap_clients = self.swap_clients
|
||||
|
||||
js_1 = read_json_api(1801, 'wallets')
|
||||
assert(make_int(js_1[Coins.XMR.name]['balance'], scale=12) > 0)
|
||||
assert(make_int(js_1[Coins.XMR.name]['unconfirmed'], scale=12) > 0)
|
||||
assert (make_int(js_1[Coins.XMR.name]['balance'], scale=12) > 0)
|
||||
assert (make_int(js_1[Coins.XMR.name]['unconfirmed'], scale=12) > 0)
|
||||
|
||||
offer_id = swap_clients[0].postOffer(Coins.PART, Coins.XMR, 100 * COIN, 0.11 * XMR_COIN, 100 * COIN, SwapTypes.XMR_SWAP)
|
||||
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||
offers = swap_clients[1].listOffers(filters={'offer_id': offer_id})
|
||||
assert(len(offers) == 1)
|
||||
assert (len(offers) == 1)
|
||||
offer = offers[0]
|
||||
|
||||
bid_id = swap_clients[1].postXmrBid(offer_id, offer.amount_from)
|
||||
@@ -569,7 +569,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[0].acceptXmrBid(bid_id)
|
||||
|
||||
@@ -578,15 +578,15 @@ class Test(BaseTest):
|
||||
|
||||
js_0_end = read_json_api(1800, 'wallets')
|
||||
end_xmr = float(js_0_end['XMR']['balance']) + float(js_0_end['XMR']['unconfirmed'])
|
||||
assert(end_xmr > 10.9 and end_xmr < 11.0)
|
||||
assert (end_xmr > 10.9 and end_xmr < 11.0)
|
||||
|
||||
bid_id_hex = bid_id.hex()
|
||||
path = f'bids/{bid_id_hex}/states'
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[0]) is True)
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[0]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||
|
||||
def test_011_smsgaddresses(self):
|
||||
logging.info('---------- Test address management and private offers')
|
||||
@@ -601,21 +601,21 @@ class Test(BaseTest):
|
||||
new_address_pk = json_rv['pubkey']
|
||||
|
||||
js_2 = read_json_api(1801, 'smsgaddresses')
|
||||
assert(len(js_2) == len(js_1) + 1)
|
||||
assert (len(js_2) == len(js_1) + 1)
|
||||
found = False
|
||||
for addr in js_2:
|
||||
if addr['addr'] == new_address:
|
||||
assert(addr['note'] == 'testing')
|
||||
assert (addr['note'] == 'testing')
|
||||
found = True
|
||||
assert(found is True)
|
||||
assert (found is True)
|
||||
|
||||
found = False
|
||||
lks = callnoderpc(1, 'smsglocalkeys')
|
||||
for key in lks['wallet_keys']:
|
||||
if key['address'] == new_address:
|
||||
assert(key['receive'] == '1')
|
||||
assert (key['receive'] == '1')
|
||||
found = True
|
||||
assert(found is True)
|
||||
assert (found is True)
|
||||
|
||||
# Disable
|
||||
post_json = {
|
||||
@@ -624,23 +624,23 @@ class Test(BaseTest):
|
||||
'active_ind': '0',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/smsgaddresses/edit', post_json))
|
||||
assert(json_rv['edited_address'] == new_address)
|
||||
assert (json_rv['edited_address'] == new_address)
|
||||
|
||||
js_3 = read_json_api(1801, 'smsgaddresses')
|
||||
found = False
|
||||
for addr in js_3:
|
||||
if addr['addr'] == new_address:
|
||||
assert(addr['note'] == 'testing2')
|
||||
assert(addr['active_ind'] == 0)
|
||||
assert (addr['note'] == 'testing2')
|
||||
assert (addr['active_ind'] == 0)
|
||||
found = True
|
||||
assert(found is True)
|
||||
assert (found is True)
|
||||
|
||||
found = False
|
||||
lks = callnoderpc(1, 'smsglocalkeys')
|
||||
for key in lks['wallet_keys']:
|
||||
if key['address'] == new_address:
|
||||
found = True
|
||||
assert(found is False)
|
||||
assert (found is False)
|
||||
|
||||
# Re-enable
|
||||
post_json = {
|
||||
@@ -648,22 +648,22 @@ class Test(BaseTest):
|
||||
'active_ind': '1',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/smsgaddresses/edit', post_json))
|
||||
assert(json_rv['edited_address'] == new_address)
|
||||
assert (json_rv['edited_address'] == new_address)
|
||||
|
||||
found = False
|
||||
lks = callnoderpc(1, 'smsglocalkeys')
|
||||
for key in lks['wallet_keys']:
|
||||
if key['address'] == new_address:
|
||||
assert(key['receive'] == '1')
|
||||
assert (key['receive'] == '1')
|
||||
found = True
|
||||
assert(found is True)
|
||||
assert (found is True)
|
||||
|
||||
post_json = {
|
||||
'addresspubkey': new_address_pk,
|
||||
'addressnote': 'testing_add_addr',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/smsgaddresses/add', post_json))
|
||||
assert(json_rv['added_address'] == new_address)
|
||||
assert (json_rv['added_address'] == new_address)
|
||||
|
||||
post_json = {
|
||||
'addr_to': new_address,
|
||||
@@ -680,10 +680,10 @@ class Test(BaseTest):
|
||||
wait_for_offer(test_delay_event, swap_clients[1], bytes.fromhex(offer_id_hex))
|
||||
|
||||
rv = read_json_api(1801, f'offers/{offer_id_hex}')
|
||||
assert(rv[0]['addr_to'] == new_address)
|
||||
assert (rv[0]['addr_to'] == new_address)
|
||||
|
||||
rv = read_json_api(1800, f'offers/{offer_id_hex}')
|
||||
assert(rv[0]['addr_to'] == new_address)
|
||||
assert (rv[0]['addr_to'] == new_address)
|
||||
|
||||
def test_02_leader_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test PART to XMR leader recovers coin a lock tx')
|
||||
@@ -700,7 +700,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
|
||||
@@ -713,7 +713,7 @@ class Test(BaseTest):
|
||||
path = f'bids/{bid_id_hex}/states'
|
||||
offerer_states = read_json_api(1800, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
|
||||
def test_03_follower_recover_a_lock_tx(self):
|
||||
logging.info('---------- Test PART to XMR follower recovers coin a lock tx')
|
||||
@@ -730,7 +730,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
swap_clients[0].setBidDebugInd(bid_id, DebugTypes.BID_DONT_SPEND_COIN_A_LOCK_REFUND)
|
||||
@@ -748,7 +748,7 @@ class Test(BaseTest):
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
bidder_states = [s for s in bidder_states if s[1] != 'Bid Stalled (debug)']
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[2]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[2]) is True)
|
||||
|
||||
def test_04_follower_recover_b_lock_tx(self):
|
||||
logging.info('---------- Test PART to XMR follower recovers coin b lock tx')
|
||||
@@ -765,7 +765,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||
|
||||
@@ -779,8 +779,8 @@ class Test(BaseTest):
|
||||
offerer_states = read_json_api(1800, path)
|
||||
bidder_states = read_json_api(1801, path)
|
||||
|
||||
assert(compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert(compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||
assert (compare_bid_states(offerer_states, self.states_offerer[1]) is True)
|
||||
assert (compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||
|
||||
def test_05_btc_xmr(self):
|
||||
logging.info('---------- Test BTC to XMR')
|
||||
@@ -797,7 +797,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[0].acceptXmrBid(bid_id)
|
||||
|
||||
@@ -861,7 +861,7 @@ class Test(BaseTest):
|
||||
|
||||
js_w0_after = read_json_api(1800, 'wallets')
|
||||
js_w1_after = read_json_api(1801, 'wallets')
|
||||
assert(make_int(js_w1_after['BTC']['balance'], scale=8, r=1) - (make_int(js_w1_before['BTC']['balance'], scale=8, r=1) + amt_1) < 1000)
|
||||
assert (make_int(js_w1_after['BTC']['balance'], scale=8, r=1) - (make_int(js_w1_before['BTC']['balance'], scale=8, r=1) + amt_1) < 1000)
|
||||
|
||||
def test_07_revoke_offer(self):
|
||||
logging.info('---------- Test offer revocaction')
|
||||
@@ -880,7 +880,7 @@ class Test(BaseTest):
|
||||
address_to = js_0[Coins.XMR.name]['deposit_address']
|
||||
|
||||
js_1 = read_json_api(1801, 'wallets')
|
||||
assert(float(js_1[Coins.XMR.name]['balance']) > 0.0)
|
||||
assert (float(js_1[Coins.XMR.name]['balance']) > 0.0)
|
||||
|
||||
swap_clients[1].withdrawCoin(Coins.XMR, 1.1, address_to, False)
|
||||
|
||||
@@ -918,14 +918,14 @@ class Test(BaseTest):
|
||||
try:
|
||||
bid_id = swap_clients[1].postBid(offer_id, below_min_bid)
|
||||
except Exception as e:
|
||||
assert('Bid amount below minimum' in str(e))
|
||||
assert ('Bid amount below minimum' in str(e))
|
||||
extra_bid_options = {
|
||||
'debug_skip_validation': True,
|
||||
}
|
||||
bid_id = swap_clients[1].postBid(offer_id, below_min_bid, extra_options=extra_bid_options)
|
||||
|
||||
events = wait_for_event(test_delay_event, swap_clients[0], Concepts.NETWORK_MESSAGE, bid_id)
|
||||
assert('Bid amount below minimum' in events[0].event_msg)
|
||||
assert ('Bid amount below minimum' in events[0].event_msg)
|
||||
|
||||
bid_ids = []
|
||||
for i in range(5):
|
||||
@@ -935,7 +935,7 @@ class Test(BaseTest):
|
||||
test_delay_event.wait(1.0)
|
||||
bid_id = swap_clients[1].postBid(offer_id, min_bid)
|
||||
events = wait_for_event(test_delay_event, swap_clients[0], Concepts.AUTOMATION, bid_id)
|
||||
assert('Already have 5 bids to complete' in events[0].event_msg)
|
||||
assert ('Already have 5 bids to complete' in events[0].event_msg)
|
||||
|
||||
for bid_id in bid_ids:
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=180)
|
||||
@@ -947,7 +947,7 @@ class Test(BaseTest):
|
||||
amt_bid += 1
|
||||
bid_id = swap_clients[1].postBid(offer_id, amt_bid)
|
||||
events = wait_for_event(test_delay_event, swap_clients[0], Concepts.AUTOMATION, bid_id)
|
||||
assert('Over remaining offer value' in events[0].event_msg)
|
||||
assert ('Over remaining offer value' in events[0].event_msg)
|
||||
|
||||
# Should pass
|
||||
amt_bid -= 1
|
||||
@@ -968,7 +968,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
swap_clients[1].setBidDebugInd(bid_id, DebugTypes.BID_STOP_AFTER_COIN_A_LOCK)
|
||||
|
||||
@@ -977,25 +977,25 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED, wait_for=180)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
|
||||
try:
|
||||
swap_clients[0].ci(Coins.BTC).publishTx(xmr_swap.a_lock_refund_tx)
|
||||
assert(False), 'Lock refund tx should be locked'
|
||||
assert (False), 'Lock refund tx should be locked'
|
||||
except Exception as e:
|
||||
assert('non-BIP68-final' in str(e))
|
||||
assert ('non-BIP68-final' in str(e))
|
||||
|
||||
def test_11_particl_anon(self):
|
||||
logging.info('---------- Test Particl anon transactions')
|
||||
swap_clients = self.swap_clients
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets/part')
|
||||
assert(float(js_0['anon_balance']) == 0.0)
|
||||
assert (float(js_0['anon_balance']) == 0.0)
|
||||
node0_anon_before = js_0['anon_balance'] + js_0['anon_pending']
|
||||
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1801/json/wallets/part', 'balance', 200.0)
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
assert(float(js_1['balance']) > 200.0)
|
||||
assert (float(js_1['balance']) > 200.0)
|
||||
node1_anon_before = js_1['anon_balance'] + js_1['anon_pending']
|
||||
|
||||
callnoderpc(1, 'reservebalance', [True, 1000000]) # Stop staking to avoid conflicts (input used by tx->anon staked before tx gets in the chain)
|
||||
@@ -1006,7 +1006,7 @@ class Test(BaseTest):
|
||||
'type_to': 'anon',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/wallets/part/withdraw', post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
|
||||
logging.info('Waiting for anon balance')
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1801/json/wallets/part', 'anon_balance', 100.0 + node1_anon_before)
|
||||
@@ -1022,7 +1022,7 @@ class Test(BaseTest):
|
||||
'type_to': 'blind',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/wallets/part/withdraw', post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
|
||||
logging.info('Waiting for blind balance')
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1800/json/wallets/part', 'blind_balance', 9.8)
|
||||
@@ -1041,7 +1041,7 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||
|
||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||
assert(xmr_swap)
|
||||
assert (xmr_swap)
|
||||
amount_to = float(format_amount(bid.amount_to, 8))
|
||||
|
||||
swap_clients[0].acceptXmrBid(bid_id)
|
||||
@@ -1050,10 +1050,10 @@ class Test(BaseTest):
|
||||
wait_for_bid(test_delay_event, swap_clients[1], bid_id, BidStates.SWAP_COMPLETED, sent=True)
|
||||
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
assert(js_1['anon_balance'] < node1_anon_before - amount_to)
|
||||
assert (js_1['anon_balance'] < node1_anon_before - amount_to)
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets/part')
|
||||
assert(js_0['anon_balance'] + js_0['anon_pending'] > node0_anon_before + (amount_to - 0.05))
|
||||
assert (js_0['anon_balance'] + js_0['anon_pending'] > node0_anon_before + (amount_to - 0.05))
|
||||
|
||||
def test_12_particl_blind(self):
|
||||
logging.info('---------- Test Particl blind transactions')
|
||||
@@ -1064,7 +1064,7 @@ class Test(BaseTest):
|
||||
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1801/json/wallets/part', 'balance', 200.0)
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
assert(float(js_1['balance']) > 200.0)
|
||||
assert (float(js_1['balance']) > 200.0)
|
||||
node1_blind_before = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
||||
|
||||
post_json = {
|
||||
@@ -1074,7 +1074,7 @@ class Test(BaseTest):
|
||||
'type_to': 'blind',
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/wallets/part/withdraw', post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
|
||||
logging.info('Waiting for blind balance')
|
||||
wait_for_balance(test_delay_event, 'http://127.0.0.1:1800/json/wallets/part', 'blind_balance', 100.0 + node0_blind_before)
|
||||
@@ -1100,11 +1100,11 @@ class Test(BaseTest):
|
||||
amount_from = float(format_amount(amt_swap, 8))
|
||||
js_1 = read_json_api(1801, 'wallets/part')
|
||||
node1_blind_after = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
||||
assert(node1_blind_after > node1_blind_before + (amount_from - 0.05))
|
||||
assert (node1_blind_after > node1_blind_before + (amount_from - 0.05))
|
||||
|
||||
js_0 = read_json_api(1800, 'wallets/part')
|
||||
node0_blind_after = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
||||
assert(node0_blind_after < node0_blind_before - amount_from)
|
||||
assert (node0_blind_after < node0_blind_before - amount_from)
|
||||
|
||||
def test_98_withdraw_all(self):
|
||||
logging.info('---------- Test XMR withdrawal all')
|
||||
@@ -1117,7 +1117,7 @@ class Test(BaseTest):
|
||||
|
||||
wallets1 = read_json_api(TEST_HTTP_PORT + 1, 'wallets')
|
||||
xmr_total = float(wallets1[Coins.XMR.name]['balance'])
|
||||
assert(xmr_total > 10)
|
||||
assert (xmr_total > 10)
|
||||
|
||||
post_json = {
|
||||
'value': 10,
|
||||
@@ -1125,11 +1125,11 @@ class Test(BaseTest):
|
||||
'subfee': True,
|
||||
}
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:{}/json/wallets/xmr/withdraw'.format(TEST_HTTP_PORT + 1), post_json))
|
||||
assert(json_rv['error'] == 'Withdraw value must be close to total to use subfee/sweep_all.')
|
||||
assert (json_rv['error'] == 'Withdraw value must be close to total to use subfee/sweep_all.')
|
||||
|
||||
post_json['value'] = xmr_total
|
||||
json_rv = json.loads(post_json_req('http://127.0.0.1:{}/json/wallets/xmr/withdraw'.format(TEST_HTTP_PORT + 1), post_json))
|
||||
assert(len(json_rv['txid']) == 64)
|
||||
assert (len(json_rv['txid']) == 64)
|
||||
finally:
|
||||
logging.info('Restoring XMR mining')
|
||||
pause_event.set()
|
||||
|
||||
@@ -50,7 +50,7 @@ class Test(XmrTestBase):
|
||||
waitForServer(self.delay_event, 12700)
|
||||
waitForServer(self.delay_event, 12701)
|
||||
wallets1 = read_json_api(12701, 'wallets')
|
||||
assert(float(wallets1['XMR']['balance']) > 0.0)
|
||||
assert (float(wallets1['XMR']['balance']) > 0.0)
|
||||
|
||||
offer_data = {
|
||||
'addr_from': -1,
|
||||
@@ -68,7 +68,7 @@ class Test(XmrTestBase):
|
||||
offer1_id = rv['offer_id']
|
||||
|
||||
summary = read_json_api(12700)
|
||||
assert(summary['num_sent_offers'] > 1)
|
||||
assert (summary['num_sent_offers'] > 1)
|
||||
|
||||
logger.info('Waiting for offer')
|
||||
waitForNumOffers(self.delay_event, 12701, 2)
|
||||
@@ -79,17 +79,17 @@ class Test(XmrTestBase):
|
||||
c0.join()
|
||||
|
||||
offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers/{}'.format(offer0_id)).read())
|
||||
assert(len(offers) == 1)
|
||||
assert (len(offers) == 1)
|
||||
offer0 = offers[0]
|
||||
|
||||
post_data = {
|
||||
'coin_from': 'PART'
|
||||
}
|
||||
test_post_offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers', data=parse.urlencode(post_data).encode()).read())
|
||||
assert(len(test_post_offers) == 2)
|
||||
assert (len(test_post_offers) == 2)
|
||||
post_data['coin_from'] = '2'
|
||||
test_post_offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers', data=parse.urlencode(post_data).encode()).read())
|
||||
assert(len(test_post_offers) == 0)
|
||||
assert (len(test_post_offers) == 0)
|
||||
|
||||
bid_data = {
|
||||
'offer_id': offer0_id,
|
||||
@@ -98,7 +98,7 @@ class Test(XmrTestBase):
|
||||
bid0_id = json.loads(urlopen('http://127.0.0.1:12701/json/bids/new', data=parse.urlencode(bid_data).encode()).read())['bid_id']
|
||||
|
||||
offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers/{}'.format(offer1_id)).read())
|
||||
assert(len(offers) == 1)
|
||||
assert (len(offers) == 1)
|
||||
offer1 = offers[0]
|
||||
|
||||
bid_data = {
|
||||
@@ -126,12 +126,12 @@ class Test(XmrTestBase):
|
||||
}).encode()
|
||||
try:
|
||||
rv = json.loads(urlopen('http://127.0.0.1:12700/json/bids/{}'.format(bid0_id), data=data).read())
|
||||
assert(rv['bid_state'] == 'Accepted')
|
||||
assert rv['bid_state'] == 'Accepted'
|
||||
except Exception as e:
|
||||
print('Accept bid failed', str(e), rv)
|
||||
try:
|
||||
rv = json.loads(urlopen('http://127.0.0.1:12700/json/bids/{}'.format(bid1_id), data=data).read())
|
||||
assert(rv['bid_state'] == 'Accepted')
|
||||
assert (rv['bid_state'] == 'Accepted')
|
||||
except Exception as e:
|
||||
print('Accept bid failed', str(e), rv)
|
||||
|
||||
@@ -145,8 +145,8 @@ class Test(XmrTestBase):
|
||||
rv1 = read_json_api(12700, 'bids/{}'.format(bid1_id))
|
||||
if rv0['bid_state'] == 'Completed' and rv1['bid_state'] == 'Completed':
|
||||
break
|
||||
assert(rv0['bid_state'] == 'Completed')
|
||||
assert(rv1['bid_state'] == 'Completed')
|
||||
assert rv0['bid_state'] == 'Completed'
|
||||
assert rv1['bid_state'] == 'Completed'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -46,7 +46,7 @@ class Test(XmrTestBase):
|
||||
waitForServer(self.delay_event, 12700)
|
||||
waitForServer(self.delay_event, 12701)
|
||||
wallets1 = read_json_api(12701, 'wallets')
|
||||
assert(float(wallets1['XMR']['balance']) > 0.0)
|
||||
assert (float(wallets1['XMR']['balance']) > 0.0)
|
||||
|
||||
data = {
|
||||
'addr_from': '-1',
|
||||
@@ -58,7 +58,7 @@ class Test(XmrTestBase):
|
||||
|
||||
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
||||
summary = read_json_api(12700)
|
||||
assert(summary['num_sent_offers'] == 1)
|
||||
assert (summary['num_sent_offers'] == 1)
|
||||
|
||||
logger.info('Waiting for offer')
|
||||
waitForNumOffers(self.delay_event, 12701, 1)
|
||||
@@ -72,20 +72,20 @@ class Test(XmrTestBase):
|
||||
|
||||
data['valid_for_seconds'] = 24 * 60 * 60 + 1
|
||||
bid = post_json_api(12701, 'bids/new', data)
|
||||
assert(bid['error'] == 'Bid TTL too high')
|
||||
assert (bid['error'] == 'Bid TTL too high')
|
||||
del data['valid_for_seconds']
|
||||
data['validmins'] = 24 * 60 + 1
|
||||
bid = post_json_api(12701, 'bids/new', data)
|
||||
assert(bid['error'] == 'Bid TTL too high')
|
||||
assert (bid['error'] == 'Bid TTL too high')
|
||||
|
||||
del data['validmins']
|
||||
data['valid_for_seconds'] = 10
|
||||
bid = post_json_api(12701, 'bids/new', data)
|
||||
assert(bid['error'] == 'Bid TTL too low')
|
||||
assert (bid['error'] == 'Bid TTL too low')
|
||||
del data['valid_for_seconds']
|
||||
data['validmins'] = 1
|
||||
bid = post_json_api(12701, 'bids/new', data)
|
||||
assert(bid['error'] == 'Bid TTL too low')
|
||||
assert (bid['error'] == 'Bid TTL too low')
|
||||
|
||||
data['validmins'] = 60
|
||||
bid_id = post_json_api(12701, 'bids/new', data)
|
||||
@@ -98,13 +98,13 @@ class Test(XmrTestBase):
|
||||
if bid['bid_state'] == 'Received':
|
||||
break
|
||||
self.delay_event.wait(1)
|
||||
assert(bid['expire_at'] == bid['created_at'] + data['validmins'] * 60)
|
||||
assert (bid['expire_at'] == bid['created_at'] + data['validmins'] * 60)
|
||||
|
||||
data = {
|
||||
'accept': True
|
||||
}
|
||||
rv = post_json_api(12700, 'bids/{}'.format(bid['bid_id']), data)
|
||||
assert(rv['bid_state'] == 'Accepted')
|
||||
assert (rv['bid_state'] == 'Accepted')
|
||||
|
||||
waitForNumSwapping(self.delay_event, 12701, 1)
|
||||
|
||||
@@ -117,10 +117,10 @@ class Test(XmrTestBase):
|
||||
|
||||
waitForServer(self.delay_event, 12701)
|
||||
rv = read_json_api(12701)
|
||||
assert(rv['num_swapping'] == 1)
|
||||
assert (rv['num_swapping'] == 1)
|
||||
|
||||
rv = read_json_api(12700, 'revokeoffer/{}'.format(offer_id))
|
||||
assert(rv['revoked_offer'] == offer_id)
|
||||
assert (rv['revoked_offer'] == offer_id)
|
||||
|
||||
logger.info('Completing swap')
|
||||
for i in range(240):
|
||||
@@ -131,11 +131,11 @@ class Test(XmrTestBase):
|
||||
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
||||
if rv['bid_state'] == 'Completed':
|
||||
break
|
||||
assert(rv['bid_state'] == 'Completed')
|
||||
assert (rv['bid_state'] == 'Completed')
|
||||
|
||||
# Ensure offer was revoked
|
||||
summary = read_json_api(12700)
|
||||
assert(summary['num_network_offers'] == 0)
|
||||
assert (summary['num_network_offers'] == 0)
|
||||
|
||||
# Wait for bid to be removed from in-progress
|
||||
waitForNumBids(self.delay_event, 12700, 0)
|
||||
|
||||
Reference in New Issue
Block a user