Skip to content

Commit

Permalink
Merge #2619
Browse files Browse the repository at this point in the history
2619: Shared wallets testing r=piotr-iohk a=piotr-iohk

# Issue Number

ADP-660


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have added e2e tests using also cardano-addresses from the bundle
- [ ] marked shared eps as experimental for the time being


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
  • Loading branch information
3 people committed Apr 23, 2021
2 parents c3cc8a1 + b958f40 commit cd91f1c
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/cache@v2.1.4
with:
path: ~/node-db-nightly-docker
key: ${{ runner.os }}-node-cache
key: ${{ runner.os }}-docker-node-cache-v2

- name: Set up cardano-wallet and cardano-node MANUAL
if: ${{ github.event.inputs.walletTag != '' && github.event.inputs.nodeTag != ''}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/cache@v2.1.4
with:
path: test/e2e/state/node_db
key: ${{ runner.os }}-node-cache
key: ${{ runner.os }}-node-cache-v2

- name: Run all tests
run: rake run_on[testnet]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/cache@v2.1.4
with:
path: test/e2e/state/node_db
key: ${{ runner.os }}-node-cache
key: ${{ runner.os }}-node-cache-v2

- name: Run all tests
run: rake run_on[testnet]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/cache@v2.1.4
with:
path: test/e2e/state/node_db
key: ${{ runner.os }}-node-cache
key: ${{ runner.os }}-node-cache-v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
8 changes: 4 additions & 4 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5137,7 +5137,7 @@ paths:
tags: ["Shared Wallets"]
summary: Create
description: |
<p align="right">status: <strong>stable</strong></p>
<p align="right">status: <strong>⚠ under development</strong></p>
Create a shared wallet from an account public key, its index and script templates.
requestBody:
Expand All @@ -5153,7 +5153,7 @@ paths:
tags: ["Shared Wallets"]
summary: Get
description: |
<p align="right">status: <strong>stable</strong></p>
<p align="right">status: <strong>⚠ under development</strong></p>
parameters:
- *parametersWalletId
responses: *responsesGetSharedWallet
Expand All @@ -5174,7 +5174,7 @@ paths:
tags: ["Shared Wallets"]
summary: Update Payment
description: |
<p align="right">status: <strong>stable</strong></p>
<p align="right">status: <strong>⚠ under development</strong></p>
parameters:
- *parametersWalletId
requestBody:
Expand All @@ -5190,7 +5190,7 @@ paths:
tags: ["Shared Wallets"]
summary: Update Delegation
description: |
<p align="right">status: <strong>stable</strong></p>
<p align="right">status: <strong>⚠ under development</strong></p>
parameters:
- *parametersWalletId
requestBody:
Expand Down
1 change: 1 addition & 0 deletions test/e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/cardano-wallet-*/
/binaryDist/
*binary-dist*
*.prv

# rake
/.rakeTasks/
3 changes: 2 additions & 1 deletion test/e2e/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'

gem 'cardano_wallet', '0.3.2'
gem 'cardano_wallet', '~> 0.3.4'
# gem 'cardano_wallet', path: "~/wb/cardano_wallet"
gem 'bip_mnemonic', '0.0.4'
gem 'rake', '12.3.3'
gem 'rspec', '3.10.0'
4 changes: 2 additions & 2 deletions test/e2e/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
bip_mnemonic (0.0.4)
cardano_wallet (0.3.2)
cardano_wallet (0.3.4)
httparty (~> 0.18.0)
diff-lcs (1.4.4)
httparty (0.18.1)
Expand Down Expand Up @@ -32,7 +32,7 @@ PLATFORMS

DEPENDENCIES
bip_mnemonic (= 0.0.4)
cardano_wallet (= 0.3.2)
cardano_wallet (~> 0.3.4)
rake (= 12.3.3)
rspec (= 3.10.0)

Expand Down
9 changes: 2 additions & 7 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ One can also start tests against cardano-wallet docker. There is docker-compose-
#### Running tests against local wallet
One can also run tests against `cardano-wallet` and `cardano-node` which are specified on machine's `$PATH`:

```bash
$ rake run_on[testnet,local]
```

or

```bash
$ TESTS_E2E_BINDIR="" rake run_on[testnet]
```
Expand Down Expand Up @@ -124,7 +118,7 @@ One can run specific tests using by providing `SPEC` or `SPEC_OPTS` arguments to
```
- run only specific test identified by line of test code against node and wallet from the `$PATH` (skips downloading from Hydra)
```ruby
$ rake run_on[testnet,local] SPEC=spec/shelley_spec.rb:9
$ TESTS_E2E_BINDIR="" rake run_on[testnet] SPEC=spec/shelley_spec.rb:9
```

### Skipping / making test pending
Expand All @@ -150,4 +144,5 @@ end
## Documentation

Cardano-wallet-rb repository: https://github.com/piotr-iohk/cardano-wallet-rb.

Ruby doc: https://rubydoc.info/gems/cardano_wallet.
23 changes: 11 additions & 12 deletions test/e2e/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ FIXTURES_SECRET = absolute_path ENV['TESTS_E2E_FIXTURES']

TOKEN_METADATA = ENV['TESTS_E2E_TOKEN_METADATA']

path_separator = is_win? ? ';' : ':'
ENV['PATH'] = "#{BINS}#{path_separator}#{ENV['PATH']}"

task :default => :spec

task :fixture_wallets_encode do
Expand Down Expand Up @@ -101,13 +104,11 @@ task :wait_until_node_synced do
end

##
# `rake start_node_and_wallet[testnet,local]' assumes cardano-node and cardano-wallet on $PATH
# `rake start_node_and_wallet[testnet]' assumes cardano-node and cardano-wallet in $TESTS_E2E_BINDIR
task :start_node_and_wallet, [:env, :installation] do |task, args|
task :start_node_and_wallet, [:env] do |task, args|
puts "\n >> Setting up cardano-node and cardano-wallet"

installation = args[:installation] || :bins
bin_dir = installation == "local" ? "" : (BINS.empty? ? "" : BINS + "/")
bin_dir = BINS == '' ? BINS : "#{BINS}/"
config_dir = File.join(CONFIGS, args[:env])
cd = Dir.pwd
mk_dir(STATE)
Expand Down Expand Up @@ -155,18 +156,17 @@ end

##
# Utility task for getting binaries, configs and starting wallet and node
task :launch_on, [:env, :installation] do |task, args|
task :launch_on, [:env] do |task, args|
env = args[:env]
installation = args[:installation] || :bins

if installation == "local"
if BINS == ''
puts "\n >> Skipping getting latest binaries. Will launch wallet and node from $PATH."
else
Rake::Task[:get_latest_bins].invoke
end

Rake::Task[:get_latest_configs].invoke(env)
Rake::Task[:start_node_and_wallet].invoke(env, installation)
Rake::Task[:start_node_and_wallet].invoke(env)
end

task :stop_node_and_wallet do
Expand Down Expand Up @@ -246,22 +246,21 @@ task :get_docker_logs do
cmd "sudo chmod a+rw #{LOGS}/wallet.log"
end

task :run_on, [:env, :installation, :sync_strategy, :skip_configs] do |task, args|
task :run_on, [:env, :sync_strategy, :skip_configs] do |task, args|
puts "\n>> Setting up env and running tests..."
puts "TESTS_E2E_STATEDIR=#{STATE}"
env = args[:env]
installation = args[:installation] || :bins
sync_strategy = args[:sync_strategy] || :sync

if installation == "local"
if BINS == ''
puts "\n >> Skipping getting latest binaries. Will test wallet and node from $PATH."
else
Rake::Task[:get_latest_bins].invoke
end

Rake::Task[:fixture_wallets_decode].invoke
Rake::Task[:get_latest_configs].invoke(env) unless args[:skip_configs]
Rake::Task[:start_node_and_wallet].invoke(env, installation)
Rake::Task[:start_node_and_wallet].invoke(env)

if sync_strategy == "no-sync"
puts "\n >> Skipping waiting for node to be synced..."
Expand Down
14 changes: 12 additions & 2 deletions test/e2e/helpers/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
module Helpers
module Utils
def cmd(cmd)
puts cmd
puts `#{cmd}`
puts cmd.gsub(/\s+/, ' ')
res = `#{cmd}`
puts res
res
end

def cardano_address_get_acc_xpub(mnemonics, derivation_path)
cmd(%(echo #{mnemonics.join(' ')} \
| cardano-address key from-recovery-phrase Shelley \
| cardano-address key child #{derivation_path} \
| cardano-address key public --with-chain-code \
| bech32)).gsub("\n", '')
end

def absolute_path(path)
Expand Down
Loading

0 comments on commit cd91f1c

Please sign in to comment.