mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
MOVEONLY: Move signrawtransactionwithwallet test
Put signrawtransactionwithwallet_tests in rpc_signrawtransaction.py, as the test is mainly testing the signrawtransaction RPC. Review with `git show --color-moved=dimmed-zebra`
This commit is contained in:
parent
1ab389b1ba
commit
e93046c10b
2 changed files with 51 additions and 50 deletions
|
@ -83,7 +83,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
self.getrawtransaction_tests()
|
||||
self.createrawtransaction_tests()
|
||||
self.signrawtransactionwithwallet_tests()
|
||||
self.sendrawtransaction_tests()
|
||||
self.sendrawtransaction_testmempoolaccept_tests()
|
||||
self.decoderawtransaction_tests()
|
||||
|
@ -259,55 +258,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.nodes[2].createrawtransaction(inputs=[{'txid': TXID, 'vout': 9}], outputs=[{address: 99}, {address2: 99}, {'data': '99'}]),
|
||||
)
|
||||
|
||||
def signrawtransactionwithwallet_tests(self):
|
||||
for type in ["bech32", "p2sh-segwit", "legacy"]:
|
||||
self.log.info(f"Test signrawtransactionwithwallet with missing prevtx info ({type})")
|
||||
addr = self.nodes[0].getnewaddress("", type)
|
||||
addrinfo = self.nodes[0].getaddressinfo(addr)
|
||||
pubkey = addrinfo["scriptPubKey"]
|
||||
inputs = [{'txid': TXID, 'vout': 3, 'sequence': 1000}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 1}
|
||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
|
||||
prevtx = dict(txid=TXID, scriptPubKey=pubkey, vout=3, amount=1)
|
||||
succ = self.nodes[0].signrawtransactionwithwallet(rawtx, [prevtx])
|
||||
assert succ["complete"]
|
||||
|
||||
if type == "legacy":
|
||||
del prevtx["amount"]
|
||||
succ = self.nodes[0].signrawtransactionwithwallet(rawtx, [prevtx])
|
||||
assert succ["complete"]
|
||||
else:
|
||||
assert_raises_rpc_error(-3, "Missing amount", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": TXID,
|
||||
"scriptPubKey": pubkey,
|
||||
"vout": 3,
|
||||
}
|
||||
])
|
||||
|
||||
assert_raises_rpc_error(-3, "Missing vout", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": TXID,
|
||||
"scriptPubKey": pubkey,
|
||||
"amount": 1,
|
||||
}
|
||||
])
|
||||
assert_raises_rpc_error(-3, "Missing txid", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"scriptPubKey": pubkey,
|
||||
"vout": 3,
|
||||
"amount": 1,
|
||||
}
|
||||
])
|
||||
assert_raises_rpc_error(-3, "Missing scriptPubKey", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": TXID,
|
||||
"vout": 3,
|
||||
"amount": 1
|
||||
}
|
||||
])
|
||||
|
||||
def sendrawtransaction_tests(self):
|
||||
self.log.info("Test sendrawtransaction with missing input")
|
||||
inputs = [{'txid': TXID, 'vout': 1}] # won't exist
|
||||
|
|
|
@ -334,6 +334,56 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
|||
assert_equal(signed["complete"], True)
|
||||
self.nodes[0].sendrawtransaction(signed["hex"])
|
||||
|
||||
def test_signing_with_missing_prevtx_info(self):
|
||||
txid = "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000"
|
||||
for type in ["bech32", "p2sh-segwit", "legacy"]:
|
||||
self.log.info(f"Test signing with missing prevtx info ({type})")
|
||||
addr = self.nodes[0].getnewaddress("", type)
|
||||
addrinfo = self.nodes[0].getaddressinfo(addr)
|
||||
pubkey = addrinfo["scriptPubKey"]
|
||||
inputs = [{'txid': txid, 'vout': 3, 'sequence': 1000}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 1}
|
||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
|
||||
prevtx = dict(txid=txid, scriptPubKey=pubkey, vout=3, amount=1)
|
||||
succ = self.nodes[0].signrawtransactionwithwallet(rawtx, [prevtx])
|
||||
assert succ["complete"]
|
||||
|
||||
if type == "legacy":
|
||||
del prevtx["amount"]
|
||||
succ = self.nodes[0].signrawtransactionwithwallet(rawtx, [prevtx])
|
||||
assert succ["complete"]
|
||||
else:
|
||||
assert_raises_rpc_error(-3, "Missing amount", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": txid,
|
||||
"scriptPubKey": pubkey,
|
||||
"vout": 3,
|
||||
}
|
||||
])
|
||||
|
||||
assert_raises_rpc_error(-3, "Missing vout", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": txid,
|
||||
"scriptPubKey": pubkey,
|
||||
"amount": 1,
|
||||
}
|
||||
])
|
||||
assert_raises_rpc_error(-3, "Missing txid", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"scriptPubKey": pubkey,
|
||||
"vout": 3,
|
||||
"amount": 1,
|
||||
}
|
||||
])
|
||||
assert_raises_rpc_error(-3, "Missing scriptPubKey", self.nodes[0].signrawtransactionwithwallet, rawtx, [
|
||||
{
|
||||
"txid": txid,
|
||||
"vout": 3,
|
||||
"amount": 1
|
||||
}
|
||||
])
|
||||
|
||||
def run_test(self):
|
||||
self.successful_signing_test()
|
||||
self.script_verification_error_test()
|
||||
|
@ -343,6 +393,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
|||
self.test_fully_signed_tx()
|
||||
self.test_signing_with_csv()
|
||||
self.test_signing_with_cltv()
|
||||
self.test_signing_with_missing_prevtx_info()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue