From 1c4f208d27226217978306ed185e9342ed167cd8 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 31 Jul 2022 20:01:49 +0200 Subject: [PATCH] refactor: E275 missing whitespace after keyword --- basicswap/basicswap.py | 22 ++-- basicswap/explorers.py | 2 +- basicswap/http_server.py | 2 +- basicswap/interface_btc.py | 20 ++-- basicswap/interface_part.py | 10 +- basicswap/interface_xmr.py | 2 +- basicswap/js_server.py | 16 +-- basicswap/util/__init__.py | 2 +- basicswap/util/address.py | 2 +- basicswap/util/ecc.py | 10 +- basicswap/util/rfc2440.py | 2 +- basicswap/util/script.py | 4 +- bin/basicswap_prepare.py | 4 +- tests/basicswap/common.py | 16 +-- tests/basicswap/common_xmr.py | 2 +- tests/basicswap/extended/test_http_ui.py | 2 +- tests/basicswap/extended/test_nmc.py | 28 ++--- tests/basicswap/extended/test_wallet_init.py | 12 +- .../basicswap/extended/test_wallet_restore.py | 8 +- .../basicswap/extended/test_xmr_persistent.py | 2 +- tests/basicswap/test_btc_xmr.py | 20 ++-- tests/basicswap/test_ltc_xmr.py | 20 ++-- tests/basicswap/test_other.py | 86 +++++++------- tests/basicswap/test_partblind_xmr.py | 26 ++--- tests/basicswap/test_reload.py | 10 +- tests/basicswap/test_run.py | 106 ++++++++--------- tests/basicswap/test_xmr.py | 110 +++++++++--------- tests/basicswap/test_xmr_bids_offline.py | 20 ++-- tests/basicswap/test_xmr_reload.py | 24 ++-- 29 files changed, 295 insertions(+), 295 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index caa53ef..2722f46 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -519,13 +519,13 @@ class BasicSwap(BaseApp): with open(pidfilepath, 'rb') as fp: datadir_pid = int(fp.read().decode('utf-8')) - assert(datadir_pid == cc['pid']), 'Mismatched pid' - assert(os.path.exists(authcookiepath)) + assert (datadir_pid == cc['pid']), 'Mismatched pid' + assert (os.path.exists(authcookiepath)) except Exception: self.delay_event.wait(0.5) try: if os.name != 'nt' or cc['core_version_group'] > 17: # Litecoin on windows doesn't write a pid file - assert(datadir_pid == cc['pid']), 'Mismatched pid' + assert (datadir_pid == cc['pid']), 'Mismatched pid' with open(authcookiepath, 'rb') as fp: cc['rpcauth'] = fp.read().decode('utf-8') except Exception as e: @@ -2074,7 +2074,7 @@ class BasicSwap(BaseApp): else: xmr_swap.kbsf_dleag = xmr_swap.pkbsf xmr_swap.pkasf = xmr_swap.kbsf_dleag[0: 33] - assert(xmr_swap.pkasf == ci_from.getPubkey(kbsf)) + assert (xmr_swap.pkasf == ci_from.getPubkey(kbsf)) msg_buf.pkaf = xmr_swap.pkaf msg_buf.kbvf = kbvf @@ -2432,7 +2432,7 @@ class BasicSwap(BaseApp): amount_to = bid.amount_to # Check required? - assert(amount_to == (bid.amount * bid.rate) // self.ci(offer.coin_from).COIN()) + assert (amount_to == (bid.amount * bid.rate) // self.ci(offer.coin_from).COIN()) if bid.debug_ind == DebugTypes.MAKE_INVALID_PTX: amount_to -= 1 @@ -2536,7 +2536,7 @@ class BasicSwap(BaseApp): if addr_redeem_out is None: addr_redeem_out = self.getReceiveAddressFromPool(coin_type, bid.bid_id, TxTypes.PTX_REDEEM if for_txn_type == 'participate' else TxTypes.ITX_REDEEM) - assert(addr_redeem_out is not None) + assert (addr_redeem_out is not None) if self.coin_clients[coin_type]['use_segwit']: # Change to btc hrp @@ -3102,7 +3102,7 @@ class BasicSwap(BaseApp): return rv def checkBidState(self, bid_id, bid, offer): - # assert(self.mxDB.locked()) + # assert (self.mxDB.locked()) # Return True to remove bid from in-progress list state = BidStates(bid.state) @@ -3484,7 +3484,7 @@ class BasicSwap(BaseApp): self.initiateTxnSpent(watched_output.bid_id, spend_txid_hex, spend_n, spend_txn) def checkForSpends(self, coin_type, c): - # assert(self.mxDB.locked()) + # assert (self.mxDB.locked()) self.log.debug('checkForSpends %s', coin_type) # TODO: Check for spends on watchonly txns where possible @@ -3935,7 +3935,7 @@ class BasicSwap(BaseApp): self.validateBidAmount(offer, bid_data.amount, bid_data.rate) # TODO: Allow higher bids - # assert(bid_data.rate != offer['data'].rate), 'Bid rate mismatch' + # assert (bid_data.rate != offer['data'].rate), 'Bid rate mismatch' coin_to = Coins(offer.coin_to) ci_from = self.ci(offer.coin_from) @@ -4641,7 +4641,7 @@ class BasicSwap(BaseApp): xmr_swap.al_lock_spend_tx_sig = ci_from.extractLeaderSig(xmr_swap.a_lock_spend_tx) kbsf = ci_from.recoverEncKey(xmr_swap.al_lock_spend_tx_esig, xmr_swap.al_lock_spend_tx_sig, xmr_swap.pkasf) - assert(kbsf is not None) + assert (kbsf is not None) for_ed25519 = True if coin_to == Coins.XMR else False kbsl = self.getPathKey(coin_from, coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSL, for_ed25519) @@ -4697,7 +4697,7 @@ class BasicSwap(BaseApp): af_lock_refund_spend_tx_sig = ci_from.extractFollowerSig(xmr_swap.a_lock_refund_spend_tx) kbsl = ci_from.recoverEncKey(xmr_swap.af_lock_refund_spend_tx_esig, af_lock_refund_spend_tx_sig, xmr_swap.pkasl) - assert(kbsl is not None) + assert (kbsl is not None) for_ed25519 = True if coin_to == Coins.XMR else False kbsf = self.getPathKey(coin_from, coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSF, for_ed25519) diff --git a/basicswap/explorers.py b/basicswap/explorers.py index c0fff03..84a36bd 100644 --- a/basicswap/explorers.py +++ b/basicswap/explorers.py @@ -75,7 +75,7 @@ class ExplorerBitAps(Explorer): # Can't get unspents return only if exactly one transaction exists data = json.loads(self.readURL(self.base_url + '/address/transactions/' + address)) try: - assert(data['data']['list'] == 1) + assert data['data']['list'] == 1 except Exception as ex: self.log.debug('Explorer error: {}'.format(str(ex))) return None diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 6f811ff..593f61a 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -356,7 +356,7 @@ class HttpHandler(BaseHTTPRequestHandler): ensure(len(url_split) > 2, 'Bid ID not specified') try: bid_id = bytes.fromhex(url_split[2]) - assert(len(bid_id) == 28) + assert len(bid_id) == 28 except Exception: raise ValueError('Bad bid ID') swap_client = self.server.swap_client diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index ffcffbd..cfcea9e 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -157,7 +157,7 @@ class BTCInterface(CoinInterface): @staticmethod def getExpectedSequence(lockType, lockVal): - assert(lockVal >= 1), 'Bad lockVal' + assert (lockVal >= 1), 'Bad lockVal' if lockType == TxLockTypes.SEQUENCE_LOCK_BLOCKS: return lockVal if lockType == TxLockTypes.SEQUENCE_LOCK_TIME: @@ -289,7 +289,7 @@ class BTCInterface(CoinInterface): except Exception: try: fee_rate = self.rpc_callback('getwalletinfo')['paytxfee'], 'paytxfee' - assert(fee_rate > 0.0), '0 feerate' + assert (fee_rate > 0.0), '0 feerate' return fee_rate except Exception: return self.rpc_callback('getnetworkinfo')['relayfee'], 'relayfee' @@ -311,7 +311,7 @@ class BTCInterface(CoinInterface): def pkh_to_address(self, pkh): # pkh is hash160(pk) - assert(len(pkh) == 20) + assert (len(pkh) == 20) prefix = self.chainparams_network()['pubkey_address'] data = bytes((prefix,)) + pkh checksum = hashlib.sha256(hashlib.sha256(data).digest()).digest() @@ -327,7 +327,7 @@ class BTCInterface(CoinInterface): return pubkeyToAddress(self.chainparams_network()['script_address'], script) def pubkey_to_address(self, pk): - assert(len(pk) == 33) + assert (len(pk) == 33) return self.pkh_to_address(hash160(pk)) def getNewSecretKey(self): @@ -342,7 +342,7 @@ class BTCInterface(CoinInterface): def verifyKey(self, k): i = b2i(k) - return(i < ep.o and i > 0) + return (i < ep.o and i > 0) def verifyPubkey(self, pubkey_bytes): return verify_secp256k1_point(pubkey_bytes) @@ -629,7 +629,7 @@ class BTCInterface(CoinInterface): for txo in tx.vout: outputs_value += txo.nValue fee_paid = inputs_value - outputs_value - assert(fee_paid > 0) + assert (fee_paid > 0) vsize = self.getTxVSize(tx, add_bytes, add_witness_bytes) fee_rate_paid = fee_paid * 1000 // vsize @@ -677,7 +677,7 @@ class BTCInterface(CoinInterface): ensure(C == Kaf, 'Bad script pubkey') fee_paid = swap_value - locked_coin - assert(fee_paid > 0) + assert (fee_paid > 0) dummy_witness_stack = self.getScriptLockTxDummyWitness(prevout_script) witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack) @@ -721,7 +721,7 @@ class BTCInterface(CoinInterface): tx_value = tx.vout[0].nValue fee_paid = prevout_value - tx_value - assert(fee_paid > 0) + assert (fee_paid > 0) dummy_witness_stack = self.getScriptLockRefundSpendTxDummyWitness(prevout_script) witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack) @@ -768,7 +768,7 @@ class BTCInterface(CoinInterface): # The value of the lock tx output should already be verified, if the fee is as expected the difference will be the correct amount fee_paid = locked_coin - tx.vout[0].nValue - assert(fee_paid > 0) + assert (fee_paid > 0) dummy_witness_stack = self.getScriptLockTxDummyWitness(lock_tx_script) witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack) @@ -1065,7 +1065,7 @@ class BTCInterface(CoinInterface): message_hash = hashlib.sha256(bytes(message, 'utf-8')).digest() pubkey = PublicKey(K) rv = pubkey.verify_compact(sig, message_hash, hasher=None) - assert(rv is True) + assert (rv is True) def verifyMessage(self, address, message, signature, message_magic=None) -> bool: if message_magic is None: diff --git a/basicswap/interface_part.py b/basicswap/interface_part.py index 6a680c8..81de26c 100644 --- a/basicswap/interface_part.py +++ b/basicswap/interface_part.py @@ -172,7 +172,7 @@ class PARTInterfaceBlind(PARTInterface): # Nonce is derived from vkbv, ephemeral_key isn't used ephemeral_key = i2b(self.getNewSecretKey()) ephemeral_pubkey = self.getPubkey(ephemeral_key) - assert(len(ephemeral_pubkey) == 33) + assert (len(ephemeral_pubkey) == 33) nonce = self.getScriptLockTxNonce(vkbv) p2wsh_addr = self.encode_p2wsh(getP2WSH(script)) inputs = [] @@ -192,7 +192,7 @@ class PARTInterfaceBlind(PARTInterface): tx_obj = self.rpc_callback('decoderawtransaction', [tx_hex]) - assert(len(tx_obj['vout']) == 1) + assert (len(tx_obj['vout']) == 1) txo = tx_obj['vout'][0] blinded_info = self.rpc_callback('rewindrangeproof', [txo['rangeproof'], txo['valueCommitment'], nonce.hex()]) @@ -207,11 +207,11 @@ class PARTInterfaceBlind(PARTInterface): def createScriptLockRefundTx(self, tx_lock_bytes, script_lock, Kal, Kaf, lock1_value, csv_val, tx_fee_rate, vkbv): lock_tx_obj = self.rpc_callback('decoderawtransaction', [tx_lock_bytes.hex()]) - assert(self.getTxid(tx_lock_bytes).hex() == lock_tx_obj['txid']) + assert (self.getTxid(tx_lock_bytes).hex() == lock_tx_obj['txid']) # Nonce is derived from vkbv, ephemeral_key isn't used ephemeral_key = i2b(self.getNewSecretKey()) ephemeral_pubkey = self.getPubkey(ephemeral_key) - assert(len(ephemeral_pubkey) == 33) + assert (len(ephemeral_pubkey) == 33) nonce = self.getScriptLockTxNonce(vkbv) output_nonce = self.getScriptLockRefundTxNonce(vkbv) @@ -675,7 +675,7 @@ class PARTInterfaceAnon(PARTInterface): if len(txns) == 1: tx = txns[0] - assert(tx['outputs'][0]['stealth_address'] == sx_addr) # Should not be possible + assert (tx['outputs'][0]['stealth_address'] == sx_addr) # Should not be possible ensure(tx['outputs'][0]['type'] == 'anon', 'Output is not anon') if make_int(tx['outputs'][0]['amount']) == cb_swap_value: diff --git a/basicswap/interface_xmr.py b/basicswap/interface_xmr.py index d676d31..6e1d15a 100644 --- a/basicswap/interface_xmr.py +++ b/basicswap/interface_xmr.py @@ -199,7 +199,7 @@ class XMRInterface(CoinInterface): def verifyKey(self, k): i = b2i(k) - return(i < edf.l and i > 8) + return (i < edf.l and i > 8) def verifyPubkey(self, pubkey_bytes): # Calls ed25519_decode_check_point() in secp256k1 diff --git a/basicswap/js_server.py b/basicswap/js_server.py index 669d13c..cd14f20 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -143,18 +143,18 @@ def js_offers(self, url_split, post_string, is_json, sent=False): if have_data_entry(post_data, 'sort_by'): sort_by = get_data_entry(post_data, 'sort_by') - assert(sort_by in ['created_at', 'rate']), 'Invalid sort by' + assert (sort_by in ['created_at', 'rate']), 'Invalid sort by' filters['sort_by'] = sort_by if have_data_entry(post_data, 'sort_dir'): sort_dir = get_data_entry(post_data, 'sort_dir') - assert(sort_dir in ['asc', 'desc']), 'Invalid sort dir' + assert (sort_dir in ['asc', 'desc']), 'Invalid sort dir' filters['sort_dir'] = sort_dir if b'offset' in post_data: filters['offset'] = int(get_data_entry(post_data, 'offset')) if b'limit' in post_data: filters['limit'] = int(get_data_entry(post_data, 'limit')) - assert(filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit' + assert (filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit' offers = self.server.swap_client.listOffers(sent, filters) rv = [] @@ -194,10 +194,10 @@ def js_bids(self, url_split, post_string, is_json): post_data = urllib.parse.parse_qs(post_string) offer_id = bytes.fromhex(get_data_entry(post_data, 'offer_id')) - assert(len(offer_id) == 28) + assert (len(offer_id) == 28) offer = swap_client.getOffer(offer_id) - assert(offer), 'Offer not found.' + assert (offer), 'Offer not found.' ci_from = swap_client.ci(offer.coin_from) ci_to = swap_client.ci(offer.coin_to) @@ -236,7 +236,7 @@ def js_bids(self, url_split, post_string, is_json): return bytes(json.dumps(rv), 'UTF-8') bid_id = bytes.fromhex(url_split[3]) - assert(len(bid_id) == 28) + assert (len(bid_id) == 28) if post_string != '': if is_json: @@ -250,7 +250,7 @@ def js_bids(self, url_split, post_string, is_json): swap_client.setBidDebugInd(bid_id, int(get_data_entry(post_data, 'debugind'))) bid, xmr_swap, offer, xmr_offer, events = swap_client.getXmrBidAndOffer(bid_id) - assert(bid), 'Unknown bid ID' + assert (bid), 'Unknown bid ID' if post_string != '': if have_data_entry(post_data, 'chainbkeysplit'): @@ -290,7 +290,7 @@ def js_network(self, url_split, post_string, is_json): def js_revokeoffer(self, url_split, post_string, is_json): offer_id = bytes.fromhex(url_split[3]) - assert(len(offer_id) == 28) + assert (len(offer_id) == 28) self.server.swap_client.revokeOffer(offer_id) return bytes(json.dumps({'revoked_offer': offer_id.hex()}), 'UTF-8') diff --git a/basicswap/util/__init__.py b/basicswap/util/__init__.py index 09ae3e4..49fe09e 100644 --- a/basicswap/util/__init__.py +++ b/basicswap/util/__init__.py @@ -56,7 +56,7 @@ def SerialiseNum(n): rv = bytearray() neg = n < 0 absvalue = -n if neg else n - while(absvalue): + while (absvalue): rv.append(absvalue & 0xff) absvalue >>= 8 if rv[-1] & 0x80: diff --git a/basicswap/util/address.py b/basicswap/util/address.py index 9ce2764..6cc6baf 100644 --- a/basicswap/util/address.py +++ b/basicswap/util/address.py @@ -114,7 +114,7 @@ def decodeAddress(address_str): if b58_addr is not None: address = b58_addr[:-4] checksum = b58_addr[-4:] - assert(hashlib.sha256(hashlib.sha256(address).digest()).digest()[:4] == checksum), 'Checksum mismatch' + assert (hashlib.sha256(hashlib.sha256(address).digest()).digest()[:4] == checksum), 'Checksum mismatch' return b58_addr[:-4] return None diff --git a/basicswap/util/ecc.py b/basicswap/util/ecc.py index 96eb578..fb71e93 100644 --- a/basicswap/util/ecc.py +++ b/basicswap/util/ecc.py @@ -171,18 +171,18 @@ def testEccUtils(): print('testEccUtils()') G_enc = ToDER(G) - assert(G_enc.hex() == '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8') + assert (G_enc.hex() == '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8') G_enc = pointToCPK(G) - assert(G_enc.hex() == '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798') + assert (G_enc.hex() == '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798') G_dec = CPKToPoint(G_enc) - assert(G_dec == G) + assert (G_dec == G) G_enc = pointToCPK2(G) - assert(G_enc.hex() == '0879be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798') + assert (G_enc.hex() == '0879be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798') H = hashToCurve(ToDER(G)) - assert(pointToCPK(H).hex() == '0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0') + assert (pointToCPK(H).hex() == '0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0') print('Passed.') diff --git a/basicswap/util/rfc2440.py b/basicswap/util/rfc2440.py index be7aa1e..ae6f2e8 100644 --- a/basicswap/util/rfc2440.py +++ b/basicswap/util/rfc2440.py @@ -14,7 +14,7 @@ def rfc2440_hash_password(password, salt=None): if salt is None: salt = secrets.token_bytes(8) - assert(len(salt) == 8) + assert len(salt) == 8 hashbytes = salt + password.encode('utf-8') len_hashbytes = len(hashbytes) diff --git a/basicswap/util/script.py b/basicswap/util/script.py index d732ef2..e84101c 100644 --- a/basicswap/util/script.py +++ b/basicswap/util/script.py @@ -13,7 +13,7 @@ def decodeScriptNum(script_bytes, o): v = 0 num_len = script_bytes[o] if num_len >= OpCodes.OP_1 and num_len <= OpCodes.OP_16: - return((num_len - OpCodes.OP_1) + 1, 1) + return ((num_len - OpCodes.OP_1) + 1, 1) if num_len > 4: raise ValueError('Bad scriptnum length') # Max 4 bytes @@ -29,7 +29,7 @@ def decodeScriptNum(script_bytes, o): v *= -1 else: v += int(b) << 8 * i - return(v, 1 + num_len) + return (v, 1 + num_len) def getP2SHScriptForHash(p2sh): diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index 8c0804e..f721a3d 100755 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -193,7 +193,7 @@ def testTorConnection(): logger.info('Testing TOR connection at: ' + test_url) test_response = downloadBytes(test_url).decode('utf-8') - assert('Congratulations. This browser is configured to use Tor.' in test_response) + assert ('Congratulations. This browser is configured to use Tor.' in test_response) logger.info('TOR is working.') @@ -201,7 +201,7 @@ def testOnionLink(): test_url = 'http://jqyzxhjk6psc6ul5jnfwloamhtyh7si74b4743k2qgpskwwxrzhsxmad.onion' logger.info('Testing onion site: ' + test_url) test_response = downloadBytes(test_url).decode('utf-8') - assert('The Tor Project\'s free software protects your privacy online.' in test_response) + assert ('The Tor Project\'s free software protects your privacy online.' in test_response) logger.info('Onion links work.') diff --git a/tests/basicswap/common.py b/tests/basicswap/common.py index 882c2c1..4b1934a 100644 --- a/tests/basicswap/common.py +++ b/tests/basicswap/common.py @@ -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 diff --git a/tests/basicswap/common_xmr.py b/tests/basicswap/common_xmr.py index e1b1190..75e8bba 100644 --- a/tests/basicswap/common_xmr.py +++ b/tests/basicswap/common_xmr.py @@ -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): diff --git a/tests/basicswap/extended/test_http_ui.py b/tests/basicswap/extended/test_http_ui.py index 7afa278..6afb0eb 100644 --- a/tests/basicswap/extended/test_http_ui.py +++ b/tests/basicswap/extended/test_http_ui.py @@ -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() diff --git a/tests/basicswap/extended/test_nmc.py b/tests/basicswap/extended/test_nmc.py index 4176867..98800b9 100644 --- a/tests/basicswap/extended/test_nmc.py +++ b/tests/basicswap/extended/test_nmc.py @@ -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') diff --git a/tests/basicswap/extended/test_wallet_init.py b/tests/basicswap/extended/test_wallet_init.py index f15e67d..17b903a 100644 --- a/tests/basicswap/extended/test_wallet_init.py +++ b/tests/basicswap/extended/test_wallet_init.py @@ -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() diff --git a/tests/basicswap/extended/test_wallet_restore.py b/tests/basicswap/extended/test_wallet_restore.py index 41fdb69..2021a2a 100644 --- a/tests/basicswap/extended/test_wallet_restore.py +++ b/tests/basicswap/extended/test_wallet_restore.py @@ -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.') diff --git a/tests/basicswap/extended/test_xmr_persistent.py b/tests/basicswap/extended/test_xmr_persistent.py index 2d79943..6d3ee18 100644 --- a/tests/basicswap/extended/test_xmr_persistent.py +++ b/tests/basicswap/extended/test_xmr_persistent.py @@ -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): diff --git a/tests/basicswap/test_btc_xmr.py b/tests/basicswap/test_btc_xmr.py index de4e9f1..8178e11 100644 --- a/tests/basicswap/test_btc_xmr.py +++ b/tests/basicswap/test_btc_xmr.py @@ -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__': diff --git a/tests/basicswap/test_ltc_xmr.py b/tests/basicswap/test_ltc_xmr.py index c333726..b1fc275 100644 --- a/tests/basicswap/test_ltc_xmr.py +++ b/tests/basicswap/test_ltc_xmr.py @@ -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__': diff --git a/tests/basicswap/test_other.py b/tests/basicswap/test_other.py index 12336bf..f83a8c8 100644 --- a/tests/basicswap/test_other.py +++ b/tests/basicswap/test_other.py @@ -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__': diff --git a/tests/basicswap/test_partblind_xmr.py b/tests/basicswap/test_partblind_xmr.py index 3b56f85..1a1a83a 100644 --- a/tests/basicswap/test_partblind_xmr.py +++ b/tests/basicswap/test_partblind_xmr.py @@ -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__': diff --git a/tests/basicswap/test_reload.py b/tests/basicswap/test_reload.py index 94b55f5..a7bbc3d 100644 --- a/tests/basicswap/test_reload.py +++ b/tests/basicswap/test_reload.py @@ -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() diff --git a/tests/basicswap/test_run.py b/tests/basicswap/test_run.py index 2d55b99..4700836 100644 --- a/tests/basicswap/test_run.py +++ b/tests/basicswap/test_run.py @@ -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') diff --git a/tests/basicswap/test_xmr.py b/tests/basicswap/test_xmr.py index bdef860..522c244 100644 --- a/tests/basicswap/test_xmr.py +++ b/tests/basicswap/test_xmr.py @@ -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() diff --git a/tests/basicswap/test_xmr_bids_offline.py b/tests/basicswap/test_xmr_bids_offline.py index f5a4e82..55af458 100644 --- a/tests/basicswap/test_xmr_bids_offline.py +++ b/tests/basicswap/test_xmr_bids_offline.py @@ -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__': diff --git a/tests/basicswap/test_xmr_reload.py b/tests/basicswap/test_xmr_reload.py index c28e9b5..3d8d8d8 100644 --- a/tests/basicswap/test_xmr_reload.py +++ b/tests/basicswap/test_xmr_reload.py @@ -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)