Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.parametrize('amount, expected, description', [
[0, True, 'valid amount: 0'],
[1, True, 'valid amount: 1'],
[-1, False, 'negative amount'],
[1.5, False, 'floating point number'],
['a', False, 'string'],
['', False, 'empty string'],
[None, False, 'None value'],
])
def test_valid_amount(self, amount, expected, description):
print(description)
assert validators.valid_amount(amount) == expected
def configure(self, **config):
super(BalanceTrigger, self).configure(**config)
if 'address' in config and valid_address(config['address']):
self.address = config['address']
if 'amount' in config and valid_amount(config['amount']):
self.amount = config['amount']
def configure(self, **config):
super(SentTrigger, self).configure(**config)
if 'address' in config and valid_address(config['address']):
self.address = config['address']
if 'amount' in config and valid_amount(config['amount']):
self.amount = config['amount']
if 'bip44_account' in config:
self.bip44_account = config['bip44_account']
if 'bip44_index' in config:
self.bip44_index = config['bip44_index']
if 'receiving_address' in config and valid_address(config['receiving_address']):
self.receiving_address = config['receiving_address']
if 'receiving_xpub' in config and valid_xpub(config['receiving_xpub']):
self.receiving_xpub = config['receiving_xpub']
if 'amount' in config and valid_amount(config['amount']):
self.amount = config['amount']
if 'minimum_amount' in config and valid_amount(config['minimum_amount']):
self.minimum_amount = config['minimum_amount']
if 'op_return_data' in config and valid_op_return(config['op_return_data']):
self.op_return_data = config['op_return_data']
if 'change_address' in config and valid_address(config['change_address']):
self.receiving_address = config['change_address']
if 'transaction_type' in config and valid_transaction_type(config['transaction_type']):
self.transaction_type = config['transaction_type']
if 'minimum_output_value' in config and valid_amount(config['minimum_output_value']):
self.minimum_output_value = config['minimum_output_value']
if 'registration_address' in config and valid_address(config['registration_address']):
self.registration_address = config['registration_address']
def get_distribution(self, transaction_type, sending_amount):
if not valid_amount(sending_amount) or sending_amount == 0:
LOG.error('Unable to get distribution: invalid sending_amount: %s' % sending_amount)
raise Exception('Unable to get distribution: invalid sending_amount: %s' % sending_amount)
if transaction_type == 'Send2Single':
if not valid_address(self.receiving_address):
LOG.error('Unable to get distribution: invalid receiving_address: %s' % self.receiving_address)
raise Exception('Unable to get distribution: invalid receiving_address: %s' % self.receiving_address)
distribution = {self.receiving_address: sending_amount}
elif transaction_type == 'Send2Many':
if not valid_distribution(self.distribution):
LOG.error('Unable to get distribution: invalid distribution: %s' % self.distribution)
raise Exception('Unable to get distribution: invalid distribution: %s' % self.distribution)
distribution = self.distribution
elif transaction_type == 'Send2SIL':
def configure(self, **config):
super(ReceivedTrigger, self).configure(**config)
if 'address' in config and valid_address(config['address']):
self.address = config['address']
if 'amount' in config and valid_amount(config['amount']):
self.amount = config['amount']
def configure(self, **config):
super(TxConfirmationTrigger, self).configure(**config)
if 'txid' in config and valid_txid(config['txid']):
self.txid = config['txid']
if 'confirmations' in config and valid_amount(config['confirmations']):
self.confirmations = config['confirmations']