'test_trigger_conditions_TriggerStatusTrigger_A', 'test_trigger_conditions_TriggerStatusTrigger_B' ]) # Clean up actions if necessary clean_up_actions(action_ids=['test_triggerstatus_action']) ######################################################################################################### # TriggerStatus trigger ######################################################################################################### print('Creating previous trigger with webhook action') previous_trigger = 'test_trigger_conditions_TriggerStatusTrigger_A' previous_trigger_status = 'Succeeded' previous_trigger_type = 'Manual' response = spellbook_call('save_trigger', previous_trigger, '-t=%s' % previous_trigger_type, '-st=Active') assert response is None action_name = 'test_triggerstatus_action' webhook = 'http://www.google.com' response = spellbook_call('save_action', action_name, '-t=Webhook', '-w=%s' % webhook) assert response is None response = spellbook_call('save_trigger', previous_trigger, '--actions', 'test_triggerstatus_action') assert response is None print('Creating the test TriggerStatus trigger') trigger_name = 'test_trigger_conditions_TriggerStatusTrigger'
######################################################################################################### # SendTransaction actions ######################################################################################################### action_name = 'integrationtest_action_SendTransaction_REAL' wallet_type = 'BIP44' bip44_account = 0 bip44_index = 0 fee_address = get_address_from_wallet(account=0, index=1) fee_percentage = 1.0 minimum_amount = 100000 # 100 BTC receiving_address = get_address_from_wallet(account=0, index=2) op_return_data = 'A test op return message' # -------------------------------------------------------------------------------------------------------- print('Creating test action: SendTransaction') response = spellbook_call('save_action', action_name, '-t=SendTransaction', '-fa=%s' % fee_address, '-fp=%s' % fee_percentage, '-wt=%s' % wallet_type, '-ba=%s' % bip44_account, '-bi=%s' % bip44_index, '-ma=%s' % minimum_amount, '-ra=%s' % receiving_address, '-or=%s' % op_return_data) assert response is None # response = spellbook_call('run_action', action_name) # assert response is True
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call print('Starting Spellbook integration test: bech32') print('----------------------------------------------\n') print('Getting the list of configured explorers') configured_explorers = spellbook_call('get_explorers') txid = '48089a814ac571944feb7162cc0145eea4e72742aa51f6f23d470debd838eeb3' address = 'tb1ql7kvd5w8d0czy7majmxhm2mul99039zvlzrkn0' testnet_P2WPKH = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx' testnet_P2WSH = 'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7' for explorer in configured_explorers: response = spellbook_call('get_prime_input_address', txid, '-e=%s' % explorer) if response['prime_input_address'] is None: print('%s does NOT support Bech32!' % explorer) for explorer in configured_explorers: response = spellbook_call('get_transactions', address, '-e=%s' % explorer)
def get_response_from_explorer(self, explorer): start_time = time.time() args_with_explorer = self.spellbook_args + ['-e=%s' % explorer] return spellbook_call(*args_with_explorer), time.time() - start_time
print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers( trigger_ids=['test_trigger_conditions_DeadMansSwitchTrigger']) ######################################################################################################### # DeadMansSwitch trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_DeadMansSwitchTrigger' trigger_type = 'DeadMansSwitch' timeout = 60 # 60 seconds warning_email = '*****@*****.**' response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-ti=%s' % timeout, '-we=%s' % warning_email, '-st=Active') assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type assert response['timeout'] == timeout assert response['warning_email'] == warning_email assert response['triggered'] == 0 print('Checking DeadMansSwitch trigger, should not activate') response = spellbook_call('check_triggers', trigger_name) assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type
print('Starting Spellbook integration test: Command actions') print('----------------------------------------------\n') # Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_Command']) ######################################################################################################### # Command actions ######################################################################################################### action_name = 'integrationtest_action_Command' run_command = 'echo Hello world!' # -------------------------------------------------------------------------------------------------------- print('Creating test action: CommandAction') response = spellbook_call('save_action', '-t=Command', action_name, '-c=%s' % run_command) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'Command' assert response['run_command'] == run_command # --------------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------------- trigger_types = [ 'Manual', 'Balance', 'Received', 'Sent', 'Block_height', 'Timestamp' ] for trigger_type in trigger_types: print( '--------------------------------------------------------------------------------------------------------' ) print('Saving trigger of type: %s' % trigger_type) trigger_name = 'test_trigger_%s' % trigger_type response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type) assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_id'] == trigger_name assert response['trigger_type'] == trigger_type print( '--------------------------------------------------------------------------------------------------------' ) for trigger_type in trigger_types: print( '--------------------------------------------------------------------------------------------------------' ) print('updating trigger of type: %s' % trigger_type)
clean_up_triggers(trigger_ids=['test_trigger_with_actions']) # Clean up actions if necessary clean_up_actions(action_ids=['test_trigger_action1', 'test_trigger_action2', 'test_trigger_action3', 'test_trigger_action4']) ######################################################################################################### # Trigger with actions ######################################################################################################### trigger_name = 'test_trigger_with_actions' trigger_type = 'Manual' # -------------------------------------------------------------------------------------------------------- print('Saving trigger of type: %s' % trigger_type) response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type) assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_id'] == trigger_name assert response['trigger_type'] == trigger_type assert response['actions'] == [] # -------------------------------------------------------------------------------------------------------- print('adding non-existing action to trigger') response = spellbook_call('save_trigger', trigger_name, '--actions', 'test_trigger_action1', 'test_trigger_action2') assert response is None print('adding test actions')
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from helpers.setupscripthelpers import spellbook_call PROGRAM_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) print('Starting Spellbook integration test: explorers') print('----------------------------------------------\n') # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured explorers') configured_explorers = spellbook_call('get_explorers') if configured_explorers: print('--> Explorers found at beginning of test, deleting them before continuing') for explorer_id in configured_explorers: print('----> Get explorer config %s' % explorer_id) response = spellbook_call('get_explorer_config', explorer_id) print('----> Deleting explorer %s' % explorer_id) response = spellbook_call('delete_explorer', explorer_id) assert response is None print('\nGetting the list of configured explorers, should be empty') response = spellbook_call('get_explorers') assert isinstance(response, list) assert len(response) == 0 print('--------------------------------------------------------------------------------------------------------')
print('----------------------------------------------\n') # Clean up old actions if necessary clean_up_actions(action_ids=[ 'test_action_Command', 'test_action_SendMail', 'test_action_Webhook', 'test_action_RevealSecret' ]) ######################################################################################################### # Command actions ######################################################################################################### action_name = 'test_action_Command' run_command = 'echo Hello world!' print('Creating test action: CommandAction') response = spellbook_call('save_action', '-t=Command', action_name, '-c=%s' % run_command) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'Command' assert response['run_command'] == run_command # --------------------------------------------------------------------------------------------------------
print('Starting Spellbook integration test: Manual trigger conditions') print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_ManualTrigger']) ######################################################################################################### # Manual trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_ManualTrigger' trigger_type = 'Manual' # ------------------------------------------------------------------------------------------------- print('Creating Manual trigger') response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-st=Active') assert response is None print('Checking if trigger has not been triggered yet') response = spellbook_call('get_trigger_config', trigger_name) assert response['triggered'] == 0 assert response['trigger_type'] == trigger_type print('Activating Manual trigger') response = spellbook_call('activate_trigger', trigger_name) assert response is None print('Checking if trigger has been triggered') response = spellbook_call('get_trigger_config', trigger_name) assert response['triggered'] == 1
# -------------------------------------------------------------------------------------------------------- # Create Actions # -------------------------------------------------------------------------------------------------------- print( '\nCreating Action...') action_id = 'Dividends' action_type = ActionType.SENDTRANSACTION transaction_type = TransactionType.SEND2SIL # no need to set the amount, all funds in the address will be sent response = spellbook_call('save_action', action_id, '--type=%s' % action_type, '--transaction_type=%s' % transaction_type, '--wallet_type=%s' % wallet_type, '--bip44_account=%s' % bip44_account, '--bip44_index=%s' % bip44_index_dividends, '--minimum_amount=%s' % amount, # additional check to make sure enough funds are available in the address before sending transaction '--registration_address=%s' % investors_address, # '--registration_block_height=%s' % investors_block_height, #uncomment if you want to lock the investors shares at a specific moment '--fee_percentage=%s' % dividends_fee_percentage, '--fee_address=%s' % dividends_fee_address, ) assert response is None # -------------------------------------------------------------------------------------------------------- # Create Triggers # -------------------------------------------------------------------------------------------------------- print( '\nCreating Trigger...') trigger_id = 'Dividends' trigger_type = TriggerType.BALANCE response = spellbook_call('save_trigger', trigger_id,
print('\nCreating Action...') action_id = 'Splitter' action_type = ActionType.SENDTRANSACTION transaction_type = TransactionType.SEND2MANY # no need to set the amount, all funds in the address will be sent response = spellbook_call( 'save_action', action_id, '--type=%s' % action_type, '--transaction_type=%s' % transaction_type, '--wallet_type=%s' % wallet_type, '--bip44_account=%s' % bip44_account, '--bip44_index=%s' % bip44_index, '--minimum_amount=%s' % amount, # additional check to make sure enough funds are available in the address before sending transaction '--distribution=%s' % os.path.abspath(distribution_filename), # '--fee_percentage=%s' % splitter_fee_percentage, # uncomment if you want to charge a fee for the service # '--fee_address=%s' % splitter_fee_address, # uncomment if you want to charge a fee for the service # '--amount=%s' % total_amount, # uncomment if you want to send a specific amount # '--change_address=%s' % change_address, # uncomment if you want to send the change to a specific address ) assert response is None # -------------------------------------------------------------------------------------------------------- # Create Triggers # -------------------------------------------------------------------------------------------------------- print('\nCreating Trigger...') trigger_id = 'Splitter'
print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_BlockHeightTrigger']) ######################################################################################################### # Blockheight trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_BlockHeightTrigger' trigger_type = 'Block_height' # ------------------------------------------------------------------------------------------------- print('Creating Block_height trigger') response = spellbook_call('get_latest_block') latest_block_height = response['block']['height'] assert isinstance(latest_block_height, int) and latest_block_height > 0 print( 'set block_height to 1 block in the future and 0 conditions, this should not trigger yet' ) response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-b=%d' % (latest_block_height + 1), '-c=0', '-st=Active') assert response is None print('Checking if trigger has not been triggered yet') response = spellbook_call('get_trigger_config', trigger_name) assert response['triggered'] == 0 assert response['trigger_type'] == trigger_type
print('Starting Spellbook integration test: Webhook actions') print('----------------------------------------------\n') # Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_Webhook']) ######################################################################################################### # Webhook actions ######################################################################################################### action_name = 'integrationtest_action_Webhook' webhook = 'http://www.google.com' # -------------------------------------------------------------------------------------------------------- print('Creating test action: Webhook') response = spellbook_call('save_action', '-t=Webhook', action_name, '-w=%s' % webhook) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'Webhook' assert response['webhook'] == webhook # --------------------------------------------------------------------------------------------------------
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call from helpers.hotwallethelpers import get_address_from_wallet print('Starting Spellbook integration test: data') print('----------------------------------------------\n') # -------------------------------------------------------------------------------------------------------- print('Getting latest block from Blockchain.info') blockchain_info = spellbook_call('get_latest_block', '-e=blockchain.info') print('Getting latest block from BTC.com') btc_com = spellbook_call('get_latest_block', '-e=btc.com') print('Getting latest block from Blockstream.info') blockstream_info = spellbook_call('get_latest_block', '-e=blockstream.info') if not (blockchain_info['block']['time'] == btc_com['block']['time'] == blockstream_info['block']['time']): print('Not all times are the same!') print('Blockchain.info: %s' % blockchain_info['block']['time']) print('BTC.com: %s' % btc_com['block']['time']) print('Blockstream.info: %s' % blockstream_info['block']['time']) # -------------------------------------------------------------------------------------------------------- # block_height = 488470 # Note: blockchain.info reports wrong for this block! it says an orphaned block is on the main chain when this is requested via the api (not via the website) block_height = 488471 print('Getting block %s from Blockchain.info' % block_height) blockchain_info = spellbook_call('get_block', block_height, '-e=blockchain.info')
print('Starting Spellbook integration test: Timestamp trigger conditions') print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_TimestampTrigger']) ######################################################################################################### # Timestamp trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_TimestampTrigger' trigger_type = 'Timestamp' timestamp = int(time.time()) + 5 # 5 seconds in the future # ---------------------------------------------------------------------------------------------------------------------- response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-ts=%s' % timestamp, '-st=Active') assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type assert response['timestamp'] == timestamp assert response['triggered'] == 0 print('Checking timestamp trigger, should not activate') response = spellbook_call('check_triggers', trigger_name) assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type assert response['timestamp'] == timestamp assert response['triggered'] == 0
# Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_ReceivedTrigger']) ######################################################################################################### # Received trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_ReceivedTrigger' trigger_type = 'Received' # ---------------------------------------------------------------------------------------------------------------------- account = 0 index = 0 address = get_address_from_wallet(account=account, index=index) balance_data = spellbook_call('get_balance', address) amount = balance_data['balance']['received'] print('Creating Received trigger') print('Setting trigger amount higher than current received balance') response = spellbook_call('save_trigger', '-t=%s' % trigger_type, trigger_name, '--reset', '-a=%s' % address, '-am=%s' % (amount + 1)) assert response is None print('Checking if trigger has not been triggered yet') response = spellbook_call('get_trigger_config', trigger_name) assert response['triggered'] == 0 assert response['address'] == address assert response['amount'] == amount + 1
# Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_SendMail']) ######################################################################################################### # SendMail actions ######################################################################################################### action_name = 'integrationtest_action_SendMail' mail_recipients = '*****@*****.**' mail_subject = 'example email subject' mail_body_template = 'template1' # -------------------------------------------------------------------------------------------------------- print('Creating test action: SendMailAction') response = spellbook_call('save_action', '-t=SendMail', action_name, '-mr=%s' % mail_recipients, '-ms=%s' % mail_subject, "-mb=%s" % mail_body_template) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'SendMail' assert response['mail_recipients'] == mail_recipients assert response['mail_subject'] == mail_subject
# Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_RecurringTrigger']) ######################################################################################################### # Recurring trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_RecurringTrigger' trigger_type = 'Recurring' begin_time = int(time.time()) + 10 # 10 seconds in the future end_time = int(time.time()) + 60 # 60 seconds in the future interval = 10 # ---------------------------------------------------------------------------------------------------------------------- response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-bt=%s' % begin_time, '-et=%s' % end_time, '-i=%s' % interval, '-st=Active') assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type assert response['begin_time'] == begin_time assert response['end_time'] == end_time assert response['interval'] == interval assert response['next_activation'] == begin_time assert response['triggered'] == 0 print('Checking recurring trigger, should not activate because begin time has not been reached') response = spellbook_call('check_triggers', trigger_name) assert response is None response = spellbook_call('get_trigger_config', trigger_name)
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse import time import deepdiff from helpers.setupscripthelpers import spellbook_call from pprint import pprint EXPLORERS = spellbook_call('get_explorers') class Comparison(object): def __init__(self, *args): self.spellbook_args = list(args) print( '\n\n#####################################################################################################' ) print('# Comparing: %s' % self.spellbook_args) print( '#####################################################################################################' ) self.responses = {} for explorer in EXPLORERS: self.responses[explorer] = self.get_response_from_explorer( explorer) self.compare_response_times()
print('Starting Spellbook integration test: SignedMessage trigger conditions') print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_SignedMessageTrigger']) ######################################################################################################### # SignedMessage trigger ######################################################################################################### trigger_name = 'test_trigger_conditions_SignedMessageTrigger' trigger_type = 'SignedMessage' # ---------------------------------------------------------------------------------------------------------------------- response = spellbook_call('save_trigger', trigger_name, '-t=%s' % trigger_type, '-st=Active') assert response is None response = spellbook_call('get_trigger_config', trigger_name) assert response['trigger_type'] == trigger_type assert response['triggered'] == 0 assert response['multi'] is False print('Checking SignedMessage trigger, should not activate') response = spellbook_call('check_triggers', trigger_name) assert response is None account = 0 index = 0 address = get_address_from_wallet(account=account, index=index)
print('Setting up Notary') print('----------------------------------------------\n') # -------------------------------------------------------------------------------------------------------- # Clean up old triggers and actions first # -------------------------------------------------------------------------------------------------------- clean_up_triggers(trigger_ids=['Notary-request']) # -------------------------------------------------------------------------------------------------------- # Create Triggers # -------------------------------------------------------------------------------------------------------- print('\nCreating Trigger...') trigger_id = 'Notary-request' trigger_type = TriggerType.HTTPPOSTREQUEST script = 'Notary\Notary.py' response = spellbook_call('save_trigger', trigger_id, '--type=%s' % trigger_type, '--script=%s' % script, '--multi') assert response is None print('HTTP POST endpoint created') print( 'To create a new Notary request, send a HTTP POST request with the desired message as the "message" field in the request data to:' ) url = 'http://{host}:{port}/spellbook/triggers/Notary-request/post'.format( host=get_host(), port=get_port()) print(url)
# -------------------------------------------------------------------------------------------------------- # Clean up old triggers and actions first # -------------------------------------------------------------------------------------------------------- clean_up_triggers(trigger_ids=['PaymentProcessorNewPayment', 'PaymentProcessorPaymentStatus', 'PaymentProcessorTransactionReceived']) # -------------------------------------------------------------------------------------------------------- # Create Triggers # -------------------------------------------------------------------------------------------------------- print('Creating Triggers...') trigger_id = 'PaymentProcessorNewPayment' trigger_type = 'HTTPPostRequest' script = os.path.join('PaymentProcessor', 'PaymentProcessorNewPayment.py') response = spellbook_call('save_trigger', trigger_id, '-t=%s' % trigger_type, '--multi', '-sc=%s' % script) assert response is None trigger_id = 'PaymentProcessorPaymentStatus' trigger_type = 'HTTPGetRequest' script = os.path.join('PaymentProcessor', 'PaymentProcessorPaymentStatus.py') response = spellbook_call('save_trigger', trigger_id, '-t=%s' % trigger_type, '--multi', '-sc=%s' % script) assert response is None trigger_id = 'PaymentProcessorTransactionReceived'
# Clean up old triggers and actions first # -------------------------------------------------------------------------------------------------------- clean_up_triggers(trigger_ids=['Lottery']) clean_up_actions(action_ids=['Lottery-payout']) # -------------------------------------------------------------------------------------------------------- # Create Actions # -------------------------------------------------------------------------------------------------------- print('\nCreating Action...') action_id = 'Lottery-payout' action_type = ActionType.SENDTRANSACTION transaction_type = TransactionType.SEND2SINGLE response = spellbook_call('save_action', action_id, '--type=%s' % action_type, '--wallet_type=%s' % wallet_type, '--bip44_account=%s' % bip44_account, '--bip44_index=%s' % bip44_index, '--fee_percentage=%s' % lottery_fee_percentage, '--fee_address=%s' % lottery_fee_address) assert response is None # -------------------------------------------------------------------------------------------------------- # Create Triggers # -------------------------------------------------------------------------------------------------------- print('\nCreating Trigger...') trigger_id = 'Lottery' trigger_type = TriggerType.BLOCK_HEIGHT block_height = current_block_height + block_height_offset script = 'Lottery\Lottery.py' # note: the action for the trigger will be modified by the script because the winning address is not known at this time
bip44_account = 0 bip44_index = 0 fee_address = get_address_from_wallet(account=0, index=1) fee_percentage = 1.0 minimum_amount = 10000000000 # 100 BTC receiving_address = get_address_from_wallet(account=0, index=2) op_return_data = 'A test op return message' # -------------------------------------------------------------------------------------------------------- print('Creating test action: SendTransaction') response = spellbook_call('save_action', action_name, '-t=SendTransaction', '-fa=%s' % fee_address, '-fp=%s' % fee_percentage, '-wt=%s' % wallet_type, '-ba=%s' % bip44_account, '-bi=%s' % bip44_index, '-ma=%s' % minimum_amount, '-ra=%s' % receiving_address, '-or=%s' % op_return_data) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'SendTransaction' assert response['fee_address'] == fee_address
print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=['test_trigger_conditions_HTTPDeleteRequest_Trigger']) ######################################################################################################### # HTTP DELETE request trigger ######################################################################################################### trigger_id = 'test_trigger_conditions_HTTPDeleteRequest_Trigger' trigger_type = 'HTTPDeleteRequest' script = 'Echo.py' # ------------------------------------------------------------------------------------------------- print('Creating HTTP DELETE request trigger') response = spellbook_call('save_trigger', trigger_id, '-t=%s' % trigger_type, '-sc=%s' % script, '-st=Active', '--multi') assert response is None print('Checking if trigger has not been triggered yet') response = spellbook_call('get_trigger_config', trigger_id) assert response['triggered'] is 0 assert response['trigger_type'] == trigger_type print('Activating HTTP DELETE request trigger with data') host, port = get_host(), get_port() url = 'http://{host}:{port}/spellbook/triggers/{trigger_id}/delete'.format(host=host, port=port, trigger_id=trigger_id) headers = {} data = {'test': 'hello'} try: r = requests.delete(url, headers=headers, json=data)
print('----------------------------------------------\n') # Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_RevealSecret']) ######################################################################################################### # RevealSecret actions ######################################################################################################### action_name = 'integrationtest_action_RevealSecret' reveal_text = 'A secret message' reveal_link = 'http://www.asecretlink.com' # -------------------------------------------------------------------------------------------------------- print('Creating test action: RevealSecret') response = spellbook_call('save_action', '-t=RevealSecret', action_name, '-rt=%s' % reveal_text, '-rl=%s' % reveal_link) assert response is None # -------------------------------------------------------------------------------------------------------- print('Getting the list of configured action_ids') response = spellbook_call('get_actions') assert action_name in response # -------------------------------------------------------------------------------------------------------- print('Getting the action config of the action we just created') response = spellbook_call('get_action_config', action_name) assert response['id'] == action_name assert response['action_type'] == 'RevealSecret' assert response['reveal_text'] == reveal_text assert response['reveal_link'] == reveal_link