Skip to content

Commit

Permalink
black tests/test_plugins.py
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Jul 5, 2022
1 parent 2898996 commit 3814572
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def test_revault_attempts_without_spend_tx(miradord, bitcoind, coordinator, nois
)
miradord.add_plugins([{"path": plugin_path}])

# Should get us exactly to the max value
vaults_txs = []
vaults_outpoints = []
deposit_value = 4
for _ in range(2):
deposit_txid, deposit_outpoint = bitcoind.create_utxo(
DEPOSIT_ADDRESS, deposit_value,
DEPOSIT_ADDRESS,
deposit_value,
)
bitcoind.generate_block(1, deposit_txid)
txs = miradord.watch_vault(deposit_outpoint, deposit_value * COIN, DERIV_INDEX)
Expand All @@ -145,10 +145,14 @@ def test_revault_attempts_without_spend_tx(miradord, bitcoind, coordinator, nois

# We share the spend to the coordinator only for vault #0
spend_tx = b64encode(bytes.fromhex(vaults_txs[0]["spend"]["tx"])).decode()
coordinator.set_spend_tx(noise_keys["manager"].privkey, [vaults_outpoints[0]], spend_tx)
coordinator.set_spend_tx(
noise_keys["manager"].privkey, [vaults_outpoints[0]], spend_tx
)

bitcoind.rpc.sendrawtransaction(vaults_txs[0]["unvault"]["tx"])
unvault_txid = bitcoind.rpc.decoderawtransaction(vaults_txs[0]["unvault"]["tx"])["txid"]
unvault_txid = bitcoind.rpc.decoderawtransaction(vaults_txs[0]["unvault"]["tx"])[
"txid"
]
bitcoind.generate_block(1, unvault_txid)
miradord.wait_for_logs(
[
Expand All @@ -157,7 +161,9 @@ def test_revault_attempts_without_spend_tx(miradord, bitcoind, coordinator, nois
]
)
bitcoind.rpc.sendrawtransaction(vaults_txs[1]["unvault"]["tx"])
unvault_txid = bitcoind.rpc.decoderawtransaction(vaults_txs[1]["unvault"]["tx"])["txid"]
unvault_txid = bitcoind.rpc.decoderawtransaction(vaults_txs[1]["unvault"]["tx"])[
"txid"
]
bitcoind.generate_block(1, unvault_txid)
miradord.wait_for_logs(
[
Expand All @@ -168,7 +174,9 @@ def test_revault_attempts_without_spend_tx(miradord, bitcoind, coordinator, nois

# The Cancel transactions has been broadcast because the spend was not
# shared to coordinator.
cancel_txid = bitcoind.rpc.decoderawtransaction(vaults_txs[1]["cancel"]["tx"]["20"])["txid"]
cancel_txid = bitcoind.rpc.decoderawtransaction(
vaults_txs[1]["cancel"]["tx"]["20"]
)["txid"]
bitcoind.generate_block(1, wait_for_mempool=cancel_txid)
miradord.wait_for_log(
f"Cancel transaction was confirmed for vault at '{vaults_outpoints[1]}'"
Expand Down

0 comments on commit 3814572

Please sign in to comment.