A helper gem for scripting a stellar-core. This gem provides a system of creating isolated test networks into which you can play transactions and record results.
The motivation for this project comes from the testing needs of horizon. Horizon uses
scc to record the various testing scenarios that its suite uses.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install stellar_core_commander
Assumptions about environment
scc makes a few assumptions about the environment it runs in that you should be aware. In the event that your own environment differs from the below assumptions,
scc will definitely break.
- Postgresql is installed locally and
dropdbare available on your PATH
whichcommand is available on your system.
- Postgresql is running and the current user has passwordless access to it. Running
psql postgres -c "\l"should confirm you're setup correctly.
- Your current user has access to create and drop postgres databases. Test using:
createdb foobar && dropdb foobar
- A working
stellar-corebinary is available on your path (or specified using the
- Your system has libsodium installed
Usage As Command Line Tool
stellar_core_commander installs the command line tool
takes a recipe file, spins up a test network, plays the defined transactions against it, then dumps the ledger database to stdout.
scc's usage is like so:
$ scc -r my_recipe.rb > out.sql
The above command will play the recipe written in
my_recipe.rb, verify that all transactions within the recipe have succeeded, then dump the ledger database to
Usage as a Library
The heart of
scc is a recipe, which is just a ruby script that executes in a context
that makes it easy to play transactions against the isolated test network. Lets look at a simple recipe:
account :scott payment :master, :scott, [:native, 1000_000000]
Let's look at each statement in turn.
account :scott declares a new unfunded account and binds it to the name
:scott, which we will use in the next statement.
The next statement is more complex:
payment :master, :scott, [:native, 1000_000000]. This statement encodes "Send 1000 lumens from the :master account to the :scott account".
:master (sometimes also called the "root" account) is a special account that is created when a new ledger is initialized. We often use it in our recipes to fund other accounts, since in a ledgers initial state the :master account has all 100 billion lumen.
All recipe execute within the context of a
StellarCoreCommander::Transactor. See the code for all available methods.
- Fork it ( https://github.com/[my-github-username]/stellar_core_commander/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request