test_name: Test that the two test accounts can trade with each other.
marks:
  - usefixtures:
    - gift_value
    - server_url
    - token_symbol
    - first_account_family_name
    - second_account_family_name
    - first_account_given_name
    - second_account_given_name
    - first_account_phone_number
    - second_account_phone_number
    - first_account_pin_number
    - second_account_pin_number
    - first_transaction_session_id
    - second_transaction_session_id
    - first_account_verify_balance_session_id
    - second_account_verify_balance_session_id
  - second

stages:
  - name: Transactions start menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_transaction_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '51'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Balance {gift_value} {token_symbol}\n1. Send\n2. My Account\n3. Help"

  - name: Transactions start menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_transaction_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '56'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Salio {gift_value} {token_symbol}\n1. Tuma\n2. Akaunti yangu\n3. Usaidizi"

  - name: Initate transcation attempt [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_transaction_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "1"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '30'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Enter phone number\n0. Back"

  - name: Initate transcation attempt [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_transaction_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "1"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '33'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Weka nambari ya simu\n0. Nyuma"

  - name: Enter phone number [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_transaction_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "1*{second_account_phone_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '24'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Enter amount\n0. Back"

  - name: Enter phone number [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_transaction_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "1*{first_account_phone_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '25'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Weka kiwango\n0. Nyuma"

  - name: Enter transcation amount [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_transaction_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "1*{second_account_phone_number}*17"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON {second_account_phone_number} will receive 17.00 {token_symbol} from {first_account_phone_number}.\nPlease enter your PIN to confirm.\n0. Back"

  - name: Enter transcation amount [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_transaction_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "1*{first_account_phone_number}*25"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON {first_account_phone_number} atapokea 25.00 {token_symbol} kutoka kwa {second_account_phone_number}.\nTafadhali weka nambari yako ya siri kudhibitisha.\n0. Nyuma"

  - name: Pin to authorize transaction [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_transaction_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "1*{second_account_phone_number}*17*{first_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Your request has been sent. {second_account_phone_number} will receive 17.00 {token_symbol} from {first_account_phone_number}.\n00. Back\n99. Exit"

  - name: Pin to authorize transaction [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_transaction_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "1*{first_account_phone_number}*25*{second_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Ombi lako limetumwa. {first_account_phone_number} atapokea 25.00 {token_symbol} kutoka kwa {second_account_phone_number}.\n00. Nyuma\n99. Ondoka"

  - name: Verify balance changes [first account]
    delay_before: 10
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_verify_balance_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '51'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Balance 58.00 {token_symbol}\n1. Send\n2. My Account\n3. Help"

  - name: Verify balance changes [second account]
    delay_before: 10
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_verify_balance_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '56'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Salio 42.00 {token_symbol}\n1. Tuma\n2. Akaunti yangu\n3. Usaidizi"