Skip to content

Commit fad81d8

Browse files
author
MarcoFalke
committed
test: Fixup creatmultisig documentation and whitespace
1 parent 78295e9 commit fad81d8

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

test/functional/rpc_createmultisig.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2015-2018 The Bitcoin Core developers
2+
# Copyright (c) 2015-2019 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
"""Test transaction signing using the signrawtransaction* RPCs."""
5+
"""Test multisig RPCs"""
66

77
from test_framework.test_framework import BitcoinTestFramework
88
import decimal
99

10+
1011
class RpcCreateMultiSigTest(BitcoinTestFramework):
1112
def set_test_params(self):
1213
self.setup_clean_chain = True
@@ -17,29 +18,29 @@ def skip_test_if_missing_module(self):
1718

1819
def get_keys(self):
1920
node0, node1, node2 = self.nodes
20-
self.add = [node1.getnewaddress() for _ in range(self.nkeys)]
21-
self.pub = [node1.getaddressinfo(a)["pubkey"] for a in self.add]
22-
self.priv = [node1.dumpprivkey(a) for a in self.add]
21+
add = [node1.getnewaddress() for _ in range(self.nkeys)]
22+
self.pub = [node1.getaddressinfo(a)["pubkey"] for a in add]
23+
self.priv = [node1.dumpprivkey(a) for a in add]
2324
self.final = node2.getnewaddress()
2425

2526
def run_test(self):
26-
node0,node1,node2 = self.nodes
27+
node0, node1, node2 = self.nodes
2728

2829
# 50 BTC each, rest will be 25 BTC each
2930
node0.generate(149)
3031
self.sync_all()
3132

3233
self.moved = 0
33-
for self.nkeys in [3,5]:
34-
for self.nsigs in [2,3]:
34+
for self.nkeys in [3, 5]:
35+
for self.nsigs in [2, 3]:
3536
for self.output_type in ["bech32", "p2sh-segwit", "legacy"]:
3637
self.get_keys()
3738
self.do_multisig()
3839

3940
self.checkbalances()
4041

4142
def checkbalances(self):
42-
node0,node1,node2 = self.nodes
43+
node0, node1, node2 = self.nodes
4344
node0.generate(100)
4445
self.sync_all()
4546

@@ -49,13 +50,13 @@ def checkbalances(self):
4950

5051
height = node0.getblockchaininfo()["blocks"]
5152
assert 150 < height < 350
52-
total = 149*50 + (height-149-100)*25
53+
total = 149 * 50 + (height - 149 - 100) * 25
5354
assert bal1 == 0
5455
assert bal2 == self.moved
55-
assert bal0+bal1+bal2 == total
56+
assert bal0 + bal1 + bal2 == total
5657

5758
def do_multisig(self):
58-
node0,node1,node2 = self.nodes
59+
node0, node1, node2 = self.nodes
5960

6061
msig = node2.createmultisig(self.nsigs, self.pub, self.output_type)
6162
madd = msig["address"]
@@ -74,7 +75,7 @@ def do_multisig(self):
7475
txid = node0.sendtoaddress(madd, 40)
7576

7677
tx = node0.getrawtransaction(txid, True)
77-
vout = [v["n"] for v in tx["vout"] if madd in v["scriptPubKey"].get("addresses",[])]
78+
vout = [v["n"] for v in tx["vout"] if madd in v["scriptPubKey"].get("addresses", [])]
7879
assert len(vout) == 1
7980
vout = vout[0]
8081
scriptPubKey = tx["vout"][vout]["scriptPubKey"]["hex"]
@@ -86,7 +87,7 @@ def do_multisig(self):
8687
outval = value - decimal.Decimal("0.00001000")
8788
rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}])
8889

89-
rawtx2 = node2.signrawtransactionwithkey(rawtx, self.priv[0:self.nsigs-1], prevtxs)
90+
rawtx2 = node2.signrawtransactionwithkey(rawtx, self.priv[0:self.nsigs - 1], prevtxs)
9091
rawtx3 = node2.signrawtransactionwithkey(rawtx2["hex"], [self.priv[-1]], prevtxs)
9192

9293
self.moved += outval
@@ -97,5 +98,6 @@ def do_multisig(self):
9798
txinfo = node0.getrawtransaction(tx, True, blk)
9899
self.log.info("n/m=%d/%d %s size=%d vsize=%d weight=%d" % (self.nsigs, self.nkeys, self.output_type, txinfo["size"], txinfo["vsize"], txinfo["weight"]))
99100

101+
100102
if __name__ == '__main__':
101103
RpcCreateMultiSigTest().main()

0 commit comments

Comments
 (0)