#!/usr/bin/env python # -*- coding: utf-8 -*- from bips.BIP32 import set_chain_mode from helpers.hotwallethelpers import get_address_from_wallet from helpers.setupscripthelpers import spellbook_call, clean_up_actions # make sure testnet is always on for this integrationtest set_chain_mode(mainnet=False) print('Starting Spellbook integration test: SendTransaction action') print('----------------------------------------------\n') # Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_SendTransaction_REAL']) ######################################################################################################### # 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'
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions print('Starting Spellbook integration test: SendMail actions') print('----------------------------------------------\n') # 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
latest_block_data = latest_block() if 'block' not in latest_block_data: print('Unable to get latest block') exit(1) current_block_height = latest_block_data['block']['height'] print('\nCurrent block height: %s' % current_block_height) print('Lottery will pick winner at block height: %s' % (current_block_height + block_height_offset)) # -------------------------------------------------------------------------------------------------------- # 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)
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions 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)
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions 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)
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions print('Starting Spellbook integration test: SpawnProcess actions') print('----------------------------------------------\n') # Clean up actions if necessary clean_up_actions(action_ids=['integrationtest_action_SpawnProcess']) ######################################################################################################### # SpawnProcess actions ######################################################################################################### action_name = 'integrationtest_action_SpawnProcess' # run_command = 'echo Hello world > integrationtests/echo_output.txt' # pipe output to file run_command = 'echo Hello world!' # -------------------------------------------------------------------------------------------------------- print('Creating test action: CommandAction') response = spellbook_call('save_action', '-t=SpawnProcess', 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')
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_triggers, clean_up_actions print('Starting Spellbook integration test: TriggerStatus trigger conditions') print('----------------------------------------------\n') # Clean up triggers if necessary clean_up_triggers(trigger_ids=[ 'test_trigger_conditions_TriggerStatusTrigger', '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'
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_triggers, clean_up_actions print('Starting Spellbook integration test: trigger with actions') print('----------------------------------------------\n') # Clean up triggers if necessary 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'] == []
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions print('Starting Spellbook integration test: actions') 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')
# Set the dividends fee, in this case we will charge a 1 percent fee each time dividends are given out dividends_fee_percentage = 1.0 dividends_fee_address = get_address_from_wallet(account=bip44_account, index=bip44_index_fee) ########################################################################################################## print( 'Setting up Dividends') print( '----------------------------------------------\n') print( 'The address for the dividends is %s' % dividends_address) # -------------------------------------------------------------------------------------------------------- # Clean up old triggers and actions first # -------------------------------------------------------------------------------------------------------- clean_up_triggers(trigger_ids=['Dividends']) clean_up_actions(action_ids=['Dividends']) # -------------------------------------------------------------------------------------------------------- # 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,
# must save the distribution as a json file distribution_filename = os.path.join('splitter-distribution.json') save_to_json_file(filename=distribution_filename, data=distribution) ########################################################################################################## print('Setting up Splitter') print('----------------------------------------------\n') print('The address for the splitter is %s' % splitter_address) # -------------------------------------------------------------------------------------------------------- # Clean up old triggers and actions first # -------------------------------------------------------------------------------------------------------- clean_up_triggers(trigger_ids=['Splitter']) clean_up_actions(action_ids=['Splitter']) # -------------------------------------------------------------------------------------------------------- # Create Actions # -------------------------------------------------------------------------------------------------------- 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,
#!/usr/bin/env python # -*- coding: utf-8 -*- from helpers.setupscripthelpers import spellbook_call, clean_up_actions print('Starting Spellbook integration test: RevealSecret actions') 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')