Esempio n. 1
0
    def receiveMeritRemoval() -> None:
        #We should receive a MeritRemoval, which is partial.
        #The unsigned Element should be the Block's DataDifficulty.
        #The signed Element should be the mempool's DataDifficulty.
        if rpc.meros.live.recv() != (
                MessageType.SignedMeritRemoval.toByte() + PartialMeritRemoval(
                    blockchainDataDiff, mempoolDataDiff, 0).signedSerialize()):
            raise TestError("Meros didn't create the partial Merit Removal.")

        #Verify Meros didn't just broadcast it, yet also added it.
        verifyMeritRemoval(rpc, 1, 1, 0, False)
Esempio n. 2
0
block = Block(
    BlockHeader(0, blockchain.last(),
                BlockHeader.createContents([], [sendDiff]), 1, bytes(4),
                bytes(32), 0, blockchain.blocks[-1].header.time + 1200),
    BlockBody([], [sendDiff], sendDiff.signature))
#Mine it.
block.mine(blsPrivKey, blockchain.difficulty())

#Add it.
blockchain.add(block)
print("Generated SendDifficulty Block " + str(len(blockchain.blocks)) + ".")

#Create a MeritRemoval by reusing a nonce.
competing: SignedSendDifficulty = SignedSendDifficulty(0, 1)
competing.sign(0, blsPrivKey)
mr: PartialMeritRemoval = PartialMeritRemoval(sendDiff, competing)

#Generate a Block containing the MeritRemoval.
block = Block(
    BlockHeader(0, blockchain.last(), BlockHeader.createContents([], [mr]), 1,
                bytes(4), bytes(32), 0,
                blockchain.blocks[-1].header.time + 1200),
    BlockBody([], [mr], mr.signature))
#Mine it.
block.mine(blsPrivKey, blockchain.difficulty())

#Add it.
blockchain.add(block)
print("Generated SendDifficulty Block " + str(len(blockchain.blocks)) + ".")

#Mine another 50 Blocks.
Esempio n. 3
0
                BlockHeader.createContents([], [dataDiff]), 1, bytes(4),
                bytes(32), 0, blockchain.blocks[-1].header.time + 1200),
    BlockBody([], [dataDiff], dataDiff.signature))
#Mine it.
block.mine(blsPrivKey, blockchain.difficulty())

#Add it.
blockchain.add(block)
print("Generated Repeat Block " + str(len(blockchain.blocks)) + ".")

#Create a conflicting DataDifficulty with the same nonce.
dataDiffConflicting = SignedDataDifficulty(1, 0)
dataDiffConflicting.sign(0, blsPrivKey)

#Create a MeritRemoval out of the two of them.
mr: PartialMeritRemoval = PartialMeritRemoval(dataDiff, dataDiffConflicting)

#Generate a Block containing the MeritRemoval.
block = Block(
    BlockHeader(0, blockchain.last(), BlockHeader.createContents([], [mr]), 1,
                bytes(4), bytes(32), 0,
                blockchain.blocks[-1].header.time + 1200),
    BlockBody([], [mr], mr.signature))
#Mine it.
block.mine(blsPrivKey, blockchain.difficulty())

#Add it.
blockchain.add(block)
print("Generated Repeat Block " + str(len(blockchain.blocks)) + ".")

#Generate another Block containing the MeritRemoval.
Esempio n. 4
0
    bytes(4),
    bytes(32),
    0,
    blockchain.blocks[-1].header.time + 1200
  ),
  BlockBody([], [dataDiffs[0]], dataDiffs[0].signature)
)
#Mine it.
block.mine(blsPrivKey, blockchain.difficulty())

#Add it.
blockchain.add(block)
print("Generated Hundred Twenty Three Partial Block " + str(len(blockchain.blocks)) + ".")

#Create a partial MeritRemoval out of the conflicting Data Difficulties.
partial: PartialMeritRemoval = PartialMeritRemoval(dataDiffs[0], dataDiffs[1])

#Generate a Block containing the partial MeritRemoval.
block = Block(
  BlockHeader(
    0,
    blockchain.last(),
    BlockHeader.createContents([], [partial]),
    1,
    bytes(4),
    bytes(32),
    0,
    blockchain.blocks[-1].header.time + 1200
  ),
  BlockBody([], [partial], partial.signature)
)