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)
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)
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)
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)
def testValidTransactionChain(Blockchain3Blocks): Blockchain.isValidTransactionChain(Blockchain3Blocks.chain)