Skip to content

Commit

Permalink
Additional checks for listing addresses in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Sep 16, 2022
1 parent 052a68a commit 6bbdc8d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 8 deletions.
59 changes: 51 additions & 8 deletions test/e2e/spec/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@
m24 = mnemonic_sentence(24)
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/0H")
incomplete_wid = create_incomplete_shared_wallet(m24, '0H', acc_xpub)
addr = SHARED.addresses.list(incomplete_wid)
expect(addr).to be_correct_and_respond 200
expect(addr.size).to eq 0

acc_xpub_upd = cardano_address_get_acc_xpub(mnemonic_sentence(24),
"1854H/1815H/0H")
Expand All @@ -183,6 +186,9 @@
expect(update_payment).to be_correct_and_respond 200
expect(SHARED.wallets.get(incomplete_wid)['state']['status']).to eq 'incomplete'
expect(SHARED.wallets.get(incomplete_wid)).to be_correct_and_respond 200
addr = SHARED.addresses.list(incomplete_wid)
expect(addr).to be_correct_and_respond 200
expect(addr.size).to eq 0

update_delegation = SHARED.wallets.update_delegation_script(incomplete_wid,
"cosigner#1",
Expand All @@ -193,6 +199,9 @@
SHARED.wallets.get(incomplete_wid)['state']['status'] != 'incomplete'
end
expect(SHARED.wallets.list).to be_correct_and_respond 200
addr = SHARED.addresses.list(incomplete_wid)
expect(addr).to be_correct_and_respond 200
expect(addr.size).to eq 20
end

it "Create / update partially / get / list / delete" do
Expand Down Expand Up @@ -468,36 +477,70 @@
m24 = mnemonic_sentence(24)
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1854H/1815H/#{acc_ix}")
active_wid = create_incomplete_shared_wallet(acc_xpub, acc_ix, "self")
incomplete_wid = create_incomplete_shared_wallet(acc_xpub, acc_ix, "self")

a = SHARED.addresses.list(active_wid)
a = SHARED.addresses.list(incomplete_wid)
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(active_wid, { state: "used" })
a = SHARED.addresses.list(incomplete_wid, { state: "used" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(active_wid, { state: "unused" })
a = SHARED.addresses.list(incomplete_wid, { state: "unused" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

acc_xpub = cardano_address_get_acc_xpub(mnemonic_sentence(24), "1854H/1815H/0H")
patch_incomplete_shared_wallet(incomplete_wid,
{"cosigner#1" => acc_xpub},
{"cosigner#1" => acc_xpub})

a = SHARED.addresses.list(incomplete_wid)
expect(a).to be_correct_and_respond 200
expect(a.size).to be 20

a = SHARED.addresses.list(incomplete_wid, { state: "used" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(incomplete_wid, { state: "unused" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 20
end

it "Lists empty addresses on incomplete shared wallet - from mnemonics" do
m24 = mnemonic_sentence(24)
active_wid = create_incomplete_shared_wallet(m24, '0H', "self")
incomplete_wid = create_incomplete_shared_wallet(m24, '0H', "self")

a = SHARED.addresses.list(active_wid)
a = SHARED.addresses.list(incomplete_wid)
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(active_wid, { state: "used" })
a = SHARED.addresses.list(incomplete_wid, { state: "used" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(active_wid, { state: "unused" })
a = SHARED.addresses.list(incomplete_wid, { state: "unused" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

acc_xpub = cardano_address_get_acc_xpub(mnemonic_sentence(24), "1854H/1815H/0H")
patch_incomplete_shared_wallet(incomplete_wid,
{"cosigner#1" => acc_xpub},
{"cosigner#1" => acc_xpub})

a = SHARED.addresses.list(incomplete_wid)
expect(a).to be_correct_and_respond 200
expect(a.size).to be 20

a = SHARED.addresses.list(incomplete_wid, { state: "used" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 0

a = SHARED.addresses.list(incomplete_wid, { state: "unused" })
expect(a).to be_correct_and_respond 200
expect(a.size).to be 20
end
end

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ def create_incomplete_shared_wallet(m, acc_ix, acc_xpub)
WalletFactory.create(:shared, payload)['id']
end

def patch_incomplete_shared_wallet(wid, payment_patch, deleg_patch)
if payment_patch
p_upd = SHARED.wallets.update_payment_script(wid,
payment_patch.keys.first,
payment_patch.values.first)
expect(p_upd).to be_correct_and_respond 200
end

if deleg_patch
d_upd = SHARED.wallets.update_delegation_script(wid,
deleg_patch.keys.first,
deleg_patch.values.first)
expect(d_upd).to be_correct_and_respond 200
end
end

def create_active_shared_wallet(m, acc_ix, acc_xpub)
script_template = { 'cosigners' =>
{ 'cosigner#0' => acc_xpub },
Expand Down

0 comments on commit 6bbdc8d

Please sign in to comment.