Skip to content

Commit

Permalink
Print vault txs to report
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Dec 11, 2023
1 parent 582358b commit a63d49f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tests/test_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ def test_vault_recover(manager: ContractManager, report_file: TextIOWrapper):

out_instances = V_inst("recover", out_i = 0)

out: CTxOut = V_inst.spending_tx.vout[0]
out: CTxOut = V_inst.spending_tx.vout[0]

assert out.nValue == amount
assert out.scriptPubKey == OpaqueP2TR(recover_priv_key.pubkey[1:]).get_tr_info().scriptPubKey

report_file.write(format_tx_markdown(V_inst.spending_tx, "A recover transaction from the Vault"))
report_file.write(format_tx_markdown(V_inst.spending_tx, "Recovery from vault, 1 input [NoRecoveryAuth]"))

assert len(out_instances) == 0

def test_vault_trigger_and_recover(manager: ContractManager):
def test_vault_trigger_and_recover(manager: ContractManager, report_file: TextIOWrapper):
locktime = 10
V = Vault(None, locktime, recover_priv_key.pubkey[1:], unvault_priv_key.pubkey[1:])

Expand All @@ -55,12 +55,17 @@ def test_vault_trigger_and_recover(manager: ContractManager):
[U_inst] = V_inst("trigger", signer = signer,
out_i = 0, ctv_hash = ctv_tmpl.get_standard_template_hash(0))

report_file.write(format_tx_markdown(V_inst.spending_tx, "Trigger [3 vault inputs]"))


out_instances = U_inst("recover", out_i = 0)

assert len(out_instances) == 0

report_file.write(format_tx_markdown(U_inst.spending_tx, "Recovery from trigger"))

def test_vault_trigger_and_withdraw(rpc: AuthServiceProxy, manager: ContractManager):

def test_vault_trigger_and_withdraw(rpc: AuthServiceProxy, manager: ContractManager, report_file: TextIOWrapper):
locktime = 10
V = Vault(None, locktime, recover_priv_key.pubkey[1:], unvault_priv_key.pubkey[1:])

Expand All @@ -79,6 +84,7 @@ def test_vault_trigger_and_withdraw(rpc: AuthServiceProxy, manager: ContractMana
[U_inst] = V_inst("trigger", signer = signer,
out_i = 0, ctv_hash = ctv_tmpl.get_standard_template_hash(0))

report_file.write(format_tx_markdown(V_inst.spending_tx, "Trigger [3 vault inputs]"))

spend_tx, _ = manager.get_spend_tx(
(U_inst, "withdraw", {"ctv_hash": ctv_tmpl.get_standard_template_hash(0)})
Expand All @@ -105,10 +111,11 @@ def test_vault_trigger_and_withdraw(rpc: AuthServiceProxy, manager: ContractMana

manager.spend_and_wait(U_inst, spend_tx)

report_file.write(format_tx_markdown(U_inst.spending_tx, "Withdraw [3 outputs]"))


def test_vault_trigger_with_revault_and_withdraw(rpc: AuthServiceProxy, manager: ContractManager):
# normal-with-revault-3-inputs.txt

def test_vault_trigger_with_revault_and_withdraw(rpc: AuthServiceProxy, manager: ContractManager, report_file: TextIOWrapper):
# get coins on 3 different Vaults, then trigger with partial withdrawal
# one of the vault uses "trigger_with_revault", the others us normal "trigger"

Expand Down Expand Up @@ -152,6 +159,8 @@ def test_vault_trigger_with_revault_and_withdraw(rpc: AuthServiceProxy, manager:

[U_inst] = manager.spend_and_wait([V_inst_1, V_inst_2, V_inst_3], spend_tx)

report_file.write(format_tx_markdown(spend_tx, "Trigger (with revault) [3 vault inputs]"))

spend_tx, _ = manager.get_spend_tx(
(U_inst, "withdraw", {"ctv_hash": ctv_tmpl.get_standard_template_hash(0)})
)
Expand All @@ -172,4 +181,6 @@ def test_vault_trigger_with_revault_and_withdraw(rpc: AuthServiceProxy, manager:

mine_blocks(rpc, locktime - 1)

manager.spend_and_wait(U_inst, spend_tx)
manager.spend_and_wait(U_inst, spend_tx)

report_file.write(format_tx_markdown(U_inst.spending_tx, "Withdraw (3 outputs)"))

0 comments on commit a63d49f

Please sign in to comment.