Urbit Developers
  • Lightning Tutorials

    • Introduction
    • Build a Groups App
    • Build a Chat App
    • Build a Voting App
    • Core Curriculum

      • Hoon School

        • Introduction
        • 1. Hoon Syntax
        • 2. Azimuth (Urbit ID)
        • 3. Gates (Functions)
        • 4. Molds (Types)
        • 5. Cores
        • 6. Trees and Addressing
        • 7. Libraries
        • 8. Testing Code
        • 9. Text Processing I
        • 10. Cores and Doors
        • 11. Data Structures
        • 12. Type Checking
        • 13. Conditional Logic
        • 14. Subject-Oriented Programming
        • 15. Text Processing II
        • 16. Functional Programming
        • 17. Text Processing III
        • 18. Generic and Variant Cores
        • 19. Mathematics
        • App School I

          • Introduction
          • 1. Arvo
          • 2. The Agent Core
          • 3. Imports and Aliases
          • 4. Lifecycle
          • 5. Cards
          • 6. Pokes
          • 7. Structures and Marks
          • 8. Subscriptions
          • 9. Vanes
          • 10. Scries
          • 11. Failure
          • 12. Next Steps
          • Appendix: Types
          • App School II (Full-Stack)

            • Introduction
            • 1. Types
            • 2. Agent
            • 3. JSON
            • 4. Marks
            • 5. Eyre
            • 6. React app setup
            • 7. React app logic
            • 8. Desk and glob
            • 9. Summary
          • Environment Setup
          • Additional Guides

            • Hoon Workbook

              • Competitive Programming
              • Gleichniszahlenreihe
              • Rhonda Numbers
              • Roman Numerals
              • Solitaire Cipher
              • App Workbook

                • Building a CLI App
                • Debugging Wrapper
                • Host a Website
                • Serving a JS Game
                • Ship Monitoring
                • Styled Text
                • Threads

                  • Fundamentals
                  • Bind
                  • Input
                  • Output
                  • Summary
                • Aqua Tests
                • Remote Scry
                • Command-Line Apps
                • HTTP API
                • Eyre noun channels
                • JSON
                • Generators
                • Parsing Text
                • Sail (HTML)
                • Udon (Markdown-esque)
                • Software Distribution
                • Strings
                • Unit Tests
                • Vases
                Urbit Developers
                • Lightning Tutorials

                  • Introduction
                  • Build a Groups App
                  • Build a Chat App
                  • Build a Voting App
                  • Core Curriculum

                    • Hoon School

                      • Introduction
                      • 1. Hoon Syntax
                      • 2. Azimuth (Urbit ID)
                      • 3. Gates (Functions)
                      • 4. Molds (Types)
                      • 5. Cores
                      • 6. Trees and Addressing
                      • 7. Libraries
                      • 8. Testing Code
                      • 9. Text Processing I
                      • 10. Cores and Doors
                      • 11. Data Structures
                      • 12. Type Checking
                      • 13. Conditional Logic
                      • 14. Subject-Oriented Programming
                      • 15. Text Processing II
                      • 16. Functional Programming
                      • 17. Text Processing III
                      • 18. Generic and Variant Cores
                      • 19. Mathematics
                      • App School I

                        • Introduction
                        • 1. Arvo
                        • 2. The Agent Core
                        • 3. Imports and Aliases
                        • 4. Lifecycle
                        • 5. Cards
                        • 6. Pokes
                        • 7. Structures and Marks
                        • 8. Subscriptions
                        • 9. Vanes
                        • 10. Scries
                        • 11. Failure
                        • 12. Next Steps
                        • Appendix: Types
                        • App School II (Full-Stack)

                          • Introduction
                          • 1. Types
                          • 2. Agent
                          • 3. JSON
                          • 4. Marks
                          • 5. Eyre
                          • 6. React app setup
                          • 7. React app logic
                          • 8. Desk and glob
                          • 9. Summary
                        • Environment Setup
                        • Additional Guides

                          • Hoon Workbook

                            • Competitive Programming
                            • Gleichniszahlenreihe
                            • Rhonda Numbers
                            • Roman Numerals
                            • Solitaire Cipher
                            • App Workbook

                              • Building a CLI App
                              • Debugging Wrapper
                              • Host a Website
                              • Serving a JS Game
                              • Ship Monitoring
                              • Styled Text
                              • Threads

                                • Fundamentals
                                • Bind
                                • Input
                                • Output
                                • Summary
                              • Aqua Tests
                              • Remote Scry
                              • Command-Line Apps
                              • HTTP API
                              • Eyre noun channels
                              • JSON
                              • Generators
                              • Parsing Text
                              • Sail (HTML)
                              • Udon (Markdown-esque)
                              • Software Distribution
                              • Strings
                              • Unit Tests
                              • Vases
                              Guides/Additional Guides

                              Aqua Tests

                              Concepts

                              Aqua (short for "aquarium", alluding to the idea that you're running multiple ships in a safe, artificial environment and watching them carefully) is an app that lets you run one or more virtual ships from within a single host.

                              pH is a library of functions designed to make it easy to write integration tests using Aqua.

                              First test

                              To run your first pH test, run the following commands:

                              |start %aqua
                              :aqua +solid
                              -ph-add

                              This will start Aqua, compile a new kernel for it, and then compile and run /ted/ph/add.hoon. Here are the contents of that file:

                              /- spider
                              /+ *ph-io
                              =, strand=strand:spider
                              ^- thread:spider
                              |= args=vase
                              =/ m (strand ,vase)
                              ;< ~ bind:m start-simple
                              ;< ~ bind:m (raw-ship ~bud ~)
                              ;< ~ bind:m (dojo ~bud "[%test-result (add 2 3)]")
                              ;< ~ bind:m (wait-for-output ~bud "[%test-result 5]")
                              ;< ~ bind:m end-simple
                              (pure:m *vase)

                              There's a few lines of boilerplate, with three important lines defining the test.

                              ;< ~ bind:m (raw-ship ~bud ~)
                              ;< ~ bind:m (dojo ~bud "[%test-result (add 2 3)]")
                              ;< ~ bind:m (wait-for-output ~bud "[%test-result 5]")

                              We boot a ship with +raw-ship. In this case the ship we are booting will be ~bud. These ships exist in a virtual environment so you could use any valid @p.

                              Next we enter some commands with +dojo, and then we wait until we get a line that includes some expected output. Each of these commands we need to specify the ship we want to run on.

                              Many tests can be created with nothing more than these simple tools. Try starting two ships and having one send a |hi to the other, and check that it arrives.

                              Many more complex tests can be created, including file changes, personal breaches, mock http clients or servers, or anything you can imagine. Check out /lib/ph/io.hoon for other available functions, and look at other tests in /ted/ph/ for inspiration.

                              Reference

                              Aqua has the following commands:

                              :aqua +solid Compiles a "pill" (kernel) for the guest ships and loads it into Aqua.

                              :aqua [%swap-files ~] modifies the pill to use the files you have in your filesystem without rebuilding the whole pill. For example, if you change an app and you want to test the new version, you must install it in the pill. This command will do that.

                              :aqua [%swap-vanes ~[%a]] Modifies the pill to load a new version of a vane (%a == Ames in this example, but it can be any list of vanes). This is faster than running :aqua +solid.

                              <-

                              Remote Scry

                              Command-Line Apps

                              ->

                              Edit this page on GitHub

                              Last modified June 13, 2023