mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-18 16:44:34 +00:00
refactor: E275 missing whitespace after keyword
This commit is contained in:
parent
1601a57aed
commit
1c4f208d27
29 changed files with 295 additions and 295 deletions
|
@ -519,13 +519,13 @@ class BasicSwap(BaseApp):
|
||||||
|
|
||||||
with open(pidfilepath, 'rb') as fp:
|
with open(pidfilepath, 'rb') as fp:
|
||||||
datadir_pid = int(fp.read().decode('utf-8'))
|
datadir_pid = int(fp.read().decode('utf-8'))
|
||||||
assert(datadir_pid == cc['pid']), 'Mismatched pid'
|
assert (datadir_pid == cc['pid']), 'Mismatched pid'
|
||||||
assert(os.path.exists(authcookiepath))
|
assert (os.path.exists(authcookiepath))
|
||||||
except Exception:
|
except Exception:
|
||||||
self.delay_event.wait(0.5)
|
self.delay_event.wait(0.5)
|
||||||
try:
|
try:
|
||||||
if os.name != 'nt' or cc['core_version_group'] > 17: # Litecoin on windows doesn't write a pid file
|
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:
|
with open(authcookiepath, 'rb') as fp:
|
||||||
cc['rpcauth'] = fp.read().decode('utf-8')
|
cc['rpcauth'] = fp.read().decode('utf-8')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -2074,7 +2074,7 @@ class BasicSwap(BaseApp):
|
||||||
else:
|
else:
|
||||||
xmr_swap.kbsf_dleag = xmr_swap.pkbsf
|
xmr_swap.kbsf_dleag = xmr_swap.pkbsf
|
||||||
xmr_swap.pkasf = xmr_swap.kbsf_dleag[0: 33]
|
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.pkaf = xmr_swap.pkaf
|
||||||
msg_buf.kbvf = kbvf
|
msg_buf.kbvf = kbvf
|
||||||
|
@ -2432,7 +2432,7 @@ class BasicSwap(BaseApp):
|
||||||
|
|
||||||
amount_to = bid.amount_to
|
amount_to = bid.amount_to
|
||||||
# Check required?
|
# 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:
|
if bid.debug_ind == DebugTypes.MAKE_INVALID_PTX:
|
||||||
amount_to -= 1
|
amount_to -= 1
|
||||||
|
@ -2536,7 +2536,7 @@ class BasicSwap(BaseApp):
|
||||||
|
|
||||||
if addr_redeem_out is None:
|
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)
|
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']:
|
if self.coin_clients[coin_type]['use_segwit']:
|
||||||
# Change to btc hrp
|
# Change to btc hrp
|
||||||
|
@ -3102,7 +3102,7 @@ class BasicSwap(BaseApp):
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def checkBidState(self, bid_id, bid, offer):
|
def checkBidState(self, bid_id, bid, offer):
|
||||||
# assert(self.mxDB.locked())
|
# assert (self.mxDB.locked())
|
||||||
# Return True to remove bid from in-progress list
|
# Return True to remove bid from in-progress list
|
||||||
|
|
||||||
state = BidStates(bid.state)
|
state = BidStates(bid.state)
|
||||||
|
@ -3484,7 +3484,7 @@ class BasicSwap(BaseApp):
|
||||||
self.initiateTxnSpent(watched_output.bid_id, spend_txid_hex, spend_n, spend_txn)
|
self.initiateTxnSpent(watched_output.bid_id, spend_txid_hex, spend_n, spend_txn)
|
||||||
|
|
||||||
def checkForSpends(self, coin_type, c):
|
def checkForSpends(self, coin_type, c):
|
||||||
# assert(self.mxDB.locked())
|
# assert (self.mxDB.locked())
|
||||||
self.log.debug('checkForSpends %s', coin_type)
|
self.log.debug('checkForSpends %s', coin_type)
|
||||||
|
|
||||||
# TODO: Check for spends on watchonly txns where possible
|
# 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)
|
self.validateBidAmount(offer, bid_data.amount, bid_data.rate)
|
||||||
|
|
||||||
# TODO: Allow higher bids
|
# 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)
|
coin_to = Coins(offer.coin_to)
|
||||||
ci_from = self.ci(offer.coin_from)
|
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)
|
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)
|
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
|
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)
|
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)
|
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)
|
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
|
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)
|
kbsf = self.getPathKey(coin_from, coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSF, for_ed25519)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class ExplorerBitAps(Explorer):
|
||||||
# Can't get unspents return only if exactly one transaction exists
|
# Can't get unspents return only if exactly one transaction exists
|
||||||
data = json.loads(self.readURL(self.base_url + '/address/transactions/' + address))
|
data = json.loads(self.readURL(self.base_url + '/address/transactions/' + address))
|
||||||
try:
|
try:
|
||||||
assert(data['data']['list'] == 1)
|
assert data['data']['list'] == 1
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.log.debug('Explorer error: {}'.format(str(ex)))
|
self.log.debug('Explorer error: {}'.format(str(ex)))
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -356,7 +356,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
ensure(len(url_split) > 2, 'Bid ID not specified')
|
ensure(len(url_split) > 2, 'Bid ID not specified')
|
||||||
try:
|
try:
|
||||||
bid_id = bytes.fromhex(url_split[2])
|
bid_id = bytes.fromhex(url_split[2])
|
||||||
assert(len(bid_id) == 28)
|
assert len(bid_id) == 28
|
||||||
except Exception:
|
except Exception:
|
||||||
raise ValueError('Bad bid ID')
|
raise ValueError('Bad bid ID')
|
||||||
swap_client = self.server.swap_client
|
swap_client = self.server.swap_client
|
||||||
|
|
|
@ -157,7 +157,7 @@ class BTCInterface(CoinInterface):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getExpectedSequence(lockType, lockVal):
|
def getExpectedSequence(lockType, lockVal):
|
||||||
assert(lockVal >= 1), 'Bad lockVal'
|
assert (lockVal >= 1), 'Bad lockVal'
|
||||||
if lockType == TxLockTypes.SEQUENCE_LOCK_BLOCKS:
|
if lockType == TxLockTypes.SEQUENCE_LOCK_BLOCKS:
|
||||||
return lockVal
|
return lockVal
|
||||||
if lockType == TxLockTypes.SEQUENCE_LOCK_TIME:
|
if lockType == TxLockTypes.SEQUENCE_LOCK_TIME:
|
||||||
|
@ -289,7 +289,7 @@ class BTCInterface(CoinInterface):
|
||||||
except Exception:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
fee_rate = self.rpc_callback('getwalletinfo')['paytxfee'], 'paytxfee'
|
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
|
return fee_rate
|
||||||
except Exception:
|
except Exception:
|
||||||
return self.rpc_callback('getnetworkinfo')['relayfee'], 'relayfee'
|
return self.rpc_callback('getnetworkinfo')['relayfee'], 'relayfee'
|
||||||
|
@ -311,7 +311,7 @@ class BTCInterface(CoinInterface):
|
||||||
|
|
||||||
def pkh_to_address(self, pkh):
|
def pkh_to_address(self, pkh):
|
||||||
# pkh is hash160(pk)
|
# pkh is hash160(pk)
|
||||||
assert(len(pkh) == 20)
|
assert (len(pkh) == 20)
|
||||||
prefix = self.chainparams_network()['pubkey_address']
|
prefix = self.chainparams_network()['pubkey_address']
|
||||||
data = bytes((prefix,)) + pkh
|
data = bytes((prefix,)) + pkh
|
||||||
checksum = hashlib.sha256(hashlib.sha256(data).digest()).digest()
|
checksum = hashlib.sha256(hashlib.sha256(data).digest()).digest()
|
||||||
|
@ -327,7 +327,7 @@ class BTCInterface(CoinInterface):
|
||||||
return pubkeyToAddress(self.chainparams_network()['script_address'], script)
|
return pubkeyToAddress(self.chainparams_network()['script_address'], script)
|
||||||
|
|
||||||
def pubkey_to_address(self, pk):
|
def pubkey_to_address(self, pk):
|
||||||
assert(len(pk) == 33)
|
assert (len(pk) == 33)
|
||||||
return self.pkh_to_address(hash160(pk))
|
return self.pkh_to_address(hash160(pk))
|
||||||
|
|
||||||
def getNewSecretKey(self):
|
def getNewSecretKey(self):
|
||||||
|
@ -342,7 +342,7 @@ class BTCInterface(CoinInterface):
|
||||||
|
|
||||||
def verifyKey(self, k):
|
def verifyKey(self, k):
|
||||||
i = b2i(k)
|
i = b2i(k)
|
||||||
return(i < ep.o and i > 0)
|
return (i < ep.o and i > 0)
|
||||||
|
|
||||||
def verifyPubkey(self, pubkey_bytes):
|
def verifyPubkey(self, pubkey_bytes):
|
||||||
return verify_secp256k1_point(pubkey_bytes)
|
return verify_secp256k1_point(pubkey_bytes)
|
||||||
|
@ -629,7 +629,7 @@ class BTCInterface(CoinInterface):
|
||||||
for txo in tx.vout:
|
for txo in tx.vout:
|
||||||
outputs_value += txo.nValue
|
outputs_value += txo.nValue
|
||||||
fee_paid = inputs_value - outputs_value
|
fee_paid = inputs_value - outputs_value
|
||||||
assert(fee_paid > 0)
|
assert (fee_paid > 0)
|
||||||
|
|
||||||
vsize = self.getTxVSize(tx, add_bytes, add_witness_bytes)
|
vsize = self.getTxVSize(tx, add_bytes, add_witness_bytes)
|
||||||
fee_rate_paid = fee_paid * 1000 // vsize
|
fee_rate_paid = fee_paid * 1000 // vsize
|
||||||
|
@ -677,7 +677,7 @@ class BTCInterface(CoinInterface):
|
||||||
ensure(C == Kaf, 'Bad script pubkey')
|
ensure(C == Kaf, 'Bad script pubkey')
|
||||||
|
|
||||||
fee_paid = swap_value - locked_coin
|
fee_paid = swap_value - locked_coin
|
||||||
assert(fee_paid > 0)
|
assert (fee_paid > 0)
|
||||||
|
|
||||||
dummy_witness_stack = self.getScriptLockTxDummyWitness(prevout_script)
|
dummy_witness_stack = self.getScriptLockTxDummyWitness(prevout_script)
|
||||||
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
||||||
|
@ -721,7 +721,7 @@ class BTCInterface(CoinInterface):
|
||||||
tx_value = tx.vout[0].nValue
|
tx_value = tx.vout[0].nValue
|
||||||
|
|
||||||
fee_paid = prevout_value - tx_value
|
fee_paid = prevout_value - tx_value
|
||||||
assert(fee_paid > 0)
|
assert (fee_paid > 0)
|
||||||
|
|
||||||
dummy_witness_stack = self.getScriptLockRefundSpendTxDummyWitness(prevout_script)
|
dummy_witness_stack = self.getScriptLockRefundSpendTxDummyWitness(prevout_script)
|
||||||
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
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
|
# 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
|
fee_paid = locked_coin - tx.vout[0].nValue
|
||||||
assert(fee_paid > 0)
|
assert (fee_paid > 0)
|
||||||
|
|
||||||
dummy_witness_stack = self.getScriptLockTxDummyWitness(lock_tx_script)
|
dummy_witness_stack = self.getScriptLockTxDummyWitness(lock_tx_script)
|
||||||
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
witness_bytes = self.getWitnessStackSerialisedLength(dummy_witness_stack)
|
||||||
|
@ -1065,7 +1065,7 @@ class BTCInterface(CoinInterface):
|
||||||
message_hash = hashlib.sha256(bytes(message, 'utf-8')).digest()
|
message_hash = hashlib.sha256(bytes(message, 'utf-8')).digest()
|
||||||
pubkey = PublicKey(K)
|
pubkey = PublicKey(K)
|
||||||
rv = pubkey.verify_compact(sig, message_hash, hasher=None)
|
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:
|
def verifyMessage(self, address, message, signature, message_magic=None) -> bool:
|
||||||
if message_magic is None:
|
if message_magic is None:
|
||||||
|
|
|
@ -172,7 +172,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
# Nonce is derived from vkbv, ephemeral_key isn't used
|
# Nonce is derived from vkbv, ephemeral_key isn't used
|
||||||
ephemeral_key = i2b(self.getNewSecretKey())
|
ephemeral_key = i2b(self.getNewSecretKey())
|
||||||
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
||||||
assert(len(ephemeral_pubkey) == 33)
|
assert (len(ephemeral_pubkey) == 33)
|
||||||
nonce = self.getScriptLockTxNonce(vkbv)
|
nonce = self.getScriptLockTxNonce(vkbv)
|
||||||
p2wsh_addr = self.encode_p2wsh(getP2WSH(script))
|
p2wsh_addr = self.encode_p2wsh(getP2WSH(script))
|
||||||
inputs = []
|
inputs = []
|
||||||
|
@ -192,7 +192,7 @@ class PARTInterfaceBlind(PARTInterface):
|
||||||
|
|
||||||
tx_obj = self.rpc_callback('decoderawtransaction', [tx_hex])
|
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]
|
txo = tx_obj['vout'][0]
|
||||||
blinded_info = self.rpc_callback('rewindrangeproof', [txo['rangeproof'], txo['valueCommitment'], nonce.hex()])
|
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):
|
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()])
|
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
|
# Nonce is derived from vkbv, ephemeral_key isn't used
|
||||||
ephemeral_key = i2b(self.getNewSecretKey())
|
ephemeral_key = i2b(self.getNewSecretKey())
|
||||||
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
ephemeral_pubkey = self.getPubkey(ephemeral_key)
|
||||||
assert(len(ephemeral_pubkey) == 33)
|
assert (len(ephemeral_pubkey) == 33)
|
||||||
nonce = self.getScriptLockTxNonce(vkbv)
|
nonce = self.getScriptLockTxNonce(vkbv)
|
||||||
output_nonce = self.getScriptLockRefundTxNonce(vkbv)
|
output_nonce = self.getScriptLockRefundTxNonce(vkbv)
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ class PARTInterfaceAnon(PARTInterface):
|
||||||
|
|
||||||
if len(txns) == 1:
|
if len(txns) == 1:
|
||||||
tx = txns[0]
|
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')
|
ensure(tx['outputs'][0]['type'] == 'anon', 'Output is not anon')
|
||||||
|
|
||||||
if make_int(tx['outputs'][0]['amount']) == cb_swap_value:
|
if make_int(tx['outputs'][0]['amount']) == cb_swap_value:
|
||||||
|
|
|
@ -199,7 +199,7 @@ class XMRInterface(CoinInterface):
|
||||||
|
|
||||||
def verifyKey(self, k):
|
def verifyKey(self, k):
|
||||||
i = b2i(k)
|
i = b2i(k)
|
||||||
return(i < edf.l and i > 8)
|
return (i < edf.l and i > 8)
|
||||||
|
|
||||||
def verifyPubkey(self, pubkey_bytes):
|
def verifyPubkey(self, pubkey_bytes):
|
||||||
# Calls ed25519_decode_check_point() in secp256k1
|
# Calls ed25519_decode_check_point() in secp256k1
|
||||||
|
|
|
@ -143,18 +143,18 @@ def js_offers(self, url_split, post_string, is_json, sent=False):
|
||||||
|
|
||||||
if have_data_entry(post_data, 'sort_by'):
|
if have_data_entry(post_data, 'sort_by'):
|
||||||
sort_by = get_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
|
filters['sort_by'] = sort_by
|
||||||
if have_data_entry(post_data, 'sort_dir'):
|
if have_data_entry(post_data, 'sort_dir'):
|
||||||
sort_dir = get_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
|
filters['sort_dir'] = sort_dir
|
||||||
|
|
||||||
if b'offset' in post_data:
|
if b'offset' in post_data:
|
||||||
filters['offset'] = int(get_data_entry(post_data, 'offset'))
|
filters['offset'] = int(get_data_entry(post_data, 'offset'))
|
||||||
if b'limit' in post_data:
|
if b'limit' in post_data:
|
||||||
filters['limit'] = int(get_data_entry(post_data, 'limit'))
|
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)
|
offers = self.server.swap_client.listOffers(sent, filters)
|
||||||
rv = []
|
rv = []
|
||||||
|
@ -194,10 +194,10 @@ def js_bids(self, url_split, post_string, is_json):
|
||||||
post_data = urllib.parse.parse_qs(post_string)
|
post_data = urllib.parse.parse_qs(post_string)
|
||||||
|
|
||||||
offer_id = bytes.fromhex(get_data_entry(post_data, 'offer_id'))
|
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)
|
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_from = swap_client.ci(offer.coin_from)
|
||||||
ci_to = swap_client.ci(offer.coin_to)
|
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')
|
return bytes(json.dumps(rv), 'UTF-8')
|
||||||
|
|
||||||
bid_id = bytes.fromhex(url_split[3])
|
bid_id = bytes.fromhex(url_split[3])
|
||||||
assert(len(bid_id) == 28)
|
assert (len(bid_id) == 28)
|
||||||
|
|
||||||
if post_string != '':
|
if post_string != '':
|
||||||
if is_json:
|
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')))
|
swap_client.setBidDebugInd(bid_id, int(get_data_entry(post_data, 'debugind')))
|
||||||
|
|
||||||
bid, xmr_swap, offer, xmr_offer, events = swap_client.getXmrBidAndOffer(bid_id)
|
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 post_string != '':
|
||||||
if have_data_entry(post_data, 'chainbkeysplit'):
|
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):
|
def js_revokeoffer(self, url_split, post_string, is_json):
|
||||||
offer_id = bytes.fromhex(url_split[3])
|
offer_id = bytes.fromhex(url_split[3])
|
||||||
assert(len(offer_id) == 28)
|
assert (len(offer_id) == 28)
|
||||||
self.server.swap_client.revokeOffer(offer_id)
|
self.server.swap_client.revokeOffer(offer_id)
|
||||||
return bytes(json.dumps({'revoked_offer': offer_id.hex()}), 'UTF-8')
|
return bytes(json.dumps({'revoked_offer': offer_id.hex()}), 'UTF-8')
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ def SerialiseNum(n):
|
||||||
rv = bytearray()
|
rv = bytearray()
|
||||||
neg = n < 0
|
neg = n < 0
|
||||||
absvalue = -n if neg else n
|
absvalue = -n if neg else n
|
||||||
while(absvalue):
|
while (absvalue):
|
||||||
rv.append(absvalue & 0xff)
|
rv.append(absvalue & 0xff)
|
||||||
absvalue >>= 8
|
absvalue >>= 8
|
||||||
if rv[-1] & 0x80:
|
if rv[-1] & 0x80:
|
||||||
|
|
|
@ -114,7 +114,7 @@ def decodeAddress(address_str):
|
||||||
if b58_addr is not None:
|
if b58_addr is not None:
|
||||||
address = b58_addr[:-4]
|
address = b58_addr[:-4]
|
||||||
checksum = 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 b58_addr[:-4]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -171,18 +171,18 @@ def testEccUtils():
|
||||||
print('testEccUtils()')
|
print('testEccUtils()')
|
||||||
|
|
||||||
G_enc = ToDER(G)
|
G_enc = ToDER(G)
|
||||||
assert(G_enc.hex() == '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8')
|
assert (G_enc.hex() == '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8')
|
||||||
|
|
||||||
G_enc = pointToCPK(G)
|
G_enc = pointToCPK(G)
|
||||||
assert(G_enc.hex() == '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')
|
assert (G_enc.hex() == '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')
|
||||||
G_dec = CPKToPoint(G_enc)
|
G_dec = CPKToPoint(G_enc)
|
||||||
assert(G_dec == G)
|
assert (G_dec == G)
|
||||||
|
|
||||||
G_enc = pointToCPK2(G)
|
G_enc = pointToCPK2(G)
|
||||||
assert(G_enc.hex() == '0879be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')
|
assert (G_enc.hex() == '0879be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')
|
||||||
|
|
||||||
H = hashToCurve(ToDER(G))
|
H = hashToCurve(ToDER(G))
|
||||||
assert(pointToCPK(H).hex() == '0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0')
|
assert (pointToCPK(H).hex() == '0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0')
|
||||||
|
|
||||||
print('Passed.')
|
print('Passed.')
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ def rfc2440_hash_password(password, salt=None):
|
||||||
|
|
||||||
if salt is None:
|
if salt is None:
|
||||||
salt = secrets.token_bytes(8)
|
salt = secrets.token_bytes(8)
|
||||||
assert(len(salt) == 8)
|
assert len(salt) == 8
|
||||||
|
|
||||||
hashbytes = salt + password.encode('utf-8')
|
hashbytes = salt + password.encode('utf-8')
|
||||||
len_hashbytes = len(hashbytes)
|
len_hashbytes = len(hashbytes)
|
||||||
|
|
|
@ -13,7 +13,7 @@ def decodeScriptNum(script_bytes, o):
|
||||||
v = 0
|
v = 0
|
||||||
num_len = script_bytes[o]
|
num_len = script_bytes[o]
|
||||||
if num_len >= OpCodes.OP_1 and num_len <= OpCodes.OP_16:
|
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:
|
if num_len > 4:
|
||||||
raise ValueError('Bad scriptnum length') # Max 4 bytes
|
raise ValueError('Bad scriptnum length') # Max 4 bytes
|
||||||
|
@ -29,7 +29,7 @@ def decodeScriptNum(script_bytes, o):
|
||||||
v *= -1
|
v *= -1
|
||||||
else:
|
else:
|
||||||
v += int(b) << 8 * i
|
v += int(b) << 8 * i
|
||||||
return(v, 1 + num_len)
|
return (v, 1 + num_len)
|
||||||
|
|
||||||
|
|
||||||
def getP2SHScriptForHash(p2sh):
|
def getP2SHScriptForHash(p2sh):
|
||||||
|
|
|
@ -193,7 +193,7 @@ def testTorConnection():
|
||||||
logger.info('Testing TOR connection at: ' + test_url)
|
logger.info('Testing TOR connection at: ' + test_url)
|
||||||
|
|
||||||
test_response = downloadBytes(test_url).decode('utf-8')
|
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.')
|
logger.info('TOR is working.')
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ def testOnionLink():
|
||||||
test_url = 'http://jqyzxhjk6psc6ul5jnfwloamhtyh7si74b4743k2qgpskwwxrzhsxmad.onion'
|
test_url = 'http://jqyzxhjk6psc6ul5jnfwloamhtyh7si74b4743k2qgpskwwxrzhsxmad.onion'
|
||||||
logger.info('Testing onion site: ' + test_url)
|
logger.info('Testing onion site: ' + test_url)
|
||||||
test_response = downloadBytes(test_url).decode('utf-8')
|
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.')
|
logger.info('Onion links work.')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,11 +83,11 @@ def prepareDataDir(datadir, node_id, conf_file, dir_prefix, base_p2p_port=BASE_P
|
||||||
|
|
||||||
def checkForks(ro):
|
def checkForks(ro):
|
||||||
if 'bip9_softforks' in ro:
|
if 'bip9_softforks' in ro:
|
||||||
assert(ro['bip9_softforks']['csv']['status'] == 'active')
|
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||||
assert(ro['bip9_softforks']['segwit']['status'] == 'active')
|
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||||
else:
|
else:
|
||||||
assert(ro['softforks']['csv']['active'])
|
assert (ro['softforks']['csv']['active'])
|
||||||
assert(ro['softforks']['segwit']['active'])
|
assert (ro['softforks']['segwit']['active'])
|
||||||
|
|
||||||
|
|
||||||
def stopDaemons(daemons):
|
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,
|
'bid_id': bid_id,
|
||||||
}
|
}
|
||||||
bids = swap_client.listBids(sent=sent, filters=filters)
|
bids = swap_client.listBids(sent=sent, filters=filters)
|
||||||
assert(len(bids) < 2)
|
assert (len(bids) < 2)
|
||||||
for bid in bids:
|
for bid in bids:
|
||||||
if bid[2] == bid_id:
|
if bid[2] == bid_id:
|
||||||
if type(state) == list:
|
if type(state) == list:
|
||||||
|
@ -377,9 +377,9 @@ def compare_bid_states(states, expect_states, exact_match=True):
|
||||||
del states[i]
|
del states[i]
|
||||||
|
|
||||||
if exact_match:
|
if exact_match:
|
||||||
assert(len(states) == len(expect_states))
|
assert (len(states) == len(expect_states))
|
||||||
else:
|
else:
|
||||||
assert(len(states) >= len(expect_states))
|
assert (len(states) >= len(expect_states))
|
||||||
|
|
||||||
for i in range(len(expect_states)):
|
for i in range(len(expect_states)):
|
||||||
s = states[i]
|
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]}.')
|
logging.warning(f'Expected state {expect_states[i]} found out of order at the same time as {s[1]}.')
|
||||||
continue
|
continue
|
||||||
raise ValueError(f'Expected state {expect_states[i]}, found {s[1]}')
|
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
|
return True
|
||||||
|
|
|
@ -322,7 +322,7 @@ class XmrTestBase(TestBase):
|
||||||
print('Error reading wallets', str(e))
|
print('Error reading wallets', str(e))
|
||||||
|
|
||||||
self.delay_event.wait(1)
|
self.delay_event.wait(1)
|
||||||
assert(particl_blocks >= num_blocks)
|
assert particl_blocks >= num_blocks
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
|
|
@ -59,7 +59,7 @@ def run_test():
|
||||||
driver.get(base_url)
|
driver.get(base_url)
|
||||||
link = driver.find_element_by_xpath('//a[@href="/offers"]')
|
link = driver.find_element_by_xpath('//a[@href="/offers"]')
|
||||||
num_offers_end = int(link.text.split(':')[1].strip())
|
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()
|
driver.quit()
|
||||||
|
|
||||||
|
|
|
@ -319,11 +319,11 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
ro = nmcRpc('getblockchaininfo')
|
ro = nmcRpc('getblockchaininfo')
|
||||||
try:
|
try:
|
||||||
assert(ro['bip9_softforks']['csv']['status'] == 'active')
|
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.info('nmc: csv is not active')
|
logging.info('nmc: csv is not active')
|
||||||
try:
|
try:
|
||||||
assert(ro['bip9_softforks']['segwit']['status'] == 'active')
|
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.info('nmc: segwit is not active')
|
logging.info('nmc: segwit is not active')
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ class Test(unittest.TestCase):
|
||||||
if particl_blocks >= num_blocks:
|
if particl_blocks >= num_blocks:
|
||||||
break
|
break
|
||||||
delay_event.wait(1)
|
delay_event.wait(1)
|
||||||
assert(particl_blocks >= num_blocks)
|
assert (particl_blocks >= num_blocks)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
@ -382,7 +382,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
wait_for_offer(delay_event, swap_clients[1], offer_id)
|
wait_for_offer(delay_event, swap_clients[1], offer_id)
|
||||||
offers = swap_clients[1].listOffers()
|
offers = swap_clients[1].listOffers()
|
||||||
assert(len(offers) == 1)
|
assert (len(offers) == 1)
|
||||||
for offer in offers:
|
for offer in offers:
|
||||||
if offer.offer_id == offer_id:
|
if offer.offer_id == offer_id:
|
||||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
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_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_03_nmc_part(self):
|
def test_03_nmc_part(self):
|
||||||
logging.info('---------- Test NMC to PART')
|
logging.info('---------- Test NMC to PART')
|
||||||
|
@ -423,8 +423,8 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_04_nmc_btc(self):
|
def test_04_nmc_btc(self):
|
||||||
logging.info('---------- Test NMC to BTC')
|
logging.info('---------- Test NMC to BTC')
|
||||||
|
@ -451,8 +451,8 @@ class Test(unittest.TestCase):
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
|
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_05_refund(self):
|
def test_05_refund(self):
|
||||||
# Seller submits initiate txn, buyer doesn't respond
|
# Seller submits initiate txn, buyer doesn't respond
|
||||||
|
@ -477,8 +477,8 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_06_self_bid(self):
|
def test_06_self_bid(self):
|
||||||
logging.info('---------- Test same client, BTC to NMC')
|
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)
|
wait_for_bid(delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
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_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):
|
def test_07_error(self):
|
||||||
logging.info('---------- Test error, BTC to NMC, set fee above bid value')
|
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)
|
waitForServer(self.delay_event, 12700)
|
||||||
|
|
||||||
wallets_0 = read_json_api(12700, 'wallets')
|
wallets_0 = read_json_api(12700, 'wallets')
|
||||||
assert(wallets_0['PART']['expected_seed'] is True)
|
assert (wallets_0['PART']['expected_seed'] is True)
|
||||||
assert(wallets_0['XMR']['expected_seed'] is True)
|
assert (wallets_0['XMR']['expected_seed'] is True)
|
||||||
|
|
||||||
waitForServer(self.delay_event, 12701)
|
waitForServer(self.delay_event, 12701)
|
||||||
wallets_1 = read_json_api(12701, 'wallets')
|
wallets_1 = read_json_api(12701, 'wallets')
|
||||||
|
|
||||||
assert(wallets_0['PART']['expected_seed'] is True)
|
assert (wallets_0['PART']['expected_seed'] is True)
|
||||||
assert(wallets_1['XMR']['expected_seed'] is True)
|
assert (wallets_1['XMR']['expected_seed'] is True)
|
||||||
|
|
||||||
# TODO: Check other coins
|
# TODO: Check other coins
|
||||||
|
|
||||||
assert(wallets_0['PART']['deposit_address'] == wallets_1['1']['deposit_address'])
|
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['XMR']['deposit_address'] == wallets_1['6']['deposit_address'])
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ class Test(TestBase):
|
||||||
|
|
||||||
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
||||||
summary = read_json_api(12700)
|
summary = read_json_api(12700)
|
||||||
assert(summary['num_sent_offers'] == 1)
|
assert (summary['num_sent_offers'] == 1)
|
||||||
|
|
||||||
logger.info('Waiting for offer')
|
logger.info('Waiting for offer')
|
||||||
waitForNumOffers(self.delay_event, 12701, 1)
|
waitForNumOffers(self.delay_event, 12701, 1)
|
||||||
|
@ -170,8 +170,8 @@ class Test(TestBase):
|
||||||
|
|
||||||
ltc_original = read_json_api(12700, 'wallets/ltc')
|
ltc_original = read_json_api(12700, 'wallets/ltc')
|
||||||
ltc_restored = read_json_api(12703, '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']) > 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']) == float(ltc_restored['balance']) + float(ltc_restored['unconfirmed']))
|
||||||
|
|
||||||
wallets_original = read_json_api(12700, 'wallets')
|
wallets_original = read_json_api(12700, 'wallets')
|
||||||
# TODO: After restoring a new deposit address should be generated, should be automated
|
# 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')
|
next_addr = read_json_api(12703, 'wallets/part/nextdepositaddr')
|
||||||
wallets_restored = read_json_api(12703, 'wallets')
|
wallets_restored = read_json_api(12703, 'wallets')
|
||||||
for k, w in wallets_original.items():
|
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.')
|
logging.info('Test passed.')
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ class Test(unittest.TestCase):
|
||||||
self.delay_event.wait(1)
|
self.delay_event.wait(1)
|
||||||
|
|
||||||
logging.info('PART blocks: %d', callpartrpc(0, 'getblockchaininfo')['blocks'])
|
logging.info('PART blocks: %d', callpartrpc(0, 'getblockchaininfo')['blocks'])
|
||||||
assert(particl_blocks >= num_blocks)
|
assert particl_blocks >= num_blocks
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
|
|
|
@ -88,12 +88,12 @@ class Test(BaseTest):
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
js_1 = read_json_api(1801, 'wallets')
|
js_1 = read_json_api(1801, 'wallets')
|
||||||
node1_from_after = self.getBalance(js_1)
|
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')
|
js_0 = read_json_api(1800, 'wallets')
|
||||||
node0_from_after = self.getBalance(js_0)
|
node0_from_after = self.getBalance(js_0)
|
||||||
# TODO: Discard block rewards
|
# 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_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||||
js_1_xmr_after = read_json_api(1801, '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))
|
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_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'])
|
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):
|
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)))
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
node0_from_after = self.getBalance(js_w0_after)
|
||||||
|
|
||||||
# TODO: Discard block rewards
|
# 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):
|
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)))
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
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)
|
node1_from_after = self.getBalance(js_w1_after)
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
# TODO: Discard block rewards
|
# 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)
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
swap_clients[0].acceptXmrBid(bid_id)
|
||||||
|
@ -219,11 +219,11 @@ class Test(BaseTest):
|
||||||
node0_from_after = self.getBalance(js_w0_after)
|
node0_from_after = self.getBalance(js_w0_after)
|
||||||
|
|
||||||
# TODO: Discard block rewards
|
# 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_before = self.getXmrBalance(js_w1_before)
|
||||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -109,12 +109,12 @@ class Test(BaseTest):
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
js_1 = read_json_api(1801, 'wallets')
|
js_1 = read_json_api(1801, 'wallets')
|
||||||
node1_from_after = self.getBalance(js_1)
|
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')
|
js_0 = read_json_api(1800, 'wallets')
|
||||||
node0_from_after = self.getBalance(js_0)
|
node0_from_after = self.getBalance(js_0)
|
||||||
# TODO: Discard block rewards
|
# 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_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||||
js_1_xmr_after = read_json_api(1801, '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))
|
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_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'])
|
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):
|
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)))
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
node0_from_after = self.getBalance(js_w0_after)
|
||||||
|
|
||||||
# TODO: Discard block rewards
|
# 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):
|
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)))
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
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)
|
node1_from_after = self.getBalance(js_w1_after)
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
# TODO: Discard block rewards
|
# 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)
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
swap_clients[0].acceptXmrBid(bid_id)
|
||||||
|
@ -239,11 +239,11 @@ class Test(BaseTest):
|
||||||
node0_from_after = self.getBalance(js_w0_after)
|
node0_from_after = self.getBalance(js_w0_after)
|
||||||
|
|
||||||
# TODO: Discard block rewards
|
# 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_before = self.getXmrBalance(js_w1_before)
|
||||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -44,8 +44,8 @@ class Test(unittest.TestCase):
|
||||||
def test_case(v, nb=None):
|
def test_case(v, nb=None):
|
||||||
b = SerialiseNum(v)
|
b = SerialiseNum(v)
|
||||||
if nb is not None:
|
if nb is not None:
|
||||||
assert(len(b) == nb)
|
assert (len(b) == nb)
|
||||||
assert(v == DeserialiseNum(b))
|
assert (v == DeserialiseNum(b))
|
||||||
test_case(0, 1)
|
test_case(0, 1)
|
||||||
test_case(1, 1)
|
test_case(1, 1)
|
||||||
test_case(16, 1)
|
test_case(16, 1)
|
||||||
|
@ -66,35 +66,35 @@ class Test(unittest.TestCase):
|
||||||
time_val = 48 * 60 * 60
|
time_val = 48 * 60 * 60
|
||||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
||||||
decoded = ci.decodeSequence(encoded)
|
decoded = ci.decodeSequence(encoded)
|
||||||
assert(decoded >= time_val)
|
assert (decoded >= time_val)
|
||||||
assert(decoded <= time_val + 512)
|
assert (decoded <= time_val + 512)
|
||||||
|
|
||||||
time_val = 24 * 60
|
time_val = 24 * 60
|
||||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_TIME, time_val)
|
||||||
decoded = ci.decodeSequence(encoded)
|
decoded = ci.decodeSequence(encoded)
|
||||||
assert(decoded >= time_val)
|
assert (decoded >= time_val)
|
||||||
assert(decoded <= time_val + 512)
|
assert (decoded <= time_val + 512)
|
||||||
|
|
||||||
blocks_val = 123
|
blocks_val = 123
|
||||||
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_BLOCKS, blocks_val)
|
encoded = ci.getExpectedSequence(TxLockTypes.SEQUENCE_LOCK_BLOCKS, blocks_val)
|
||||||
decoded = ci.decodeSequence(encoded)
|
decoded = ci.decodeSequence(encoded)
|
||||||
assert(decoded == blocks_val)
|
assert (decoded == blocks_val)
|
||||||
|
|
||||||
def test_make_int(self):
|
def test_make_int(self):
|
||||||
def test_case(vs, vf, expect_int):
|
def test_case(vs, vf, expect_int):
|
||||||
i = make_int(vs)
|
i = make_int(vs)
|
||||||
assert(i == expect_int and isinstance(i, int))
|
assert (i == expect_int and isinstance(i, int))
|
||||||
i = make_int(vf)
|
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)
|
vs_out = format_amount(i, 8)
|
||||||
# Strip
|
# Strip
|
||||||
for i in range(7):
|
for i in range(7):
|
||||||
if vs_out[-1] == '0':
|
if vs_out[-1] == '0':
|
||||||
vs_out = vs_out[:-1]
|
vs_out = vs_out[:-1]
|
||||||
if '.' in vs:
|
if '.' in vs:
|
||||||
assert(vs_out == vs)
|
assert (vs_out == vs)
|
||||||
else:
|
else:
|
||||||
assert(vs_out[:-2] == vs)
|
assert (vs_out[:-2] == vs)
|
||||||
test_case('0', 0, 0)
|
test_case('0', 0, 0)
|
||||||
test_case('1', 1, 100000000)
|
test_case('1', 1, 100000000)
|
||||||
test_case('10', 10, 1000000000)
|
test_case('10', 10, 1000000000)
|
||||||
|
@ -113,49 +113,49 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
make_int('0.123456789')
|
make_int('0.123456789')
|
||||||
assert(False)
|
assert (False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
assert(str(e) == 'Mantissa too long')
|
assert (str(e) == 'Mantissa too long')
|
||||||
validate_amount('0.12345678')
|
validate_amount('0.12345678')
|
||||||
|
|
||||||
# floor
|
# floor
|
||||||
assert(make_int('0.123456789', r=-1) == 12345678)
|
assert (make_int('0.123456789', r=-1) == 12345678)
|
||||||
# Round up
|
# 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_make_int12(self):
|
||||||
def test_case(vs, vf, expect_int):
|
def test_case(vs, vf, expect_int):
|
||||||
i = make_int(vs, 12)
|
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)
|
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)
|
vs_out = format_amount(i, 12)
|
||||||
# Strip
|
# Strip
|
||||||
for i in range(7):
|
for i in range(7):
|
||||||
if vs_out[-1] == '0':
|
if vs_out[-1] == '0':
|
||||||
vs_out = vs_out[:-1]
|
vs_out = vs_out[:-1]
|
||||||
if '.' in vs:
|
if '.' in vs:
|
||||||
assert(vs_out == vs)
|
assert (vs_out == vs)
|
||||||
else:
|
else:
|
||||||
assert(vs_out[:-2] == vs)
|
assert (vs_out[:-2] == vs)
|
||||||
test_case('0.123456789', 0.123456789, 123456789000)
|
test_case('0.123456789', 0.123456789, 123456789000)
|
||||||
test_case('0.123456789123', 0.123456789123, 123456789123)
|
test_case('0.123456789123', 0.123456789123, 123456789123)
|
||||||
try:
|
try:
|
||||||
make_int('0.1234567891234', 12)
|
make_int('0.1234567891234', 12)
|
||||||
assert(False)
|
assert (False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
assert(str(e) == 'Mantissa too long')
|
assert (str(e) == 'Mantissa too long')
|
||||||
validate_amount('0.123456789123', 12)
|
validate_amount('0.123456789123', 12)
|
||||||
try:
|
try:
|
||||||
validate_amount('0.1234567891234', 12)
|
validate_amount('0.1234567891234', 12)
|
||||||
assert(False)
|
assert (False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
assert('Too many decimal places' in str(e))
|
assert ('Too many decimal places' in str(e))
|
||||||
try:
|
try:
|
||||||
validate_amount(0.1234567891234, 12)
|
validate_amount(0.1234567891234, 12)
|
||||||
assert(False)
|
assert (False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
assert('Too many decimal places' in str(e))
|
assert ('Too many decimal places' in str(e))
|
||||||
|
|
||||||
def test_ed25519(self):
|
def test_ed25519(self):
|
||||||
privkey = edu.get_secret()
|
privkey = edu.get_secret()
|
||||||
|
@ -163,7 +163,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
privkey_bytes = i2b(privkey)
|
privkey_bytes = i2b(privkey)
|
||||||
pubkey_test = ed25519_get_pubkey(privkey_bytes)
|
pubkey_test = ed25519_get_pubkey(privkey_bytes)
|
||||||
assert(pubkey == pubkey_test)
|
assert (pubkey == pubkey_test)
|
||||||
|
|
||||||
def test_ecdsa_otves(self):
|
def test_ecdsa_otves(self):
|
||||||
coin_settings = {'rpcport': 0, 'rpcauth': 'none'}
|
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)
|
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)
|
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)
|
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):
|
def test_sign(self):
|
||||||
coin_settings = {'rpcport': 0, 'rpcauth': 'none'}
|
coin_settings = {'rpcport': 0, 'rpcauth': 'none'}
|
||||||
|
@ -211,7 +211,7 @@ class Test(unittest.TestCase):
|
||||||
vk = i2b(ci.getNewSecretKey())
|
vk = i2b(ci.getNewSecretKey())
|
||||||
pk = ci.getPubkey(vk)
|
pk = ci.getPubkey(vk)
|
||||||
sig = ci.signCompact(vk, 'test signing message')
|
sig = ci.signCompact(vk, 'test signing message')
|
||||||
assert(len(sig) == 64)
|
assert (len(sig) == 64)
|
||||||
ci.verifyCompact(pk, 'test signing message', sig)
|
ci.verifyCompact(pk, 'test signing message', sig)
|
||||||
|
|
||||||
def test_pubkey_to_address(self):
|
def test_pubkey_to_address(self):
|
||||||
|
@ -220,7 +220,7 @@ class Test(unittest.TestCase):
|
||||||
ci = BTCInterface(coin_settings, 'regtest')
|
ci = BTCInterface(coin_settings, 'regtest')
|
||||||
pk = h2b('02c26a344e7d21bcc6f291532679559f2fd234c881271ff98714855edc753763a6')
|
pk = h2b('02c26a344e7d21bcc6f291532679559f2fd234c881271ff98714855edc753763a6')
|
||||||
addr = ci.pubkey_to_address(pk)
|
addr = ci.pubkey_to_address(pk)
|
||||||
assert(addr == 'mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8')
|
assert (addr == 'mj6SdSxmWRmdDqR5R3FfZmRiLmQfQAsLE8')
|
||||||
|
|
||||||
def test_dleag(self):
|
def test_dleag(self):
|
||||||
coin_settings = {'rpcport': 0, 'walletrpcport': 0, 'walletrpcauth': 'none'}
|
coin_settings = {'rpcport': 0, 'walletrpcport': 0, 'walletrpcauth': 'none'}
|
||||||
|
@ -230,7 +230,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
key = i2b(ci.getNewSecretKey())
|
key = i2b(ci.getNewSecretKey())
|
||||||
proof = ci.proveDLEAG(key)
|
proof = ci.proveDLEAG(key)
|
||||||
assert(ci.verifyDLEAG(proof))
|
assert (ci.verifyDLEAG(proof))
|
||||||
|
|
||||||
def test_rate(self):
|
def test_rate(self):
|
||||||
scale_from = 8
|
scale_from = 8
|
||||||
|
@ -239,11 +239,11 @@ class Test(unittest.TestCase):
|
||||||
rate = make_int(0.1, scale_to)
|
rate = make_int(0.1, scale_to)
|
||||||
|
|
||||||
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
||||||
assert('100.00000000' == format_amount(amount_from, scale_from))
|
assert ('100.00000000' == format_amount(amount_from, scale_from))
|
||||||
assert('10.000000000000' == format_amount(amount_to, scale_to))
|
assert ('10.000000000000' == format_amount(amount_to, scale_to))
|
||||||
|
|
||||||
rate_check = make_int((amount_to / amount_from), scale_from)
|
rate_check = make_int((amount_to / amount_from), scale_from)
|
||||||
assert(rate == rate_check)
|
assert (rate == rate_check)
|
||||||
|
|
||||||
scale_from = 12
|
scale_from = 12
|
||||||
scale_to = 8
|
scale_to = 8
|
||||||
|
@ -251,11 +251,11 @@ class Test(unittest.TestCase):
|
||||||
rate = make_int(12, scale_to)
|
rate = make_int(12, scale_to)
|
||||||
|
|
||||||
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
amount_to = int((amount_from * rate) // (10 ** scale_from))
|
||||||
assert('1.000000000000' == format_amount(amount_from, scale_from))
|
assert ('1.000000000000' == format_amount(amount_from, scale_from))
|
||||||
assert('12.00000000' == format_amount(amount_to, scale_to))
|
assert ('12.00000000' == format_amount(amount_to, scale_to))
|
||||||
|
|
||||||
rate_check = make_int((amount_to / amount_from), scale_from)
|
rate_check = make_int((amount_to / amount_from), scale_from)
|
||||||
assert(rate == rate_check)
|
assert (rate == rate_check)
|
||||||
|
|
||||||
scale_from = 8
|
scale_from = 8
|
||||||
scale_to = 8
|
scale_to = 8
|
||||||
|
@ -263,7 +263,7 @@ class Test(unittest.TestCase):
|
||||||
amount_to = make_int(10, scale_to)
|
amount_to = make_int(10, scale_to)
|
||||||
rate = make_int(amount_to / amount_from, scale_to, r=1)
|
rate = make_int(amount_to / amount_from, scale_to, r=1)
|
||||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
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_from = 8
|
||||||
scale_to = 12
|
scale_to = 12
|
||||||
|
@ -271,7 +271,7 @@ class Test(unittest.TestCase):
|
||||||
amount_to = make_int(0.06935, scale_to)
|
amount_to = make_int(0.06935, scale_to)
|
||||||
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
||||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
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_from = 12
|
||||||
scale_to = 8
|
scale_to = 8
|
||||||
|
@ -279,18 +279,18 @@ class Test(unittest.TestCase):
|
||||||
amount_to = make_int(10.0, scale_to)
|
amount_to = make_int(10.0, scale_to)
|
||||||
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
rate = make_int(amount_to / amount_from, scale_from, r=1)
|
||||||
amount_to_recreate = int((amount_from * rate) // (10 ** scale_from))
|
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):
|
def test_rfc2440(self):
|
||||||
password = 'test'
|
password = 'test'
|
||||||
salt = bytes.fromhex('B7A94A7E4988630E')
|
salt = bytes.fromhex('B7A94A7E4988630E')
|
||||||
password_hash = rfc2440_hash_password(password, salt=salt)
|
password_hash = rfc2440_hash_password(password, salt=salt)
|
||||||
|
|
||||||
assert(password_hash == '16:B7A94A7E4988630E6095334BA67F06FBA509B2A7136A04C9C1B430F539')
|
assert (password_hash == '16:B7A94A7E4988630E6095334BA67F06FBA509B2A7136A04C9C1B430F539')
|
||||||
|
|
||||||
def test_ripemd160(self):
|
def test_ripemd160(self):
|
||||||
input_data = b'hash this'
|
input_data = b'hash this'
|
||||||
assert(ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17')
|
assert (ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Test(BaseTest):
|
||||||
'type_to': 'blind',
|
'type_to': 'blind',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/wallets/part/withdraw', post_json))
|
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')
|
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)
|
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
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
js_0 = read_json_api(1800, 'wallets/part')
|
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']
|
node0_blind_before = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
||||||
|
|
||||||
js_1 = read_json_api(1801, 'wallets/part')
|
js_1 = read_json_api(1801, 'wallets/part')
|
||||||
|
@ -102,11 +102,11 @@ class Test(BaseTest):
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
js_1 = read_json_api(1801, 'wallets/part')
|
js_1 = read_json_api(1801, 'wallets/part')
|
||||||
node1_blind_after = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
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')
|
js_0 = read_json_api(1800, 'wallets/part')
|
||||||
node0_blind_after = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
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_0_xmr_after = read_json_api(1800, 'wallets/xmr')
|
||||||
js_1_xmr_after = read_json_api(1801, '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))
|
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_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'])
|
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):
|
def test_02_leader_recover_a_lock_tx(self):
|
||||||
logging.info('---------- Test PARTct to XMR leader recovers coin a lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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')
|
js_w0_after = read_json_api(1800, 'wallets')
|
||||||
node0_blind_after = self.getBalance(js_w0_after)
|
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):
|
def test_03_follower_recover_a_lock_tx(self):
|
||||||
logging.info('---------- Test PARTct to XMR follower recovers coin a lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||||
swap_clients[0].setBidDebugInd(bid_id, DebugTypes.BID_DONT_SPEND_COIN_A_LOCK_REFUND)
|
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_before = self.getBalance(js_w1_before)
|
||||||
node1_blind_after = self.getBalance(js_w1_after)
|
node1_blind_after = self.getBalance(js_w1_after)
|
||||||
amount_from = float(format_amount(amt_swap, 8))
|
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[0].abandonBid(bid_id)
|
||||||
swap_clients[1].abandonBid(bid_id)
|
swap_clients[1].abandonBid(bid_id)
|
||||||
|
@ -204,7 +204,7 @@ class Test(BaseTest):
|
||||||
'remote_key': offerer_key
|
'remote_key': offerer_key
|
||||||
}).encode()
|
}).encode()
|
||||||
redeemed_txid = json.loads(urlopen('http://127.0.0.1:1801/json/bids/{}'.format(bid_id.hex()), data=data).read())['txid']
|
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):
|
def test_04_follower_recover_b_lock_tx(self):
|
||||||
logging.info('---------- Test PARTct to XMR follower recovers coin b lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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_before = self.getBalance(js_w0_before)
|
||||||
node0_blind_after = self.getBalance(js_w0_after)
|
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_before = self.getXmrBalance(js_w1_before)
|
||||||
node1_xmr_after = self.getXmrBalance(js_w1_after)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Test(unittest.TestCase):
|
||||||
if blocks >= num_blocks:
|
if blocks >= num_blocks:
|
||||||
break
|
break
|
||||||
delay_event.wait(2)
|
delay_event.wait(2)
|
||||||
assert(blocks >= num_blocks)
|
assert (blocks >= num_blocks)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'addr_from': '-1',
|
'addr_from': '-1',
|
||||||
|
@ -110,7 +110,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
offer_id = post_json_api(12700, 'offers/new', data)
|
offer_id = post_json_api(12700, 'offers/new', data)
|
||||||
summary = read_json_api(12700)
|
summary = read_json_api(12700)
|
||||||
assert(summary['num_sent_offers'] == 1)
|
assert (summary['num_sent_offers'] == 1)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ class Test(unittest.TestCase):
|
||||||
'accept': True
|
'accept': True
|
||||||
}
|
}
|
||||||
rv = post_json_api(12700, 'bids/{}'.format(bid['bid_id']), data)
|
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)
|
waitForNumSwapping(delay_event, 12701, 1)
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
waitForServer(delay_event, 12701)
|
waitForServer(delay_event, 12701)
|
||||||
rv = read_json_api(12701)
|
rv = read_json_api(12701)
|
||||||
assert(rv['num_swapping'] == 1)
|
assert (rv['num_swapping'] == 1)
|
||||||
|
|
||||||
update_thread = threading.Thread(target=updateThread)
|
update_thread = threading.Thread(target=updateThread)
|
||||||
update_thread.start()
|
update_thread.start()
|
||||||
|
@ -160,7 +160,7 @@ class Test(unittest.TestCase):
|
||||||
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
||||||
if rv['bid_state'] == 'Completed':
|
if rv['bid_state'] == 'Completed':
|
||||||
break
|
break
|
||||||
assert(rv['bid_state'] == 'Completed')
|
assert (rv['bid_state'] == 'Completed')
|
||||||
|
|
||||||
delay_event.set()
|
delay_event.set()
|
||||||
update_thread.join()
|
update_thread.join()
|
||||||
|
|
|
@ -95,24 +95,24 @@ class Test(BaseTest):
|
||||||
for c in Coins:
|
for c in Coins:
|
||||||
coin = next((x for x in js_coins if x['id'] == int(c)), None)
|
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):
|
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:
|
else:
|
||||||
assert(coin['active'] is False)
|
assert (coin['active'] is False)
|
||||||
if c in (Coins.PART_ANON, Coins.PART_BLIND):
|
if c in (Coins.PART_ANON, Coins.PART_BLIND):
|
||||||
assert(coin['ticker'] == 'PART')
|
assert (coin['ticker'] == 'PART')
|
||||||
|
|
||||||
def test_002_lookup_rates(self):
|
def test_002_lookup_rates(self):
|
||||||
rv = self.swap_clients[0].lookupRates(Coins.BTC, Coins.PART)
|
rv = self.swap_clients[0].lookupRates(Coins.BTC, Coins.PART)
|
||||||
assert('coingecko' in rv)
|
assert ('coingecko' in rv)
|
||||||
assert('bittrex' in rv)
|
assert ('bittrex' in rv)
|
||||||
|
|
||||||
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.BTC)
|
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.BTC)
|
||||||
assert('coingecko' in rv)
|
assert ('coingecko' in rv)
|
||||||
assert('bittrex' in rv)
|
assert ('bittrex' in rv)
|
||||||
|
|
||||||
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.PART)
|
rv = self.swap_clients[0].lookupRates(Coins.LTC, Coins.PART)
|
||||||
assert('coingecko' in rv)
|
assert ('coingecko' in rv)
|
||||||
assert('bittrex' in rv)
|
assert ('bittrex' in rv)
|
||||||
|
|
||||||
def test_01_verifyrawtransaction(self):
|
def test_01_verifyrawtransaction(self):
|
||||||
txn = '0200000001eb6e5c4ebba4efa32f40c7314cad456a64008e91ee30b2dd0235ab9bb67fbdbb01000000ee47304402200956933242dde94f6cf8f195a470f8d02aef21ec5c9b66c5d3871594bdb74c9d02201d7e1b440de8f4da672d689f9e37e98815fb63dbc1706353290887eb6e8f7235012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d205a803b28fe2f86c17db91fa99d7ed2598f79b5677ffe869de2e478c0d1c02cc7514c606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888acffffffff01e0167118020000001976a9140044e188928710cecba8311f1cf412135b98145c88ac00000000'
|
txn = '0200000001eb6e5c4ebba4efa32f40c7314cad456a64008e91ee30b2dd0235ab9bb67fbdbb01000000ee47304402200956933242dde94f6cf8f195a470f8d02aef21ec5c9b66c5d3871594bdb74c9d02201d7e1b440de8f4da672d689f9e37e98815fb63dbc1706353290887eb6e8f7235012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d205a803b28fe2f86c17db91fa99d7ed2598f79b5677ffe869de2e478c0d1c02cc7514c606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888acffffffff01e0167118020000001976a9140044e188928710cecba8311f1cf412135b98145c88ac00000000'
|
||||||
|
@ -123,13 +123,13 @@ class Test(BaseTest):
|
||||||
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888ac',
|
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914225fbfa4cb725b75e511810ac4d6f74069bdded26703520140b27576a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666888ac',
|
||||||
'amount': 1.0}
|
'amount': 1.0}
|
||||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||||
assert(ro['inputs_valid'] is False)
|
assert (ro['inputs_valid'] is False)
|
||||||
assert(ro['validscripts'] == 1)
|
assert (ro['validscripts'] == 1)
|
||||||
|
|
||||||
prevout['amount'] = 100.0
|
prevout['amount'] = 100.0
|
||||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||||
assert(ro['inputs_valid'] is True)
|
assert (ro['inputs_valid'] is True)
|
||||||
assert(ro['validscripts'] == 1)
|
assert (ro['validscripts'] == 1)
|
||||||
|
|
||||||
txn = 'a000000000000128e8ba6a28673f2ebb5fd983b27a791fd1888447a47638b3cd8bfdd3f54a6f1e0100000000a90040000101e0c69a3b000000001976a9146c0f1ea47ca2bf84ed87bf3aa284e18748051f5788ac04473044022026b01f3a90e46883949404141467b741cd871722a4aaae8ddc8c4d6ab6fb1c77022047a2f3be2dcbe4c51837d2d5e0329aaa8a13a8186b03186b127cc51185e4f3ab012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d0100606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac'
|
txn = 'a000000000000128e8ba6a28673f2ebb5fd983b27a791fd1888447a47638b3cd8bfdd3f54a6f1e0100000000a90040000101e0c69a3b000000001976a9146c0f1ea47ca2bf84ed87bf3aa284e18748051f5788ac04473044022026b01f3a90e46883949404141467b741cd871722a4aaae8ddc8c4d6ab6fb1c77022047a2f3be2dcbe4c51837d2d5e0329aaa8a13a8186b03186b127cc51185e4f3ab012103dc1b24feb32841bc2f4375da91fa97834e5983668c2a39a6b7eadb60e7033f9d0100606382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac'
|
||||||
prevout = {
|
prevout = {
|
||||||
|
@ -139,13 +139,13 @@ class Test(BaseTest):
|
||||||
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac',
|
'redeemScript': '6382012088a8201fe90717abb84b481c2a59112414ae56ec8acc72273642ca26cc7a5812fdc8f68876a914207eb66b2fd6ed9924d6217efc7fa7b38dfabe666703a90040b27576a914225fbfa4cb725b75e511810ac4d6f74069bdded26888ac',
|
||||||
'amount': 1.0}
|
'amount': 1.0}
|
||||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||||
assert(ro['inputs_valid'] is False)
|
assert (ro['inputs_valid'] is False)
|
||||||
assert(ro['validscripts'] == 0) # Amount covered by signature
|
assert (ro['validscripts'] == 0) # Amount covered by signature
|
||||||
|
|
||||||
prevout['amount'] = 90.0
|
prevout['amount'] = 90.0
|
||||||
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
ro = callnoderpc(0, 'verifyrawtransaction', [txn, [prevout, ]])
|
||||||
assert(ro['inputs_valid'] is True)
|
assert (ro['inputs_valid'] is True)
|
||||||
assert(ro['validscripts'] == 1)
|
assert (ro['validscripts'] == 1)
|
||||||
|
|
||||||
def test_02_part_ltc(self):
|
def test_02_part_ltc(self):
|
||||||
logging.info('---------- Test PART to LTC')
|
logging.info('---------- Test PART to LTC')
|
||||||
|
@ -155,7 +155,7 @@ class Test(BaseTest):
|
||||||
|
|
||||||
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||||
offers = swap_clients[1].listOffers()
|
offers = swap_clients[1].listOffers()
|
||||||
assert(len(offers) == 1)
|
assert (len(offers) == 1)
|
||||||
for offer in offers:
|
for offer in offers:
|
||||||
if offer.offer_id == offer_id:
|
if offer.offer_id == offer_id:
|
||||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
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_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
bid_id_hex = bid_id.hex()
|
bid_id_hex = bid_id.hex()
|
||||||
path = f'bids/{bid_id_hex}/states'
|
path = f'bids/{bid_id_hex}/states'
|
||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, path)
|
||||||
|
|
||||||
assert(compare_bid_states(offerer_states, self.states_offerer[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)
|
assert (compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||||
|
|
||||||
def test_03_ltc_part(self):
|
def test_03_ltc_part(self):
|
||||||
logging.info('---------- Test LTC to PART')
|
logging.info('---------- Test LTC to PART')
|
||||||
|
@ -202,8 +202,8 @@ class Test(BaseTest):
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_04_ltc_btc(self):
|
def test_04_ltc_btc(self):
|
||||||
logging.info('---------- Test LTC to BTC')
|
logging.info('---------- Test LTC to BTC')
|
||||||
|
@ -225,8 +225,8 @@ class Test(BaseTest):
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
def test_05_refund(self):
|
def test_05_refund(self):
|
||||||
# Seller submits initiate txn, buyer doesn't respond
|
# 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_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||||
js_1_bid = read_json_api(1801, '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_0_bid['itx_state'] == 'Refunded')
|
||||||
assert(js_1_bid['ptx_state'] == 'Unknown')
|
assert (js_1_bid['ptx_state'] == 'Unknown')
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
bid_id_hex = bid_id.hex()
|
bid_id_hex = bid_id.hex()
|
||||||
path = f'bids/{bid_id_hex}/states'
|
path = f'bids/{bid_id_hex}/states'
|
||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, 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)
|
||||||
assert(bidder_states[-1][1] == 'Bid Abandoned')
|
assert (bidder_states[-1][1] == 'Bid Abandoned')
|
||||||
|
|
||||||
def test_06_self_bid(self):
|
def test_06_self_bid(self):
|
||||||
logging.info('---------- Test same client, BTC to LTC')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['num_watched_outputs'] == 0)
|
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_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):
|
def test_07_error(self):
|
||||||
logging.info('---------- Test error, BTC to LTC, set fee above bid value')
|
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)
|
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||||
offers = swap_clients[1].listOffers()
|
offers = swap_clients[1].listOffers()
|
||||||
assert(len(offers) >= 1)
|
assert (len(offers) >= 1)
|
||||||
for offer in offers:
|
for offer in offers:
|
||||||
if offer.offer_id == offer_id:
|
if offer.offer_id == offer_id:
|
||||||
bid_id = swap_clients[1].postBid(offer_id, offer.amount_from)
|
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_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||||
js_1_bid = read_json_api(1801, '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_0_bid['itx_state'] == 'Refunded')
|
||||||
assert(js_1_bid['ptx_state'] == 'Refunded')
|
assert (js_1_bid['ptx_state'] == 'Refunded')
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
|
|
||||||
bid_id_hex = bid_id.hex()
|
bid_id_hex = bid_id.hex()
|
||||||
path = f'bids/{bid_id_hex}/states'
|
path = f'bids/{bid_id_hex}/states'
|
||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, 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)
|
||||||
assert(compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
assert (compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
def test_11_refund(self):
|
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_0_bid = read_json_api(1800, 'bids/{}'.format(bid_id.hex()))
|
||||||
js_1_bid = read_json_api(1801, '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_0_bid['itx_state'] == 'Refunded')
|
||||||
assert(js_1_bid['ptx_state'] == 'Unknown')
|
assert (js_1_bid['ptx_state'] == 'Unknown')
|
||||||
|
|
||||||
js_0 = read_json_api(1800)
|
js_0 = read_json_api(1800)
|
||||||
js_1 = read_json_api(1801)
|
js_1 = read_json_api(1801)
|
||||||
assert(js_0['num_swapping'] == 0 and js_0['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)
|
assert (js_1['num_swapping'] == 0 and js_1['num_watched_outputs'] == 0)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def test_12_withdrawal(self):
|
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)
|
ltc_addr = callnoderpc(0, 'getnewaddress', ['Withdrawal test', 'legacy'], base_rpc_port=LTC_BASE_RPC_PORT)
|
||||||
wallets0 = read_json_api(TEST_HTTP_PORT + 0, 'wallets')
|
wallets0 = read_json_api(TEST_HTTP_PORT + 0, 'wallets')
|
||||||
assert(float(wallets0['LTC']['balance']) > 100)
|
assert (float(wallets0['LTC']['balance']) > 100)
|
||||||
|
|
||||||
post_json = {
|
post_json = {
|
||||||
'value': 100,
|
'value': 100,
|
||||||
|
@ -420,7 +420,7 @@ class Test(BaseTest):
|
||||||
'subfee': False,
|
'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))
|
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):
|
def test_13_itx_refund(self):
|
||||||
logging.info('---------- Test ITX refunded')
|
logging.info('---------- Test ITX refunded')
|
||||||
|
@ -469,11 +469,11 @@ class Test(BaseTest):
|
||||||
high_fee_value_btc = int(0.001 * COIN)
|
high_fee_value_btc = int(0.001 * COIN)
|
||||||
high_fee_value_ltc = int(0.01 * COIN) # TODO Set fees directly, see listtransactions
|
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_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_ltc_after > node0_ltc_before - high_fee_value_ltc)
|
||||||
|
|
||||||
assert(node1_btc_after < node1_btc_before - btc_swap_value)
|
assert (node1_btc_after < node1_btc_before - btc_swap_value)
|
||||||
assert(node1_ltc_before == node1_ltc_after)
|
assert (node1_ltc_before == node1_ltc_after)
|
||||||
|
|
||||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=60)
|
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)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, path)
|
||||||
|
|
||||||
assert(compare_bid_states(offerer_states, self.states_offerer[2]) 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)
|
assert (compare_bid_states(bidder_states, self.states_bidder[2], exact_match=False) is True)
|
||||||
|
|
||||||
def pass_99_delay(self):
|
def pass_99_delay(self):
|
||||||
logging.info('Delay')
|
logging.info('Delay')
|
||||||
|
|
|
@ -555,13 +555,13 @@ class Test(BaseTest):
|
||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
js_1 = read_json_api(1801, 'wallets')
|
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]['balance'], scale=12) > 0)
|
||||||
assert(make_int(js_1[Coins.XMR.name]['unconfirmed'], 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)
|
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)
|
wait_for_offer(test_delay_event, swap_clients[1], offer_id)
|
||||||
offers = swap_clients[1].listOffers(filters={'offer_id': offer_id})
|
offers = swap_clients[1].listOffers(filters={'offer_id': offer_id})
|
||||||
assert(len(offers) == 1)
|
assert (len(offers) == 1)
|
||||||
offer = offers[0]
|
offer = offers[0]
|
||||||
|
|
||||||
bid_id = swap_clients[1].postXmrBid(offer_id, offer.amount_from)
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||||
assert(xmr_swap)
|
assert (xmr_swap)
|
||||||
|
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
swap_clients[0].acceptXmrBid(bid_id)
|
||||||
|
|
||||||
|
@ -578,15 +578,15 @@ class Test(BaseTest):
|
||||||
|
|
||||||
js_0_end = read_json_api(1800, 'wallets')
|
js_0_end = read_json_api(1800, 'wallets')
|
||||||
end_xmr = float(js_0_end['XMR']['balance']) + float(js_0_end['XMR']['unconfirmed'])
|
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()
|
bid_id_hex = bid_id.hex()
|
||||||
path = f'bids/{bid_id_hex}/states'
|
path = f'bids/{bid_id_hex}/states'
|
||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, path)
|
||||||
|
|
||||||
assert(compare_bid_states(offerer_states, self.states_offerer[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)
|
assert (compare_bid_states(bidder_states, self.states_bidder[0]) is True)
|
||||||
|
|
||||||
def test_011_smsgaddresses(self):
|
def test_011_smsgaddresses(self):
|
||||||
logging.info('---------- Test address management and private offers')
|
logging.info('---------- Test address management and private offers')
|
||||||
|
@ -601,21 +601,21 @@ class Test(BaseTest):
|
||||||
new_address_pk = json_rv['pubkey']
|
new_address_pk = json_rv['pubkey']
|
||||||
|
|
||||||
js_2 = read_json_api(1801, 'smsgaddresses')
|
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
|
found = False
|
||||||
for addr in js_2:
|
for addr in js_2:
|
||||||
if addr['addr'] == new_address:
|
if addr['addr'] == new_address:
|
||||||
assert(addr['note'] == 'testing')
|
assert (addr['note'] == 'testing')
|
||||||
found = True
|
found = True
|
||||||
assert(found is True)
|
assert (found is True)
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
lks = callnoderpc(1, 'smsglocalkeys')
|
lks = callnoderpc(1, 'smsglocalkeys')
|
||||||
for key in lks['wallet_keys']:
|
for key in lks['wallet_keys']:
|
||||||
if key['address'] == new_address:
|
if key['address'] == new_address:
|
||||||
assert(key['receive'] == '1')
|
assert (key['receive'] == '1')
|
||||||
found = True
|
found = True
|
||||||
assert(found is True)
|
assert (found is True)
|
||||||
|
|
||||||
# Disable
|
# Disable
|
||||||
post_json = {
|
post_json = {
|
||||||
|
@ -624,23 +624,23 @@ class Test(BaseTest):
|
||||||
'active_ind': '0',
|
'active_ind': '0',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/smsgaddresses/edit', post_json))
|
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')
|
js_3 = read_json_api(1801, 'smsgaddresses')
|
||||||
found = False
|
found = False
|
||||||
for addr in js_3:
|
for addr in js_3:
|
||||||
if addr['addr'] == new_address:
|
if addr['addr'] == new_address:
|
||||||
assert(addr['note'] == 'testing2')
|
assert (addr['note'] == 'testing2')
|
||||||
assert(addr['active_ind'] == 0)
|
assert (addr['active_ind'] == 0)
|
||||||
found = True
|
found = True
|
||||||
assert(found is True)
|
assert (found is True)
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
lks = callnoderpc(1, 'smsglocalkeys')
|
lks = callnoderpc(1, 'smsglocalkeys')
|
||||||
for key in lks['wallet_keys']:
|
for key in lks['wallet_keys']:
|
||||||
if key['address'] == new_address:
|
if key['address'] == new_address:
|
||||||
found = True
|
found = True
|
||||||
assert(found is False)
|
assert (found is False)
|
||||||
|
|
||||||
# Re-enable
|
# Re-enable
|
||||||
post_json = {
|
post_json = {
|
||||||
|
@ -648,22 +648,22 @@ class Test(BaseTest):
|
||||||
'active_ind': '1',
|
'active_ind': '1',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/smsgaddresses/edit', post_json))
|
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
|
found = False
|
||||||
lks = callnoderpc(1, 'smsglocalkeys')
|
lks = callnoderpc(1, 'smsglocalkeys')
|
||||||
for key in lks['wallet_keys']:
|
for key in lks['wallet_keys']:
|
||||||
if key['address'] == new_address:
|
if key['address'] == new_address:
|
||||||
assert(key['receive'] == '1')
|
assert (key['receive'] == '1')
|
||||||
found = True
|
found = True
|
||||||
assert(found is True)
|
assert (found is True)
|
||||||
|
|
||||||
post_json = {
|
post_json = {
|
||||||
'addresspubkey': new_address_pk,
|
'addresspubkey': new_address_pk,
|
||||||
'addressnote': 'testing_add_addr',
|
'addressnote': 'testing_add_addr',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/smsgaddresses/add', post_json))
|
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 = {
|
post_json = {
|
||||||
'addr_to': new_address,
|
'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))
|
wait_for_offer(test_delay_event, swap_clients[1], bytes.fromhex(offer_id_hex))
|
||||||
|
|
||||||
rv = read_json_api(1801, f'offers/{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}')
|
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):
|
def test_02_leader_recover_a_lock_tx(self):
|
||||||
logging.info('---------- Test PART to XMR leader recovers coin a lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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'
|
path = f'bids/{bid_id_hex}/states'
|
||||||
offerer_states = read_json_api(1800, path)
|
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):
|
def test_03_follower_recover_a_lock_tx(self):
|
||||||
logging.info('---------- Test PART to XMR follower recovers coin a lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
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 = read_json_api(1801, path)
|
||||||
|
|
||||||
bidder_states = [s for s in bidder_states if s[1] != 'Bid Stalled (debug)']
|
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):
|
def test_04_follower_recover_b_lock_tx(self):
|
||||||
logging.info('---------- Test PART to XMR follower recovers coin b lock tx')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[1].setBidDebugInd(bid_id, DebugTypes.CREATE_INVALID_COIN_B_LOCK)
|
||||||
|
|
||||||
|
@ -779,8 +779,8 @@ class Test(BaseTest):
|
||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, 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)
|
||||||
assert(compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
assert (compare_bid_states(bidder_states, self.states_bidder[1]) is True)
|
||||||
|
|
||||||
def test_05_btc_xmr(self):
|
def test_05_btc_xmr(self):
|
||||||
logging.info('---------- Test BTC to XMR')
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||||
assert(xmr_swap)
|
assert (xmr_swap)
|
||||||
|
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
swap_clients[0].acceptXmrBid(bid_id)
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ class Test(BaseTest):
|
||||||
|
|
||||||
js_w0_after = read_json_api(1800, 'wallets')
|
js_w0_after = read_json_api(1800, 'wallets')
|
||||||
js_w1_after = read_json_api(1801, '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):
|
def test_07_revoke_offer(self):
|
||||||
logging.info('---------- Test offer revocaction')
|
logging.info('---------- Test offer revocaction')
|
||||||
|
@ -880,7 +880,7 @@ class Test(BaseTest):
|
||||||
address_to = js_0[Coins.XMR.name]['deposit_address']
|
address_to = js_0[Coins.XMR.name]['deposit_address']
|
||||||
|
|
||||||
js_1 = read_json_api(1801, 'wallets')
|
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)
|
swap_clients[1].withdrawCoin(Coins.XMR, 1.1, address_to, False)
|
||||||
|
|
||||||
|
@ -918,14 +918,14 @@ class Test(BaseTest):
|
||||||
try:
|
try:
|
||||||
bid_id = swap_clients[1].postBid(offer_id, below_min_bid)
|
bid_id = swap_clients[1].postBid(offer_id, below_min_bid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
assert('Bid amount below minimum' in str(e))
|
assert ('Bid amount below minimum' in str(e))
|
||||||
extra_bid_options = {
|
extra_bid_options = {
|
||||||
'debug_skip_validation': True,
|
'debug_skip_validation': True,
|
||||||
}
|
}
|
||||||
bid_id = swap_clients[1].postBid(offer_id, below_min_bid, extra_options=extra_bid_options)
|
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)
|
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 = []
|
bid_ids = []
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
|
@ -935,7 +935,7 @@ class Test(BaseTest):
|
||||||
test_delay_event.wait(1.0)
|
test_delay_event.wait(1.0)
|
||||||
bid_id = swap_clients[1].postBid(offer_id, min_bid)
|
bid_id = swap_clients[1].postBid(offer_id, min_bid)
|
||||||
events = wait_for_event(test_delay_event, swap_clients[0], Concepts.AUTOMATION, bid_id)
|
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:
|
for bid_id in bid_ids:
|
||||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.SWAP_COMPLETED, wait_for=180)
|
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
|
amt_bid += 1
|
||||||
bid_id = swap_clients[1].postBid(offer_id, amt_bid)
|
bid_id = swap_clients[1].postBid(offer_id, amt_bid)
|
||||||
events = wait_for_event(test_delay_event, swap_clients[0], Concepts.AUTOMATION, bid_id)
|
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
|
# Should pass
|
||||||
amt_bid -= 1
|
amt_bid -= 1
|
||||||
|
@ -968,7 +968,7 @@ class Test(BaseTest):
|
||||||
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
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[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)
|
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)
|
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||||
assert(xmr_swap)
|
assert (xmr_swap)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
swap_clients[0].ci(Coins.BTC).publishTx(xmr_swap.a_lock_refund_tx)
|
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:
|
except Exception as e:
|
||||||
assert('non-BIP68-final' in str(e))
|
assert ('non-BIP68-final' in str(e))
|
||||||
|
|
||||||
def test_11_particl_anon(self):
|
def test_11_particl_anon(self):
|
||||||
logging.info('---------- Test Particl anon transactions')
|
logging.info('---------- Test Particl anon transactions')
|
||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
js_0 = read_json_api(1800, 'wallets/part')
|
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']
|
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)
|
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')
|
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']
|
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)
|
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',
|
'type_to': 'anon',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/wallets/part/withdraw', post_json))
|
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')
|
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)
|
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',
|
'type_to': 'blind',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1801/json/wallets/part/withdraw', post_json))
|
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')
|
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)
|
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)
|
wait_for_bid(test_delay_event, swap_clients[0], bid_id, BidStates.BID_RECEIVED)
|
||||||
|
|
||||||
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
bid, xmr_swap = swap_clients[0].getXmrBid(bid_id)
|
||||||
assert(xmr_swap)
|
assert (xmr_swap)
|
||||||
amount_to = float(format_amount(bid.amount_to, 8))
|
amount_to = float(format_amount(bid.amount_to, 8))
|
||||||
|
|
||||||
swap_clients[0].acceptXmrBid(bid_id)
|
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)
|
wait_for_bid(test_delay_event, swap_clients[1], bid_id, BidStates.SWAP_COMPLETED, sent=True)
|
||||||
|
|
||||||
js_1 = read_json_api(1801, 'wallets/part')
|
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')
|
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):
|
def test_12_particl_blind(self):
|
||||||
logging.info('---------- Test Particl blind transactions')
|
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)
|
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')
|
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']
|
node1_blind_before = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
||||||
|
|
||||||
post_json = {
|
post_json = {
|
||||||
|
@ -1074,7 +1074,7 @@ class Test(BaseTest):
|
||||||
'type_to': 'blind',
|
'type_to': 'blind',
|
||||||
}
|
}
|
||||||
json_rv = json.loads(post_json_req('http://127.0.0.1:1800/json/wallets/part/withdraw', post_json))
|
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')
|
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)
|
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))
|
amount_from = float(format_amount(amt_swap, 8))
|
||||||
js_1 = read_json_api(1801, 'wallets/part')
|
js_1 = read_json_api(1801, 'wallets/part')
|
||||||
node1_blind_after = js_1['blind_balance'] + js_1['blind_unconfirmed']
|
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')
|
js_0 = read_json_api(1800, 'wallets/part')
|
||||||
node0_blind_after = js_0['blind_balance'] + js_0['blind_unconfirmed']
|
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):
|
def test_98_withdraw_all(self):
|
||||||
logging.info('---------- Test XMR withdrawal all')
|
logging.info('---------- Test XMR withdrawal all')
|
||||||
|
@ -1117,7 +1117,7 @@ class Test(BaseTest):
|
||||||
|
|
||||||
wallets1 = read_json_api(TEST_HTTP_PORT + 1, 'wallets')
|
wallets1 = read_json_api(TEST_HTTP_PORT + 1, 'wallets')
|
||||||
xmr_total = float(wallets1[Coins.XMR.name]['balance'])
|
xmr_total = float(wallets1[Coins.XMR.name]['balance'])
|
||||||
assert(xmr_total > 10)
|
assert (xmr_total > 10)
|
||||||
|
|
||||||
post_json = {
|
post_json = {
|
||||||
'value': 10,
|
'value': 10,
|
||||||
|
@ -1125,11 +1125,11 @@ class Test(BaseTest):
|
||||||
'subfee': True,
|
'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))
|
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
|
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))
|
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:
|
finally:
|
||||||
logging.info('Restoring XMR mining')
|
logging.info('Restoring XMR mining')
|
||||||
pause_event.set()
|
pause_event.set()
|
||||||
|
|
|
@ -50,7 +50,7 @@ class Test(XmrTestBase):
|
||||||
waitForServer(self.delay_event, 12700)
|
waitForServer(self.delay_event, 12700)
|
||||||
waitForServer(self.delay_event, 12701)
|
waitForServer(self.delay_event, 12701)
|
||||||
wallets1 = read_json_api(12701, 'wallets')
|
wallets1 = read_json_api(12701, 'wallets')
|
||||||
assert(float(wallets1['XMR']['balance']) > 0.0)
|
assert (float(wallets1['XMR']['balance']) > 0.0)
|
||||||
|
|
||||||
offer_data = {
|
offer_data = {
|
||||||
'addr_from': -1,
|
'addr_from': -1,
|
||||||
|
@ -68,7 +68,7 @@ class Test(XmrTestBase):
|
||||||
offer1_id = rv['offer_id']
|
offer1_id = rv['offer_id']
|
||||||
|
|
||||||
summary = read_json_api(12700)
|
summary = read_json_api(12700)
|
||||||
assert(summary['num_sent_offers'] > 1)
|
assert (summary['num_sent_offers'] > 1)
|
||||||
|
|
||||||
logger.info('Waiting for offer')
|
logger.info('Waiting for offer')
|
||||||
waitForNumOffers(self.delay_event, 12701, 2)
|
waitForNumOffers(self.delay_event, 12701, 2)
|
||||||
|
@ -79,17 +79,17 @@ class Test(XmrTestBase):
|
||||||
c0.join()
|
c0.join()
|
||||||
|
|
||||||
offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers/{}'.format(offer0_id)).read())
|
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]
|
offer0 = offers[0]
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
'coin_from': 'PART'
|
'coin_from': 'PART'
|
||||||
}
|
}
|
||||||
test_post_offers = json.loads(urlopen('http://127.0.0.1:12701/json/offers', data=parse.urlencode(post_data).encode()).read())
|
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'
|
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())
|
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 = {
|
bid_data = {
|
||||||
'offer_id': offer0_id,
|
'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']
|
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())
|
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]
|
offer1 = offers[0]
|
||||||
|
|
||||||
bid_data = {
|
bid_data = {
|
||||||
|
@ -126,12 +126,12 @@ class Test(XmrTestBase):
|
||||||
}).encode()
|
}).encode()
|
||||||
try:
|
try:
|
||||||
rv = json.loads(urlopen('http://127.0.0.1:12700/json/bids/{}'.format(bid0_id), data=data).read())
|
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:
|
except Exception as e:
|
||||||
print('Accept bid failed', str(e), rv)
|
print('Accept bid failed', str(e), rv)
|
||||||
try:
|
try:
|
||||||
rv = json.loads(urlopen('http://127.0.0.1:12700/json/bids/{}'.format(bid1_id), data=data).read())
|
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:
|
except Exception as e:
|
||||||
print('Accept bid failed', str(e), rv)
|
print('Accept bid failed', str(e), rv)
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ class Test(XmrTestBase):
|
||||||
rv1 = read_json_api(12700, 'bids/{}'.format(bid1_id))
|
rv1 = read_json_api(12700, 'bids/{}'.format(bid1_id))
|
||||||
if rv0['bid_state'] == 'Completed' and rv1['bid_state'] == 'Completed':
|
if rv0['bid_state'] == 'Completed' and rv1['bid_state'] == 'Completed':
|
||||||
break
|
break
|
||||||
assert(rv0['bid_state'] == 'Completed')
|
assert rv0['bid_state'] == 'Completed'
|
||||||
assert(rv1['bid_state'] == 'Completed')
|
assert rv1['bid_state'] == 'Completed'
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Test(XmrTestBase):
|
||||||
waitForServer(self.delay_event, 12700)
|
waitForServer(self.delay_event, 12700)
|
||||||
waitForServer(self.delay_event, 12701)
|
waitForServer(self.delay_event, 12701)
|
||||||
wallets1 = read_json_api(12701, 'wallets')
|
wallets1 = read_json_api(12701, 'wallets')
|
||||||
assert(float(wallets1['XMR']['balance']) > 0.0)
|
assert (float(wallets1['XMR']['balance']) > 0.0)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'addr_from': '-1',
|
'addr_from': '-1',
|
||||||
|
@ -58,7 +58,7 @@ class Test(XmrTestBase):
|
||||||
|
|
||||||
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
offer_id = post_json_api(12700, 'offers/new', data)['offer_id']
|
||||||
summary = read_json_api(12700)
|
summary = read_json_api(12700)
|
||||||
assert(summary['num_sent_offers'] == 1)
|
assert (summary['num_sent_offers'] == 1)
|
||||||
|
|
||||||
logger.info('Waiting for offer')
|
logger.info('Waiting for offer')
|
||||||
waitForNumOffers(self.delay_event, 12701, 1)
|
waitForNumOffers(self.delay_event, 12701, 1)
|
||||||
|
@ -72,20 +72,20 @@ class Test(XmrTestBase):
|
||||||
|
|
||||||
data['valid_for_seconds'] = 24 * 60 * 60 + 1
|
data['valid_for_seconds'] = 24 * 60 * 60 + 1
|
||||||
bid = post_json_api(12701, 'bids/new', data)
|
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']
|
del data['valid_for_seconds']
|
||||||
data['validmins'] = 24 * 60 + 1
|
data['validmins'] = 24 * 60 + 1
|
||||||
bid = post_json_api(12701, 'bids/new', data)
|
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']
|
del data['validmins']
|
||||||
data['valid_for_seconds'] = 10
|
data['valid_for_seconds'] = 10
|
||||||
bid = post_json_api(12701, 'bids/new', data)
|
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']
|
del data['valid_for_seconds']
|
||||||
data['validmins'] = 1
|
data['validmins'] = 1
|
||||||
bid = post_json_api(12701, 'bids/new', data)
|
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
|
data['validmins'] = 60
|
||||||
bid_id = post_json_api(12701, 'bids/new', data)
|
bid_id = post_json_api(12701, 'bids/new', data)
|
||||||
|
@ -98,13 +98,13 @@ class Test(XmrTestBase):
|
||||||
if bid['bid_state'] == 'Received':
|
if bid['bid_state'] == 'Received':
|
||||||
break
|
break
|
||||||
self.delay_event.wait(1)
|
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 = {
|
data = {
|
||||||
'accept': True
|
'accept': True
|
||||||
}
|
}
|
||||||
rv = post_json_api(12700, 'bids/{}'.format(bid['bid_id']), data)
|
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)
|
waitForNumSwapping(self.delay_event, 12701, 1)
|
||||||
|
|
||||||
|
@ -117,10 +117,10 @@ class Test(XmrTestBase):
|
||||||
|
|
||||||
waitForServer(self.delay_event, 12701)
|
waitForServer(self.delay_event, 12701)
|
||||||
rv = read_json_api(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))
|
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')
|
logger.info('Completing swap')
|
||||||
for i in range(240):
|
for i in range(240):
|
||||||
|
@ -131,11 +131,11 @@ class Test(XmrTestBase):
|
||||||
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
rv = read_json_api(12700, 'bids/{}'.format(bid['bid_id']))
|
||||||
if rv['bid_state'] == 'Completed':
|
if rv['bid_state'] == 'Completed':
|
||||||
break
|
break
|
||||||
assert(rv['bid_state'] == 'Completed')
|
assert (rv['bid_state'] == 'Completed')
|
||||||
|
|
||||||
# Ensure offer was revoked
|
# Ensure offer was revoked
|
||||||
summary = read_json_api(12700)
|
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
|
# Wait for bid to be removed from in-progress
|
||||||
waitForNumBids(self.delay_event, 12700, 0)
|
waitForNumBids(self.delay_event, 12700, 0)
|
||||||
|
|
Loading…
Reference in a new issue