Skip to content

Commit e2779ce

Browse files
committed
test: cover more errors for signrawtransactionwithkey RPC
* Invalid private key * TX decode failed
1 parent a7bc9b7 commit e2779ce

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/rpc_signrawtransactionwithkey.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,20 @@ def invalid_sighashtype_test(self):
126126
privkeys = [self.nodes[0].get_deterministic_priv_key().key]
127127
assert_raises_rpc_error(-8, "'all' is not a valid sighash parameter.", self.nodes[0].signrawtransactionwithkey, tx, privkeys, sighashtype="all")
128128

129+
def invalid_private_key_and_tx(self):
130+
self.log.info("Test signing transaction with an invalid private key")
131+
tx = self.nodes[0].createrawtransaction(INPUTS, OUTPUTS)
132+
privkeys = ["123"]
133+
assert_raises_rpc_error(-5, "Invalid private key", self.nodes[0].signrawtransactionwithkey, tx, privkeys)
134+
self.log.info("Test signing transaction with an invalid tx hex")
135+
privkeys = [self.nodes[0].get_deterministic_priv_key().key]
136+
assert_raises_rpc_error(-22, "TX decode failed. Make sure the tx has at least one input.", self.nodes[0].signrawtransactionwithkey, tx + "00", privkeys)
137+
129138
def run_test(self):
130139
self.successful_signing_test()
131140
self.witness_script_test()
132141
self.invalid_sighashtype_test()
142+
self.invalid_private_key_and_tx()
133143

134144

135145
if __name__ == '__main__':

0 commit comments

Comments
 (0)