Skip to content

Commit

Permalink
Remove bip_mnemonic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Sep 30, 2022
1 parent 5cf1d99 commit 58978da
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 109 deletions.
40 changes: 20 additions & 20 deletions test/e2e/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,38 @@ end

task :fixture_wallets_template do
log ">> Creating #{FIXTURES_FILE}"

utils = CardanoWallet.new.utils
fixture_wallets = { :linux => {
:fixture => { :shelley => mnemonic_sentence(24),
:icarus => mnemonic_sentence(15),
:random => mnemonic_sentence(12),
:shelley_light => mnemonic_sentence(24)
:fixture => { :shelley => utils.mnemonic_sentence(24),
:icarus => utils.mnemonic_sentence(15),
:random => utils.mnemonic_sentence(12),
:shelley_light => utils.mnemonic_sentence(24)
},
:target => { :shelley => mnemonic_sentence(24),
:shared => mnemonic_sentence(24)
:target => { :shelley => utils.mnemonic_sentence(24),
:shared => utils.mnemonic_sentence(24)
}
},
:macos => {
:fixture => { :shelley => mnemonic_sentence(24),
:icarus => mnemonic_sentence(15),
:random => mnemonic_sentence(12),
:shelley_light => mnemonic_sentence(24)
:fixture => { :shelley => utils.mnemonic_sentence(24),
:icarus => utils.mnemonic_sentence(15),
:random => utils.mnemonic_sentence(12),
:shelley_light => utils.mnemonic_sentence(24)
},
:target => { :shelley => mnemonic_sentence(24),
:shared => mnemonic_sentence(24)
:target => { :shelley => utils.mnemonic_sentence(24),
:shared => utils.mnemonic_sentence(24)
}
},
:windows => {
:fixture => { :shelley => mnemonic_sentence(24),
:icarus => mnemonic_sentence(15),
:random => mnemonic_sentence(12),
:shelley_light => mnemonic_sentence(24)
:fixture => { :shelley => utils.mnemonic_sentence(24),
:icarus => utils.mnemonic_sentence(15),
:random => utils.mnemonic_sentence(12),
:shelley_light => utils.mnemonic_sentence(24)
},
:target => { :shelley => mnemonic_sentence(24),
:shared => mnemonic_sentence(24)
:target => { :shelley => utils.mnemonic_sentence(24),
:shared => utils.mnemonic_sentence(24)
}
},
:currency_contract_wallet => mnemonic_sentence(24)
:currency_contract_wallet => utils.mnemonic_sentence(24)
}
if File.exists?(FIXTURES_FILE)
err = "
Expand Down
23 changes: 1 addition & 22 deletions test/e2e/helpers/utils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'bip_mnemonic'
require 'httparty'
require 'fileutils'

Expand Down Expand Up @@ -93,26 +92,6 @@ def get_fixture_wallet_mnemonics(kind, type)
end
end

def mnemonic_sentence(word_count = 15)
case word_count
when 9
bits = 96
when 12
bits = 128
when 15
bits = 164
when 18
bits = 196
when 21
bits = 224
when 24
bits = 256
else
raise "Non-supported no of words #{word_count}!"
end
BipMnemonic.to_mnemonic(bits: bits, language: 'english').split
end

def wget(url, file = nil)
file ||= File.basename(url)
resp = HTTParty.get(url)
Expand Down Expand Up @@ -195,7 +174,7 @@ def get_protocol_magic(env)
def base64?(value)
value.is_a?(String) && Base64.strict_encode64(Base64.decode64(value)) == value
end

def base16?(value)
value.is_a?(String) && value.match?(/^[[:xdigit:]]+$/)
end
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/spec/byron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
payload = { style: "icarus",
name: "Wallet from mnemonic_sentence",
passphrase: "Secure Passphrase",
mnemonic_sentence: mnemonic_sentence(15)
mnemonic_sentence: CW.utils.mnemonic_sentence(15)
}
wallet = WalletFactory.create(:byron, payload)
expect(wallet).to be_correct_and_respond 201
Expand All @@ -38,7 +38,7 @@
payload = { style: "random",
name: "Wallet from mnemonic_sentence",
passphrase: "Secure Passphrase",
mnemonic_sentence: mnemonic_sentence(12)
mnemonic_sentence: CW.utils.mnemonic_sentence(12)
}
wallet = WalletFactory.create(:byron, payload)
expect(wallet).to be_correct_and_respond 201
Expand Down Expand Up @@ -99,7 +99,7 @@
wallet_type = m[0]
wallet_style = m[1]
it "I can get #{wallet_type} #{wallet_style} walletid using cardano-addresses" do
mnemonics = mnemonic_sentence(24)
mnemonics = CW.utils.mnemonic_sentence(24)
wid = create_byron_wallet(style = wallet_style, "Wallet - ID", mnemonics)

# based on root prv key
Expand All @@ -114,7 +114,7 @@
end

it "#{wallet_type} walletid is not based on acct key" do
mnemonics = mnemonic_sentence(24)
mnemonics = CW.utils.mnemonic_sentence(24)
wid = create_byron_wallet(style = wallet_style, "Wallet - ID", mnemonics)

# based on acct prv key
Expand Down Expand Up @@ -206,7 +206,7 @@
end

it "I can import address - random" do
mnemonics = mnemonic_sentence(15)
mnemonics = CW.utils.mnemonic_sentence(15)
derivation_path = '14H/42H'
id = create_byron_wallet("random", "Wallet - import", mnemonics)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/spec/lightmode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
wait_for_shelley_wallet_to_sync(wid)
wallet = SHELLEY.wallets.get(wid)
txs = SHELLEY.transactions.list(wid)
expect(wallet['balance']['total']['quantity']).to eq 500000000
expect(txs.size).to eq 1
expect(wallet['balance']['total']['quantity']).to > 0
expect(txs.size).to eq > 0
end

describe "Network" do
Expand Down
Loading

0 comments on commit 58978da

Please sign in to comment.