コード例 #1
0
def testisValidTransactionChainDuplicate(Blockchain3Blocks):
    transaction = Trasaction(Wallet(), 'recipient', 1).to_json()

    Blockchain3Blocks.addBlock([transaction, transaction])

    with pytest.raises(Exception, match='is not unique'):
        Blockchain.isValidTransactionChain(Blockchain3Blocks.chain)
コード例 #2
0
def testIsValidTransactionChainBadTransaction(Blockchain3Blocks):
    badTransaction = Trasaction(Wallet(), 'recipient', 1)
    badTransaction.input['signature'] = Wallet().sign(badTransaction.output)
    Blockchain3Blocks.addBlock([badTransaction.to_json()])

    with pytest.raises(Exception):
        Blockchain.isValidTransactionChain(Blockchain3Blocks)
コード例 #3
0
def testIsValidTransactionChainMultiRewards(Blockchain3Blocks):
    rewardOne = Trasaction.rewardTransaction(Wallet()).to_json()
    rewardTwo = Trasaction.rewardTransaction(Wallet()).to_json()

    Blockchain3Blocks.addBlock([rewardOne, rewardTwo])

    with pytest.raises(Exception, match='one mining reward per block'):
        Blockchain.isValidTransactionChain(Blockchain3Blocks.chain)
コード例 #4
0
def testIsValidTransactionChainBadHistoricBalance(Blockchain3Blocks):
    wallet = Wallet()
    badTransaction = Trasaction(wallet, 'recipient', 1)
    badTransaction.output[wallet.address] = 9000
    badTransaction.input['amount'] = 9001
    badTransaction.input['signature'] = wallet.sign(badTransaction.output)

    Blockchain3Blocks.addBlock([badTransaction.to_json()])

    with pytest.raises(Exception, match='has an invalid input amount'):
        Blockchain.isValidTransactionChain(Blockchain3Blocks.chain)
コード例 #5
0
def testValidTransactionChain(Blockchain3Blocks):
    Blockchain.isValidTransactionChain(Blockchain3Blocks.chain)