args = parser.parse_args()
pnodes = args.p
topo = args.s
delay = args.d
total_nodes = pnodes if args.n == 0 else args.n
debug = args.v

testUtils.Utils.Debug = debug

Print("producing nodes:", pnodes, ", non-producing nodes: ",
      total_nodes - pnodes, ", topology:", topo,
      ", delay between nodes launch(seconds):", delay)

cluster = testUtils.Cluster()
walletMgr = testUtils.WalletMgr(False)
cluster.killall()
cluster.cleanup()
random.seed(1)  # Use a fixed seed for repeatability.

try:
    cluster.setWalletMgr(walletMgr)
    Print("Stand up cluster")
    if cluster.launch(pnodes, total_nodes, topo, delay) is False:
        errorExit("Failed to stand up betterchain cluster.")

    Print("Wait for Cluster stabilization")
    # wait for cluster to start producing blocks
    if not cluster.waitOnClusterBlockNumSync(3):
        errorExit("Cluster never stabilized")
Exemple #2
0
                    help="test lossy network",
                    action='store_true')
parser.add_argument("--stress_network",
                    help="test load/stress network",
                    action='store_true')
parser.add_argument("--not_kill_wallet",
                    help="not killing walletd",
                    action='store_true')

args = parser.parse_args()
enableMongo = False
defproduceraPrvtKey = args.defproducera_prvt_key
defproducerbPrvtKey = args.defproducerb_prvt_key

walletMgr = testUtils.WalletMgr(True,
                                port=args.wallet_port,
                                host=args.wallet_host)

if args.impaired_network:
    module = impaired_network.ImpairedNetwork()
elif args.lossy_network:
    module = lossy_network.LossyNetwork()
elif args.stress_network:
    module = p2p_stress.StressNetwork()
else:
    errorExit(
        "one of impaired_network, lossy_network or stress_network must be set. Please also check peer configs in p2p_test_peers.py."
    )

cluster = testUtils.Cluster(walletd=True,
                            enableMongo=enableMongo,
Exemple #3
0
def myTest(transWillEnterBlock):
    testSuccessful=False

    cluster=testUtils.Cluster(walletd=True, staging=True)
    walletMgr=testUtils.WalletMgr(True)

    try:
        cluster.killall()
        cluster.cleanup()
        walletMgr.killall()
        walletMgr.cleanup()

        pnodes=2
        total_nodes=pnodes
        topo="mesh"
        delay=0
        Print("Stand up cluster")
        if cluster.launch(pnodes, total_nodes, topo, delay) is False:
            error("Failed to stand up Enumivo cluster.")
            return False

        accounts=testUtils.Cluster.createAccountKeys(1)
        if accounts is None:
            error("FAILURE - create keys")
            return False
        currencyAccount=accounts[0]
        currencyAccount.name="currency"

        Print("Stand up walletd")
        if walletMgr.launch() is False:
            error("Failed to stand up Enumivo walletd.")
            return False

        testWalletName="test"
        Print("Creating wallet \"%s\"." % (testWalletName))
        testWallet=walletMgr.create(testWalletName)
        if testWallet is None:
            error("Failed to create wallet %s." % (testWalletName))
            return False

        for account in accounts:
            Print("Importing keys for account %s into wallet %s." % (account.name, testWallet.name))
            if not walletMgr.importKey(account, testWallet):
                error("Failed to import key for account %s" % (account.name))
                return False

        node=cluster.getNode(0)
        node2=cluster.getNode(1)
        if node is None or node2 is None:
            error("Cluster in bad state, received None node")
            return False

        initaAccount=testUtils.Cluster.initaAccount

        Print("Importing keys for account %s into wallet %s." % (initaAccount.name, testWallet.name))
        if not walletMgr.importKey(initaAccount, testWallet):
            error("Failed to import key for account %s" % (initaAccount.name))
            return False

        Print("Create new account %s via %s" % (currencyAccount.name, initaAccount.name))
        transId=node.createAccount(currencyAccount, initaAccount, stakedDeposit=5000, waitForTransBlock=True)
        if transId is None:
            error("Failed to create account %s" % (currencyAccount.name))
            return False

        wastFile="contracts/currency/currency.wast"
        abiFile="contracts/currency/currency.abi"
        Print("Publish contract")
        trans=node.publishContract(currencyAccount.name, wastFile, abiFile, waitForTransBlock=True)
        if trans is None:
            error("Failed to publish contract.")
            return False

        Print("push transfer action to currency contract")
        contract="currency"
        action="transfer"
        data="{\"from\":\"currency\",\"to\":\"inita\",\"quantity\":"
        if amINoon:
            data +="\"00.0050 CUR\",\"memo\":\"test\"}"
        else:
            data +="50}"
        opts="--permission currency@active"
        if not amINoon:
            opts += " --scope currency,inita"

        trans=node.pushMessage(contract, action, data, opts, silentErrors=True)
        transInBlock=False
        if not trans[0]:
            # On slower systems e.g Travis the transaction rejection can happen immediately
            #  We want to handle fast and slow failures.
            if "allocated processing time was exceeded" in trans[1]:
                Print("Push message transaction immediately failed.")
            else:
                error("Exception in push message. %s" % (trans[1]))
                return False

        else:
            transId=testUtils.Node.getTransId(trans[1])

            Print("verify transaction exists")
            if not node2.waitForTransIdOnNode(transId):
                error("Transaction never made it to node2")
                return False

            Print("Get details for transaction %s" % (transId))
            transaction=node2.getTransaction(transId)
            signature=transaction["transaction"]["signatures"][0]

            blockNum=int(transaction["transaction"]["ref_block_num"])
            blockNum += 1
            Print("Our transaction is in block %d" % (blockNum))

            block=node2.getBlock(blockNum)
            cycles=block["cycles"]
            if len(cycles) > 0:
                blockTransSignature=cycles[0][0]["user_input"][0]["signatures"][0]
                # Print("Transaction signature: %s\nBlock transaction signature: %s" %
                #       (signature, blockTransSignature))
                transInBlock=(signature == blockTransSignature)

        if transWillEnterBlock:
            if not transInBlock:
                error("Transaction did not enter the chain.")
                return False
            else:
                Print("SUCCESS: Transaction1 entered in the chain.")
        elif not transWillEnterBlock:
            if transInBlock:
                error("Transaction entered the chain.")
                return False
            else:
                Print("SUCCESS: Transaction2 did not enter the chain.")

        testSuccessful=True
    finally:
        if not testSuccessful and dumpErrorDetails:
            cluster.dumpErrorDetails()
            walletMgr.dumpErrorDetails()
            Print("== Errors see above ==")

        if killEnuInstances:
            Print("Shut down the cluster%s" % (" and cleanup." if (testSuccessful and not keepLogs) else "."))
            cluster.killall()
            walletMgr.killall()
            if testSuccessful and not keepLogs:
                Print("Cleanup cluster and wallet data.")
                cluster.cleanup()
                walletMgr.cleanup()

    return True
Exemple #4
0
nodesFile = args.nodes_file
seed = args.seed
dontKill = args.dont_kill
dumpErrorDetails = args.dump_error_details

killWallet = not dontKill
killEosInstances = not dontKill
if nodesFile is not None:
    killEosInstances = False

testUtils.Utils.Debug = debug
testSuccessful = False

random.seed(seed)  # Use a fixed seed for repeatability.
cluster = testUtils.Cluster(walletd=True)
walletMgr = testUtils.WalletMgr(True)

try:
    cluster.setWalletMgr(walletMgr)

    if nodesFile is not None:
        jsonStr = None
        with open(nodesFile, "r") as f:
            jsonStr = f.read()
        if not cluster.initializeNodesFromJson(jsonStr):
            errorExit("Failed to initilize nodes from Json string.")
        total_nodes = len(cluster.getNodes())
    else:
        cluster.killall()
        cluster.cleanup()
        walletMgr.killall()
Exemple #5
0
initaPrvtKey = args.inita_prvt_key
initbPrvtKey = args.initb_prvt_key
dumpErrorDetails = args.dump_error_details
keepLogs = args.keep_logs
dontLaunch = args.dont_launch
dontKill = args.dont_kill

testUtils.Utils.Debug = debug
localTest = True if server == LOCAL_HOST else False
# launcher launched bios node listens on port DEFAULT_PORT-100
cluster = testUtils.Cluster(walletd=True,
                            enableMongo=enableMongo,
                            initaPrvtKey=initaPrvtKey,
                            initbPrvtKey=initbPrvtKey,
                            port=DEFAULT_PORT - 100)
walletMgr = testUtils.WalletMgr(True, nodeosPort=DEFAULT_PORT - 100)
testSuccessful = False
killEosInstances = not dontKill
killWallet = not dontKill

WalletdName = "eos-walletd"
ClientName = "eosc"

if amINoon:
    WalletdName = "eosio-walletd"
    ClientName = "cleos"
    # noon branch requires longer mongo sync time.
    testUtils.Utils.setMongoSyncTime(50)
else:
    testUtils.Utils.iAmNotNoon()