예제 #1
0
  def test_create_submit_work (self):
    """
    Test the creatework / submitwork method pair.
    """

    # Check for errors with wrong parameters.
    assert_raises_rpc_error (-1, None, self.nodes[0].creatework)
    assert_raises_rpc_error (-5, "Invalid coinbase payout address",
                             self.nodes[0].creatework,
                             "this_an_invalid_address")

    # Fix a coinbase address and construct methods for it.
    coinbaseAddr = self.nodes[0].getnewaddress ()
    def create ():
      return self.nodes[0].creatework (coinbaseAddr)
    submit = self.nodes[0].submitwork

    # Run common tests.
    self.test_common (create, submit)

    # Ensure that the payout address is the one which we specify
    hash1 = mineWorkBlockWithMethods (self.nodes[0], create, submit)
    hash2 = mineWorkBlockWithMethods (self.nodes[0], create, submit)
    addr1 = getCoinbaseAddr (self.nodes[0], hash1)
    addr2 = getCoinbaseAddr (self.nodes[0], hash2)
    assert_equal (addr1, coinbaseAddr)
    assert_equal (addr2, coinbaseAddr)

    # Ensure that different payout addresses will generate different auxblocks
    work1 = self.nodes[0].creatework (self.nodes[0].getnewaddress ())
    work2 = self.nodes[0].creatework (self.nodes[0].getnewaddress ())
    assert work1['hash'] != work2['hash']
예제 #2
0
    def test_create_submit_auxblock(self):
        """
    Test the createauxblock / submitauxblock method pair.
    """

        # Check for errors with wrong parameters.
        assert_raises_rpc_error(-1, None, self.nodes[0].createauxblock)
        assert_raises_rpc_error(-5, "Invalid coinbase payout address",
                                self.nodes[0].createauxblock,
                                "this_an_invalid_address")

        # Fix a coinbase address and construct methods for it.
        coinbaseAddr = self.nodes[0].getnewaddress()

        def create():
            return self.nodes[0].createauxblock(coinbaseAddr)

        submit = self.nodes[0].submitauxblock

        # Run common tests.
        self.test_common(create, submit)

        # Ensure that the payout address is the one which we specify
        hash1 = mineAuxpowBlockWithMethods(create, submit)
        hash2 = mineAuxpowBlockWithMethods(create, submit)
        self.sync_all()
        addr1 = getCoinbaseAddr(self.nodes[1], hash1)
        addr2 = getCoinbaseAddr(self.nodes[1], hash2)
        assert_equal(addr1, coinbaseAddr)
        assert_equal(addr2, coinbaseAddr)
예제 #3
0
  def test_create_submit_auxblock (self):
    """
    Test the createauxblock / submitauxblock method pair.
    """

    # Check for errors with wrong parameters.
    assert_raises_rpc_error (-1, None, self.nodes[0].createauxblock)
    assert_raises_rpc_error (-5, "Invalid coinbase payout address",
                             self.nodes[0].createauxblock,
                             "this_an_invalid_address")

    # Fix a coinbase address and construct methods for it.
    coinbaseAddr = self.nodes[0].getnewaddress ()
    def create ():
      return self.nodes[0].createauxblock (coinbaseAddr)
    submit = self.nodes[0].submitauxblock

    # Run common tests.
    self.test_common (create, submit)

    # Ensure that the payout address is the one which we specify
    hash1 = mineAuxpowBlockWithMethods (create, submit)
    hash2 = mineAuxpowBlockWithMethods (create, submit)
    self.sync_all ()
    addr1 = getCoinbaseAddr (self.nodes[1], hash1)
    addr2 = getCoinbaseAddr (self.nodes[1], hash2)
    assert_equal (addr1, coinbaseAddr)
    assert_equal (addr2, coinbaseAddr)
예제 #4
0
    def test_getwork(self):
        """
    Test the getwork method.
    """

        create = self.nodes[0].getwork
        submit = self.nodes[0].getwork
        self.test_common(create, submit)

        # Ensure that the payout address is changed from one block to the next.
        hash1 = mineWorkBlockWithMethods(self.nodes[0], create, submit)
        hash2 = mineWorkBlockWithMethods(self.nodes[0], create, submit)
        addr1 = getCoinbaseAddr(self.nodes[0], hash1)
        addr2 = getCoinbaseAddr(self.nodes[0], hash2)
        assert addr1 != addr2
        info = self.nodes[0].getaddressinfo(addr1)
        assert info['ismine']
        info = self.nodes[0].getaddressinfo(addr2)
        assert info['ismine']
예제 #5
0
  def test_getauxblock (self):
    """
    Test the getauxblock method.
    """

    create = self.nodes[0].getauxblock
    submit = self.nodes[0].getauxblock
    self.test_common (create, submit)

    # Ensure that the payout address is changed from one block to the next.
    hash1 = mineAuxpowBlockWithMethods (create, submit)
    hash2 = mineAuxpowBlockWithMethods (create, submit)
    self.sync_all ()
    addr1 = getCoinbaseAddr (self.nodes[1], hash1)
    addr2 = getCoinbaseAddr (self.nodes[1], hash2)
    assert addr1 != addr2
    info = self.nodes[0].getaddressinfo (addr1)
    assert info['ismine']
    info = self.nodes[0].getaddressinfo (addr2)
    assert info['ismine']
예제 #6
0
    def test_create_submit_auxblock(self):
        """
    Test the createauxblock / submitauxblock method pair.
    """

        # Check for errors with wrong parameters.
        assert_raises_rpc_error(-1, None, self.nodes[0].createauxblock)
        assert_raises_rpc_error(-5, "Invalid coinbase payout address",
                                self.nodes[0].createauxblock,
                                "this_an_invalid_address")

        # Fix a coinbase address and construct methods for it.
        coinbaseAddr = "TDv1D3WV2gFK87ucb8bDG7KGjNh5HCPZPi"

        def create():
            return self.nodes[0].createauxblock(coinbaseAddr)

        submit = self.nodes[0].submitauxblock

        # Run common tests.
        self.test_common(create, submit)

        # Ensure that the payout address is the one which we specify
        hash1 = mineAuxpowBlockWithMethods(create, submit)
        hash2 = mineAuxpowBlockWithMethods(create, submit)
        self.sync_all()
        addr1 = getCoinbaseAddr(self.nodes[1], hash1)
        addr2 = getCoinbaseAddr(self.nodes[1], hash2)
        assert_equal(addr1, coinbaseAddr)
        assert_equal(addr2, coinbaseAddr)

        # Ensure that different payout addresses will generate different auxblocks
        auxblock1 = self.nodes[0].createauxblock(
            "TMyMSQpgJR4QL6z6u5zz2dLWudi1x5Fobw")
        auxblock2 = self.nodes[0].createauxblock(
            "THG2uNG2VASsFWK4DmpZZpkwKtC5Qjkyoo")
        assert auxblock1['hash'] != auxblock2['hash']
예제 #7
0
    def test_create_submit_auxblock(self):
        """
    Test the createauxblock / submitauxblock method pair.
    """

        # Check for errors with wrong parameters.
        assert_raises_rpc_error(-1, None, self.nodes[0].createauxblock)
        assert_raises_rpc_error(-5, "Invalid coinbase payout address",
                                self.nodes[0].createauxblock,
                                "this_an_invalid_address")

        # Fix a coinbase address and construct methods for it.
        addr1 = self.nodes[0].get_deterministic_priv_key().address

        def create():
            return self.nodes[0].createauxblock(addr1)

        submit = self.nodes[0].submitauxblock

        # Run common tests.
        self.test_common(create, submit)

        # Ensure that the payout address is the one which we specify
        hash1 = mineAuxpowBlockWithMethods(create, submit)
        hash2 = mineAuxpowBlockWithMethods(create, submit)
        self.sync_all()
        actual1 = getCoinbaseAddr(self.nodes[1], hash1)
        actual2 = getCoinbaseAddr(self.nodes[1], hash2)
        assert_equal(actual1, addr1)
        assert_equal(actual2, addr1)

        # Ensure that different payout addresses will generate different auxblocks
        addr2 = self.nodes[1].get_deterministic_priv_key().address
        auxblock1 = self.nodes[0].createauxblock(addr1)
        auxblock2 = self.nodes[0].createauxblock(addr2)
        assert auxblock1['hash'] != auxblock2['hash']