|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2017-2018 The Bitcoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | +"""Test external signer. |
| 6 | +
|
| 7 | +Verify that a bitcoind node can use an external signer command |
| 8 | +""" |
| 9 | +import os |
| 10 | +import platform |
| 11 | + |
| 12 | +from test_framework.test_framework import BitcoinTestFramework |
| 13 | +from test_framework.util import ( |
| 14 | + assert_equal, |
| 15 | + assert_raises_rpc_error, |
| 16 | +) |
| 17 | + |
| 18 | + |
| 19 | +class SignerTest(BitcoinTestFramework): |
| 20 | + def mock_signer_path(self): |
| 21 | + path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'mocks', 'signer.py') |
| 22 | + if platform.system() == "Windows": |
| 23 | + return "py " + path |
| 24 | + else: |
| 25 | + return path |
| 26 | + |
| 27 | + def set_test_params(self): |
| 28 | + self.num_nodes = 3 |
| 29 | + |
| 30 | + self.extra_args = [ |
| 31 | + [], |
| 32 | + [f"-signer={self.mock_signer_path()}", '-keypool=10'], |
| 33 | + [f"-signer={self.mock_signer_path()}", '-keypool=10'], |
| 34 | + ["-signer=fake.py"], |
| 35 | + ] |
| 36 | + |
| 37 | + def skip_test_if_missing_module(self): |
| 38 | + self.skip_if_no_wallet() |
| 39 | + self.skip_if_no_external_signer() |
| 40 | + |
| 41 | + def set_mock_result(self, node, res): |
| 42 | + with open(os.path.join(node.cwd, "mock_result"), "w", encoding="utf8") as f: |
| 43 | + f.write(res) |
| 44 | + |
| 45 | + def clear_mock_result(self, node): |
| 46 | + os.remove(os.path.join(node.cwd, "mock_result")) |
| 47 | + |
| 48 | + def run_test(self): |
| 49 | + self.log.debug(f"-signer={self.mock_signer_path()}") |
| 50 | + |
| 51 | +if __name__ == '__main__': |
| 52 | + SignerTest().main() |
0 commit comments