def test_multisig_one_at_a_time(self):
    M = 3
    N = 3
    keys = [Key(secret_exponent=i, generator=secp256k1_generator) for i in range(1, (N + 2))]
    tx_in = TxIn.coinbase_tx_in(script=b'')
    script = script_for_multisig(m=M, sec_keys=[key.sec() for key in keys[:N]])
    tx_out = TxOut(1000000, script)
    tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
    tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [keys[(- 1)].address()])
    ids = ['403e5bfc59e097bb197bf77a692d158dd3a4f7affb4a1fa41072dafe7bec7058', '5931d9995e83721243dca24772d7012afcd4378996a8b953c458175f15a544db', '9bb4421088190bbbb5b42a9eaa9baed7ec7574a407c25f71992ba56ca43d9c44', '03a1dc2a63f93a5cf5a7cb668658eb3fc2eda88c06dc287b85ba3e6aff751771']
    for i in range(1, (N + 1)):
        self.assertEqual(tx2.bad_solution_count(), 1)
        self.assertEqual(tx2.id(), ids[(i - 1)])
        hash160_lookup = build_hash160_lookup((key.secret_exponent() for key in keys[(i - 1):i]), [secp256k1_generator])
        tx2.sign(hash160_lookup=hash160_lookup)
        self.assertEqual(tx2.id(), ids[i])
    self.assertEqual(tx2.bad_solution_count(), 0)
def test_multisig_one_at_a_time(self):
    M = 3
    N = 3
    keys = [Key(secret_exponent=i, generator=secp256k1_generator) for i in range(1, (N + 2))]
    tx_in = TxIn.coinbase_tx_in(script=b)
    script = script_for_multisig(m=M, sec_keys=[key.sec() for key in keys[:N]])
    tx_out = TxOut(1000000, script)
    tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out])
    tx2 = tx_utils.create_tx(tx1.tx_outs_as_spendable(), [keys[(- 1)].address()])
    ids = ['403e5bfc59e097bb197bf77a692d158dd3a4f7affb4a1fa41072dafe7bec7058', '5931d9995e83721243dca24772d7012afcd4378996a8b953c458175f15a544db', '9bb4421088190bbbb5b42a9eaa9baed7ec7574a407c25f71992ba56ca43d9c44', '03a1dc2a63f93a5cf5a7cb668658eb3fc2eda88c06dc287b85ba3e6aff751771']
    for i in range(1, (N + 1)):
        self.assertEqual(tx2.bad_solution_count(), 1)
        self.assertEqual(tx2.id(), ids[(i - 1)])
        hash160_lookup = build_hash160_lookup((key.secret_exponent() for key in keys[(i - 1):i]), [secp256k1_generator])
        tx2.sign(hash160_lookup=hash160_lookup)
        self.assertEqual(tx2.id(), ids[i])
    self.assertEqual(tx2.bad_solution_count(), 0)