Example #1
0
def SendDifficultyTest(rpc: RPC) -> None:
    file: IO[Any] = open(
        "e2e/Vectors/Consensus/Difficulties/SendDifficulty.json", "r")
    vectors: Dict[str, Any] = json.loads(file.read())
    file.close()

    #Verify functions.
    vddStarting: Callable[[], None] = lambda: verifySendDifficulty(rpc, 3)
    vddEarnedVote: Callable[[], None] = lambda: verifySendDifficulty(rpc, 2)
    vddVoted: Callable[[], None] = lambda: verifySendDifficulty(rpc, 1)

    def vmr() -> None:
        verifyMeritRemoval(rpc, 52, 52, 0, False)
        vddStarting()

    def vEarnedBack() -> None:
        vddEarnedVote()

    #Create and execute a Liver/Syncer.
    Liver(rpc,
          vectors["blockchain"],
          callbacks={
              26: vddStarting,
              50: vddEarnedVote,
              51: vddVoted,
              52: vmr,
              102: vEarnedBack
          }).live()
    Syncer(rpc, vectors["blockchain"]).sync()
Example #2
0
def SendDifficultyTest(rpc: RPC) -> None:
    #Verify functions.
    vddStarting: Callable[[], None] = lambda: verifySendDifficulty(rpc, 3)
    vddEarnedVote: Callable[[], None] = lambda: verifySendDifficulty(rpc, 2)
    vddVoted: Callable[[], None] = lambda: verifySendDifficulty(rpc, 1)

    def vmr() -> None:
        verifyMeritRemoval(rpc, 52, 52, 0, False)
        vddStarting()

    #Create and execute a Liver/Syncer.
    with open("e2e/Vectors/Consensus/Difficulties/SendDifficulty.json",
              "r") as file:
        vectors: List[Dict[str, Any]] = json.loads(file.read())
        Liver(rpc,
              vectors,
              callbacks={
                  26: vddStarting,
                  50: vddEarnedVote,
                  51: vddVoted,
                  52: vmr
              }).live()
        Syncer(rpc, vectors).sync()
Example #3
0
 def verifyCountedAndPending() -> None:
     if rpc.call("merit", "getMerit", {"nick": 0})["status"] != "Pending":
         raise Exception(INVALID_TEST)
     verifySendDifficulty(rpc, 2)
     verifyDataDifficulty(rpc, 2)
Example #4
0
 def verifyDiscountedAndLocked() -> None:
     if rpc.call("merit", "getMerit", {"nick": 0})["status"] != "Locked":
         raise Exception(INVALID_TEST)
     verifySendDifficulty(rpc, 3)
     verifyDataDifficulty(rpc, 5)
 def verifyVotedAndUnlocked() -> None:
     if rpc.call("merit", "getMerit", [0])["status"] != "Unlocked":
         raise Exception(INVALID_TEST)
     verifySendDifficulty(rpc, 2)
     verifyDataDifficulty(rpc, 2)