def verifyBlockchain(rpc: RPC, blockchain: Blockchain) -> None: sleep(2) if rpc.call("merit", "getHeight") != len(blockchain.blocks): raise TestError("Height doesn't match.") if blockchain.difficulty() != rpc.call("merit", "getDifficulty"): raise TestError("Difficulty doesn't match.") for b in range(len(blockchain.blocks)): ourBlock: Dict[str, Any] = blockchain.blocks[b].toJSON() #Info Python saves so it can properly load from the vectors yet the Meros RPC excludes. del ourBlock["header"]["packets"] blockJSON: Dict[str, Any] = rpc.call("merit", "getBlock", [b]) #Contextual info Python doesn't track. del blockJSON["removals"] if blockJSON != ourBlock: raise TestError("Block doesn't match.") #Test when indexing by the hash instead of the nonce. blockJSON = rpc.call("merit", "getBlock", [blockchain.blocks[b].header.hash.hex().upper()]) del blockJSON["removals"] if blockJSON != ourBlock: raise TestError("Block doesn't match.")
def verifyBlockchain( rpc: RPC, blockchain: Blockchain ) -> None: sleep(2) if rpc.call("merit", "getHeight") != len(blockchain.blocks): raise TestError("Height doesn't match.") if blockchain.difficulty() != rpc.call("merit", "getDifficulty"): raise TestError("Difficulty doesn't match.") for b in range(len(blockchain.blocks)): ourBlock: Dict[str, Any] = blockchain.blocks[b].toJSON() blockJSON: Dict[str, Any] = rpc.call("merit", "getBlock", {"block": b}) #Contextual info Python doesn't track. del blockJSON["removals"] if blockJSON != ourBlock: raise TestError("Block doesn't match.") #Test when indexing by the hash instead of the nonce. blockJSON = rpc.call( "merit", "getBlock", {"block": blockchain.blocks[b].header.hash.hex().upper()} ) del blockJSON["removals"] if blockJSON != ourBlock: raise TestError("Block doesn't match.")
def verifyBlockchain( rpc: RPC, blockchain: Blockchain ) -> None: #Sleep to ensure data races aren't a problem. sleep(2) #Verify the height. if rpc.call("merit", "getHeight") != len(blockchain.blocks): raise TestError("Height doesn't match.") #Verify the difficulty. if blockchain.difficulty() != int(rpc.call("merit", "getDifficulty"), 16): raise TestError("Difficulty doesn't match.") #Verify the Blocks. for b in range(len(blockchain.blocks)): if rpc.call("merit", "getBlock", [b]) != blockchain.blocks[b].toJSON(): raise TestError("Block doesn't match.") if rpc.call( "merit", "getBlock", [blockchain.blocks[b].header.hash.hex().upper()] ) != blockchain.blocks[b].toJSON(): raise TestError("Block doesn't match.")
def verifyBlockchain(rpc: RPC, blockchain: Blockchain) -> None: sleep(2) if rpc.call("merit", "getHeight") != len(blockchain.blocks): raise TestError("Height doesn't match.") if blockchain.difficulty() != int(rpc.call("merit", "getDifficulty"), 16): raise TestError("Difficulty doesn't match.") for b in range(len(blockchain.blocks)): if rpc.call("merit", "getBlock", [b]) != blockchain.blocks[b].toJSON(): raise TestError("Block doesn't match.") if rpc.call("merit", "getBlock", [blockchain.blocks[b].header.hash.hex().upper() ]) != blockchain.blocks[b].toJSON(): raise TestError("Block doesn't match.")