data: Data = Data(bytes(32), edPubKey) data.sign(edPrivKey) data.beat(dataFilter) transactions.add(data) packet: VerificationPacket = VerificationPacket(data.hash, [1]) blocks.append( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, packets=[VerificationPacket(data.hash, [1])], minerID=blsPrivKey).finish(0, merit).toJSON()) #Generate the SendDifficulty Block. blocks.append( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, elements=[SendDifficulty(0, 0, 1)], minerID=blsPrivKey).finish(0, merit).toJSON()) #Generate the DataDifficulty Block. blocks.append( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, elements=[DataDifficulty(0, 0, 1)], minerID=blsPrivKey).finish(0, merit).toJSON()) with open("e2e/Vectors/Consensus/HundredSix/BlockElements.json", "w") as vectors: vectors.write( json.dumps({ "blocks": blocks, "transactions": transactions.toJSON() }))
from typing import IO, Any import json from e2e.Classes.Consensus.DataDifficulty import DataDifficulty from e2e.Classes.Consensus.MeritRemoval import MeritRemoval from e2e.Vectors.Generation.PrototypeChain import PrototypeChain proto: PrototypeChain = PrototypeChain(25) proto.add(elements=[DataDifficulty(2, 0, 0)]) for _ in range(24): proto.add() proto.add(elements=[DataDifficulty(1, 1, 0)]) proto.add(elements=[ MeritRemoval(DataDifficulty(1, 1, 0), DataDifficulty(2, 1, 0), True) ]) for _ in range(50): proto.add() vectors: IO[Any] = open( "e2e/Vectors/Consensus/Difficulties/DataDifficulty.json", "w") vectors.write(json.dumps({"blockchain": proto.toJSON()})) vectors.close()
transactions.add(datas[-1]) datas.append(Data(datas[-1].hash, b'\0')) del datas[-1] merit.add( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, packets=[ VerificationPacket(claim.hash, [0]), VerificationPacket(send.hash, [0, 1, 2]), VerificationPacket(datas[0].hash, [0, 2]), VerificationPacket(datas[1].hash, [0, 1, 3]), VerificationPacket(datas[2].hash, [0, 1, 2, 3, 4]), VerificationPacket(datas[3].hash, [0, 1, 2, 3]) ], elements=[ DataDifficulty(8, 0, 3), SendDifficulty(1, 0, 0), DataDifficulty(4, 0, 3), DataDifficulty(1, 2, 4), SendDifficulty(3, 1, 4), SendDifficulty(2, 1, 2), DataDifficulty(7, 0, 0), ]).finish(0, merit)) with open("e2e/Vectors/RPC/Merit/GetBlock.json", "w") as vectors: vectors.write( json.dumps({ "blockchain": merit.toJSON(), "transactions": transactions.toJSON(), "claim": claim.toJSON(), "send": send.toJSON(),
import json from e2e.Classes.Consensus.SendDifficulty import SendDifficulty from e2e.Classes.Consensus.DataDifficulty import DataDifficulty from e2e.Classes.Merit.Merit import Merit from e2e.Vectors.Generation.PrototypeChain import PrototypeBlock, PrototypeChain merit: Merit = Merit.fromJSON(PrototypeChain(49).finish().toJSON()) #Add the Difficulties. merit.add( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, elements=[SendDifficulty(2, 0, 0), DataDifficulty(2, 1, 0)], minerID=0).finish(0, merit)) #Close out this, and the next, Checkpoint period to lock our Merit. for _ in range(9): merit.add( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, minerID=0).finish(0, merit)) #Become Pending. merit.add( PrototypeBlock(merit.blockchain.blocks[-1].header.time + 1200, minerID=0).finish(1, merit)) vectors: IO[Any] = open("e2e/Vectors/Consensus/Difficulties/LockedMerit.json", "w")
import json from e2e.Classes.Consensus.DataDifficulty import DataDifficulty from e2e.Vectors.Generation.PrototypeChain import PrototypeChain keepsUnlockedViaElements: PrototypeChain = PrototypeChain(1, False) for b in range(24): keepsUnlockedViaElements.add(elements=[DataDifficulty(b, b, 0)]) with open("e2e/Vectors/Merit/LockedMerit/KeepUnlocked.json", "w") as vectors: vectors.write( json.dumps( [PrototypeChain(25).toJSON(), keepsUnlockedViaElements.toJSON()]))
BlockHeader(0, blockchain.last(), BlockHeader.createContents([], elements), 1, bytes(4), BlockHeader.createSketchCheck(bytes(4), []), blsPrivKey.toPublicKey().serialize(), blockchain.blocks[-1].header.time + 1200), BlockBody([], elements, blsPrivKey.sign(b""))) #Mine it. block.mine(blsPrivKey, blockchain.difficulty()) #Add it to the vectors. blocks.append(block.toJSON()) print("Generated Hundred Six Block Elements SendDifficulty Block.") #Generate the DataDifficulty Block. elements = [] elements.append(DataDifficulty(0, 0, 1)) block = Block( BlockHeader(0, blockchain.last(), BlockHeader.createContents([], elements), 1, bytes(4), BlockHeader.createSketchCheck(bytes(4), []), blsPrivKey.toPublicKey().serialize(), blockchain.blocks[-1].header.time + 1200), BlockBody([], elements, blsPrivKey.sign(b""))) #Mine it. block.mine(blsPrivKey, blockchain.difficulty()) #Add it to the vectors. blocks.append(block.toJSON()) print("Generated Hundred Six Block Elements DataDifficulty Block.") result: Dict[str, Any] = {
import json from e2e.Classes.Consensus.DataDifficulty import DataDifficulty from e2e.Vectors.Generation.PrototypeChain import PrototypeChain proto: PrototypeChain = PrototypeChain(25) proto.add(elements=[DataDifficulty(2, 0, 0)]) for _ in range(24): proto.add() proto.add(elements=[DataDifficulty(1, 1, 0)]) proto.add(elements=[DataDifficulty(2, 1, 0)]) with open("e2e/Vectors/Consensus/Difficulties/DataDifficulty.json", "w") as vectors: vectors.write(json.dumps(proto.toJSON()))