def init_transaction(client, sender_key_input, receiver_address, amount): register_transform_event(BalanceTransfer) loop = get_event_loop() response = loop.run_until_complete( client.broadcast_transform( BalanceTransfer(sender=sender_key_input, receiver=receiver_address, amount=int(amount)))) print(response)
def test_balance_transfer_zero_money_error( dapp_registry: Registry, key_manager: KeyManager, ): """ ARRANGE """ #Define fake values for the transform sender_address = key_manager.generate() sender_initial_balance = 100 receiver_initial_balance = 100 receiver_address = key_manager.generate() send_amount = 0 what_is_this_id = str(uuid4()) ##Build the Transform transform = BalanceTransfer( sender=sender_address, receiver=receiver_address, amount=send_amount, ) #Create a fake state state = create_state(dapp_registry) balance_state = state[BalanceModel.fqdn] #Set Initial Balance for Sender balance_state[sender_address] = BalanceModel( balance=sender_initial_balance) #Set Inital Balance for receiver balance_state[receiver_address] = BalanceModel( balance=receiver_initial_balance) """ ACT """ #Run the Transform with pytest.raises(InvalidAmountError): execute_transform(transform, state) #Define the balance models of the sender and receiver the_receiver: BalanceModel = balance_state[receiver_address] the_sender: BalanceModel = balance_state[sender_address] """ ASSERT """ assert the_receiver.balance == receiver_initial_balance assert the_sender.balance == sender_initial_balance