コード例 #1
0
    def test_multisig_to_redeemscript_incorrect_length(self):
        public_keys_invalid = [b'\x00' * 32, b'\x00' * 33]
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys_invalid, 2)

        public_keys_invalid = [b'\x00' * 66, b'\x00' * 65]
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys_invalid, 2)
コード例 #2
0
    def test_multisig_to_redeemscript(self):
        public_keys = [b'\x00' * 33, b'\x00' * 33]
        assert multisig_to_redeemscript(
            public_keys, 2) == b'R!' + b'!'.join(public_keys) + b'R\xae'

        public_keys = [b'\x00' * 65, b'\x00' * 65]
        assert multisig_to_redeemscript(
            public_keys, 2) == b'RA' + b'A'.join(public_keys) + b'R\xae'
コード例 #3
0
    def test_multisig_to_redeemscript_too_long(self):
        # Maximum is 15 compressed keys in a multisig:
        try:
            public_keys = [b'\x00' * 33] * 15
            multisig_to_redeemscript(public_keys, 1)
        except ValueError:  # pragma: no cover
            pytest.fail(
                "multisig_to_redeemscript did not accept 15 compressed public keys."
            )

        public_keys = [b'\x00' * 33] * 16
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys, 1)

        # Maximum is 7 uncompressed keys in a multisig
        try:
            public_keys = [b'\x00' * 65] * 7
            multisig_to_redeemscript(public_keys, 1)
        except ValueError:  # pragma: no cover
            pytest.fail(
                "multisig_to_redeemscript did not accept 7 uncompressed public keys."
            )

        public_keys = [b'\x00' * 65] * 8
        with pytest.raises(ValueError):
            multisig_to_redeemscript(public_keys, 1)
コード例 #4
0
 def test_multisig_to_redeemscript_wrong_m(self):
     public_keys_invalid = [b'\x00' * 33, b'\x00' * 33]
     with pytest.raises(ValueError):
         multisig_to_redeemscript(public_keys_invalid, 3)