Exemplo n.º 1
0
    try:
        pegtxid = sidechain.claimpegin(raw, proof, sidechain.getnewaddress())
        raise Exception("Peg-in with non-matching address should fail.")
    except JSONRPCException:
        pass

    timeout = 20
    # Should succeed via wallet lookup for address match
    pegtxid = sidechain.claimpegin(raw, proof)
    while len(sidechain.getrawmempool()) != len(sidechain2.getrawmempool()):
        time.sleep(1)
        timeout -= 1
        if timeout == 0:
            raise Exception("Peg-in has failed to propagate.")
    sidechain2.generate(1)
    while sidechain.getblockcount() != sidechain2.getblockcount():
        time.sleep(1)
        timeout -= 1
        if timeout == 0:
            raise Exception("Blocks are not propagating.")

    tx = sidechain.gettransaction(pegtxid)

    if "confirmations" in tx and tx["confirmations"] > 0:
        print("Peg-in is confirmed: Success!")
    else:
        raise Exception("Peg-in confirmation has failed.")

except JSONRPCException as e:
    print("Pegging testing failed, aborting:")
    print(e.error)
Exemplo n.º 2
0
    assert pegout_tested

    print ("Now test failure to validate peg-ins based on intermittant bitcoind rpc failure")
    bitcoin2.stop()
    # give bitcoin2 time to stop
    time.sleep(1)
    txid = bitcoin.sendtoaddress(addrs["mainchain_address"], 1)
    bitcoin.generate(12)
    proof = bitcoin.gettxoutproof([txid])
    raw = bitcoin.getrawtransaction(txid)
    stuck_peg = sidechain.claimpegin(raw, proof)
    sidechain.generate(1)
    print("Waiting to ensure block is being rejected by sidechain2")
    time.sleep(5)

    assert(sidechain.getblockcount() != sidechain2.getblockcount())

    bitcoind2start = bitcoin_bin_path+"/bitcoind -datadir="+bitcoin2_datadir
    subprocess.Popen(bitcoind2start.split(), stdout=subprocess.PIPE)
    print("Restarting bitcoind2")
    time.sleep(5)
    with open(bitcoin2_rpccookiefile, 'r') as f:
        bitcoin2_rpccookie = f.readline()
    bitcoin2 = AuthServiceProxy("http://"+ bitcoin2_rpccookie +"@127.0.0.1:"+str(bitcoin2_port))

    # Don't make a block, race condition when pegin-invalid block
    # is awaiting further validation, nodes reject subsequent blocks
    # even ones they create
    sync_all(sidechain, sidechain2, False)
    print("Now send funds out in two stages, partial, and full")
    some_btc_addr = bitcoin.getnewaddress()