Skip to content

Commit

Permalink
Use ruby dict as script templates in tests instead of parsing from st…
Browse files Browse the repository at this point in the history
…rings
  • Loading branch information
Piotr Stachyra committed Apr 22, 2021
1 parent 6db4862 commit 9d60455
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 65 deletions.
103 changes: 48 additions & 55 deletions test/e2e/spec/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1852H/1815H/#{acc_ix}")

script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub}" },
"template":
{ "all":
script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub },
"template" =>
{ "all" =>
[ "cosigner#0",
{ "active_from": 120 }
{ "active_from" => 120 }
]
}
})
script = JSON.parse(script_template)
}

payload = { mnemonic_sentence: m24,
passphrase: PASS,
name: "Shared wallet",
account_index: acc_ix,
payment_script_template: script,
delegation_script_template: script,
payment_script_template: script_template,
delegation_script_template: script_template,
}

wallet = w.create(payload)
Expand All @@ -51,33 +50,31 @@
acc_ix = '0H'
acc_xpub = cardano_address_get_acc_xpub(m24, "1852H/1815H/#{acc_ix}")

payment_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub}" },
"template":
{ "all":
payment_script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub },
"template" =>
{ "all" =>
[ "cosigner#0",
{ "active_from": 120 }
{ "active_from" => 120 }
]
}
})

delegation_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub}" },
"template":
{ "all":
[ "cosigner#0",
"cosigner#1"
}

delegation_script_template = { 'cosigners' =>
{ 'cosigner#0' => acc_xpub },
'template' =>
{ 'all' =>
[ 'cosigner#0',
'cosigner#1'
]
}
})
pscript = JSON.parse(payment_script_template)
dscript = JSON.parse(delegation_script_template)
}
payload = { account_public_key: acc_xpub,
passphrase: PASS,
name: "Shared wallet",
account_index: acc_ix,
payment_script_template: pscript,
payment_script_template: dscript,
payment_script_template: payment_script_template,
payment_script_template: delegation_script_template,
}

wallet = w.create(payload)
Expand All @@ -98,32 +95,30 @@
acc_xpub_wrong = cardano_address_get_acc_xpub(mnemonic_sentence(24),
"1852H/1815H/0H")

payment_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub_wrong}" },
"template":
{ "all":
payment_script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub_wrong },
"template" =>
{ "all" =>
[ "cosigner#0"
]
}
})
}

delegation_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub_wrong}" },
"template":
{ "all":
delegation_script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub_wrong },
"template" =>
{ "all" =>
[ "cosigner#0",
"cosigner#1"
]
}
})
pscript = JSON.parse(payment_script_template)
dscript = JSON.parse(delegation_script_template)
}
payload = { mnemonic_sentence: m24,
passphrase: PASS,
name: "Shared wallet",
account_index: acc_ix,
payment_script_template: pscript,
payment_script_template: dscript,
payment_script_template: payment_script_template,
payment_script_template: delegation_script_template,
}

wallet = w.create(payload)
Expand All @@ -138,32 +133,30 @@
acc_ix = '0H'
acc_xpub_wrong = cardano_address_get_acc_xpub(m24, "1852H/1815H/255H")

payment_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub_wrong}" },
"template":
{ "all":
payment_script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub_wrong },
"template" =>
{ "all" =>
[ "cosigner#0"
]
}
})
}

delegation_script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub_wrong}" },
"template":
{ "all":
delegation_script_template = { "cosigners" =>
{ "cosigner#0" => acc_xpub_wrong },
"template" =>
{ "all" =>
[ "cosigner#0",
"cosigner#1"
]
}
})
pscript = JSON.parse(payment_script_template)
dscript = JSON.parse(delegation_script_template)
}
payload = { mnemonic_sentence: m24,
passphrase: PASS,
name: "Shared wallet",
account_index: acc_ix,
payment_script_template: pscript,
payment_script_template: dscript,
payment_script_template: payment_script_template,
payment_script_template: delegation_script_template,
}

wallet = w.create(payload)
Expand Down
19 changes: 9 additions & 10 deletions test/e2e/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,17 @@
]

def create_pending_shared_wallet(m, acc_ix, acc_xpub)

script_template = %({ "cosigners":
{ "cosigner#0": "#{acc_xpub}" },
"template":
{ "all":
[ "cosigner#0",
"cosigner#1"
script_template = { 'cosigners' =>
{ 'cosigner#0' => acc_xpub },
'template' =>
{ 'all' =>
[ 'cosigner#0',
'cosigner#1'
]
}
})
pscript = JSON.parse(script_template)
dscript = JSON.parse(script_template)
}
pscript = script_template
dscript = script_template

payload = { mnemonic_sentence: m,
passphrase: PASS,
Expand Down

0 comments on commit 9d60455

Please sign in to comment.