Skip to content

Commit

Permalink
Remove dockerized stellar_app and add instructions to run the spec/st…
Browse files Browse the repository at this point in the history
…ellar_app locally instead
  • Loading branch information
Ace Subido and Ramon Tayag authored and ace-subido committed Aug 29, 2018
1 parent dbd80a9 commit 5d0db27
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 52 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ See `spec/acceptance` for detailed examples.

- Copy `spec/config.yml.sample` to `spec/config.yml`
- Replace `destination` with the account the tests will be sending to
- Copy `spec/fixtures/bridge/config_bridge.toml.sample` to `spec/fixtures/bridge/config_bridge.toml`
- Copy `spec/fixtures/bridge/bridge.cfg.sample` to `spec/fixtures/bridge/bridge.cfg`
- Replace `authorizing_seed` with the seed of the account you're sending from
- Replace `receiving_account_id` with the account id you're sending from
- Replace `base_seed` with what you placed in `authorizing_seed`
- `docker-compose up pg`
- `docker-compose run bridge createdb -h pg -U postgres bridge`
- This:
- `docker-compose up bridge`
- Then start the application that we'll run some tests against:
```sh
docker-compose run stellar_app bash -c \
'bundle install && \
bundle exec rails db:create db:migrate && \
bundle exec yarn install'
cd spec/stellar_app
bundle
yarn install
rails db:create db:migrate
rails s
```
- `docker-compose up bridge stellar_app`
- Make your changes
- `rspec spec`

Expand Down
15 changes: 0 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ services:
- "5432:5432"
volumes:
- pg:/var/lib/postgresql/data
stellar_app:
build: spec/stellar_app
command: bash -c "bundle exec rails s -p 3000 -b 0.0.0.0"
ports:
- "3000:3000"
volumes:
- ./spec/stellar_app:/app
- bundle:/bundle
depends_on:
- pg
bundle:
image: busybox
volumes:
- /bundle
volumes:
pg:
bridge:
bundle:
2 changes: 1 addition & 1 deletion spec/stellar_app/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.3.1
2.5.1
21 changes: 0 additions & 21 deletions spec/stellar_app/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions spec/stellar_app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ gem 'jbuilder', '~> 2.5'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
gem "stellar_base-rails"
gem "stellar_base-rails", "0.4.1"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry-byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
Expand Down
16 changes: 13 additions & 3 deletions spec/stellar_app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GEM
chromedriver-helper (1.2.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
coderay (1.1.2)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.2.2)
Expand Down Expand Up @@ -155,6 +156,12 @@ GEM
mini_portile2 (~> 2.3.0)
pg (1.0.0)
pipetree (0.1.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.6.0)
byebug (~> 10.0)
pry (~> 0.10)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.5)
Expand Down Expand Up @@ -238,12 +245,15 @@ GEM
rbnacl
rbnacl-libsodium (~> 1.0.3)
xdr (~> 2.0.0)
stellar_base-rails (0.3.0)
stellar_base-rails (0.4.1)
disposable
dry-types
gem_config
httparty
light-service
multi_json
rails (~> 5.1)
representable
stellar-base (= 0.14.0)
trailblazer (~> 2.0)
trailblazer-rails
Expand Down Expand Up @@ -296,21 +306,21 @@ PLATFORMS

DEPENDENCIES
bootsnap (>= 1.1.0)
byebug
capybara (>= 2.15)
chromedriver-helper
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
pg (~> 1.0)
pry-byebug
puma (~> 3.11)
rails (~> 5.2.1)
sass-rails (~> 5.0)
selenium-webdriver
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
stellar_base-rails
stellar_base-rails (= 0.4.1)
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
Expand Down
2 changes: 1 addition & 1 deletion spec/stellar_app/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ default: &default
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: postgres
host: pg
host: localhost

development:
<<: *default
Expand Down
21 changes: 21 additions & 0 deletions spec/stellar_app/config/initializers/stellar_base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
StellarBase.configure do |c|
c.modules = %i(bridge_callbacks withdraw)

c.distribution_account = "G-DISTRIBUTION"

c.on_bridge_callback = StellarBase::WithdrawalRequests::Process
# c.check_bridge_callbacks_authenticity = false
# c.check_bridge_callbacks_mac_payload = false
# c.bridge_callbacks_mac_key = ENV["MAC_KEY"]

# c.on_withdraw = ProcessWithdrawal
c.withdrawable_assets = [
{
type: "crypto",
network: "bitcoin",
asset_code: "BTC",
issuer: "G-ISSUER",
fee_fixed: 0.001,
}
]
end
2 changes: 1 addition & 1 deletion spec/stellar_app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Rails.application.routes.draw do
mount StellarBase::Engine => "/stellar_base"
mount StellarBase::Engine => "/stellar"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This migration comes from stellar_base (originally 20180816014433)
class CreateStellarBaseBridgeCallbacks < ActiveRecord::Migration[5.1]
def change
create_table :stellar_base_bridge_callbacks do |t|
t.string :operation_id, null: false
t.string :from, null: false
t.string :route
t.decimal :amount, null: false
t.string :asset_code
t.string :asset_issuer
t.string :memo_type
t.string :memo
t.string :data
t.string :transaction_id
t.index %i[asset_code asset_issuer], name: :index_stellar_base_bridge_callbacks_on_asset
t.index :memo
t.index :operation_id
t.index :transaction_id
t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This migration comes from stellar_base (originally 20180816110314)
class CreateStellarBaseWithdrawalRequests < ActiveRecord::Migration[5.1]
def change
create_table :stellar_base_withdrawal_requests do |t|
t.string :asset_type, null: false
t.string :asset_code, null: false
t.string :dest, null: false
t.string :issuer, null: false
t.string :dest_extra
t.string :account_id
t.string :memo_type
t.string :memo
t.integer :eta
t.decimal :min_amount, null: false, default: 0.0
t.decimal :max_amount
t.decimal :fee_fixed, null: false, default: 0.0
t.decimal :fee_percent, null: false, default: 0.0
t.decimal :fee_network, null: false, default: 0.0
t.string :extra_info
t.index([:asset_type, :asset_code], {
name: :index_stellar_base_withdrawal_requests_on_asset,
})
t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from stellar_base (originally 20180816135847)
class UniqueStellarBaseBridgeCallbacksOperationId < ActiveRecord::Migration[5.1]
def up
remove_index :stellar_base_bridge_callbacks, :operation_id
add_index :stellar_base_bridge_callbacks, :operation_id, unique: true
end

def down
remove_index :stellar_base_bridge_callbacks, :operation_id
add_index :stellar_base_bridge_callbacks, :operation_id
end
end
42 changes: 41 additions & 1 deletion spec/stellar_app/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,49 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 0) do
ActiveRecord::Schema.define(version: 2018_08_29_075340) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "stellar_base_bridge_callbacks", force: :cascade do |t|
t.string "operation_id", null: false
t.string "from", null: false
t.string "route"
t.decimal "amount", null: false
t.string "asset_code"
t.string "asset_issuer"
t.string "memo_type"
t.string "memo"
t.string "data"
t.string "transaction_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["asset_code", "asset_issuer"], name: "index_stellar_base_bridge_callbacks_on_asset"
t.index ["memo"], name: "index_stellar_base_bridge_callbacks_on_memo"
t.index ["operation_id"], name: "index_stellar_base_bridge_callbacks_on_operation_id", unique: true
t.index ["transaction_id"], name: "index_stellar_base_bridge_callbacks_on_transaction_id"
end

create_table "stellar_base_withdrawal_requests", force: :cascade do |t|
t.string "asset_type", null: false
t.string "asset_code", null: false
t.string "dest", null: false
t.string "issuer", null: false
t.string "dest_extra"
t.string "account_id"
t.string "memo_type"
t.string "memo"
t.integer "eta"
t.decimal "min_amount", default: "0.0", null: false
t.decimal "max_amount"
t.decimal "fee_fixed", default: "0.0", null: false
t.decimal "fee_percent", default: "0.0", null: false
t.decimal "fee_network", default: "0.0", null: false
t.string "extra_info"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["asset_type", "asset_code"], name: "index_stellar_base_withdrawal_requests_on_asset"
end

end

0 comments on commit 5d0db27

Please sign in to comment.