Skip to content

Commit

Permalink
Tests for Account Public Keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed May 14, 2021
1 parent ed846f0 commit 40698f4
Showing 1 changed file with 70 additions and 8 deletions.
78 changes: 70 additions & 8 deletions test/e2e/spec/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,18 @@
it "Get public key - active wallet from mnemonics" do
pending "utxo_internal returns empty response"
m24 = mnemonic_sentence(24)
pending_wid = create_pending_shared_wallet(m24, '11H', 'self')
active_wid = create_pending_shared_wallet(m24, '11H', 'self')

matrix.each do |role, addr_prefix|
id = [*0..100000].sample
res = SHARED.keys.get_public_key(pending_wid, role, id)
res = SHARED.keys.get_public_key(active_wid, role, id)
expect(res).to be_correct_and_respond 200
expect(res.to_s).to include addr_prefix
end

matrix_h.each do |role, addr_prefix|
id = [*0..100000].sample
res = SHARED.keys.get_public_key(pending_wid, role, id, {hash: true})
res = SHARED.keys.get_public_key(active_wid, role, id, {hash: true})
expect(res).to be_correct_and_respond 200
expect(res.to_s).to include addr_prefix
end
Expand All @@ -404,18 +404,18 @@
m24 = mnemonic_sentence(24)
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/#{acc_ix}")
pending_wid = create_active_shared_wallet(acc_xpub, acc_ix, "self")
active_wid = create_active_shared_wallet(acc_xpub, acc_ix, "self")

matrix.each do |role, addr_prefix|
id = [*0..100000].sample
res = SHARED.keys.get_public_key(pending_wid, role, id)
res = SHARED.keys.get_public_key(active_wid, role, id)
expect(res).to be_correct_and_respond 200
expect(res.to_s).to include addr_prefix
end

matrix_h.each do |role, addr_prefix|
id = [*0..100000].sample
res = SHARED.keys.get_public_key(pending_wid, role, id, {hash: true})
res = SHARED.keys.get_public_key(active_wid, role, id, {hash: true})
expect(res).to be_correct_and_respond 200
expect(res.to_s).to include addr_prefix
end
Expand All @@ -424,8 +424,70 @@
end

describe "Account Public Keys" do
end
it "Create account public key - pending wallet from mnemonics" do
m24 = mnemonic_sentence(24)
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/0H")
pending_wid = create_pending_shared_wallet(m24, '0H', acc_xpub)
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHARED.keys.create_acc_public_key(pending_wid, index, PASS, 'extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_xvk"

res = SHARED.keys.create_acc_public_key(pending_wid, index, PASS, 'non_extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_vk"
end
end

end
it "Create account public key - pending wallet from acc pub key" do
pending 'no_root key error on wallet from acc pub key'
m24 = mnemonic_sentence(24)
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/#{acc_ix}")
pending_wid = create_pending_shared_wallet(acc_xpub, acc_ix, "self")
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHARED.keys.create_acc_public_key(pending_wid, index, PASS, 'extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_xvk"

res = SHARED.keys.create_acc_public_key(pending_wid, index, PASS, 'non_extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_vk"
end
end

it "Create account public key - active wallet from mnemonics" do
m24 = mnemonic_sentence(24)
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/0H")
active_wid = create_active_shared_wallet(m24, '0H', acc_xpub)
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHARED.keys.create_acc_public_key(active_wid, index, PASS, 'extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_xvk"

res = SHARED.keys.create_acc_public_key(active_wid, index, PASS, 'non_extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_vk"
end
end

it "Create account public key - active wallet from acc pub key" do
pending 'no_root key error on wallet from acc pub key'
m24 = mnemonic_sentence(24)
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/#{acc_ix}")
active_wid = create_active_shared_wallet(acc_xpub, acc_ix, "self")
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHARED.keys.create_acc_public_key(active_wid, index, PASS, 'extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_xvk"

res = SHARED.keys.create_acc_public_key(active_wid, index, PASS, 'non_extended')
expect(res).to be_correct_and_respond 202
expect(res.to_s).to include "acct_shared_vk"
end
end

end
end
end

0 comments on commit 40698f4

Please sign in to comment.