Esempio n. 1
0
def test(testfilter):
    global datadir, datadir2

    _lib.StartTestGroup("SQL Sync with Proxy")

    _lib.CleanTestFolders()

    datadir = _lib.CreateTestFolder('_1_')

    startnode.StartNodeWithoutBlockchain(datadir)

    address = startnode.InitBockchain(datadir)
    _complex.AddProxyToConfig(datadir, "localhost:40041")
    _complex.AddInternalKeyToConfig(datadir, address)  # init internal signing

    startnode.StartNode(datadir, address, '30000')

    _lib.StartTestGroup("Do transactions")

    transactions.GetUnapprovedTransactionsEmpty(datadir)

    _sql.ExecuteSQLOnProxy(
        datadir,
        "CREATE TABLE test (a INT auto_increment PRIMARY KEY, b VARCHAR(20))")

    # check new table exists
    tables = _lib.DBGetRows(datadir, "SHOW TABLES", True)
    found = False
    for table in tables:
        if table[0] == "test":
            found = True
            break

    _lib.FatalAssert(found, "Table not found in the DB")

    blocks = _blocks.WaitBlocks(datadir, 2)
    time.sleep(2)

    _sql.ExecuteSQLOnProxy(datadir, "INSERT INTO test SET b='row1'")
    _sql.ExecuteSQLOnProxy(datadir, "INSERT INTO test SET a=2,b='row2'")
    time.sleep(1)
    _sql.ExecuteSQLOnProxy(datadir, "INSERT INTO test (b) VALUES ('row3')")

    rows = _lib.DBGetRows(datadir, "SELECT * FROM test", True)

    _lib.FatalAssert(len(rows) == 3, "Must be 3 rows in a table")

    blocks = _blocks.WaitBlocks(datadir, 3)

    time.sleep(2)  # while all caches are cleaned

    txlist = transactions.GetUnapprovedTransactions(datadir)

    _lib.FatalAssert(len(txlist) == 1, "Should be 1 unapproved transaction")

    # update data
    _sql.ExecuteSQLOnProxy(datadir,
                           " update test SET b=\"row3 updated\" where a=3")
    _sql.ExecuteSQLOnProxy(
        datadir, " update test SET b=\"row2 updated\" where a = '2'")

    blocks = _blocks.WaitBlocks(datadir, 4)
    time.sleep(1)  # while all caches are cleaned

    rows = _lib.DBGetRows(datadir, "SELECT * FROM test", True)
    for row in rows:
        if row[0] == "1":
            _lib.FatalAssert(row[1] == "row1",
                             "Row 1 value is wrong. Got: " + row[1])

        if row[0] == "2":
            _lib.FatalAssert(row[1] == "row2 updated",
                             "Row 2 value is wrong. Got: " + row[1])

        if row[0] == "3":
            _lib.FatalAssert(row[1] == "row3 updated",
                             "Row 3 value is wrong. Got: " + row[1])

    _sql.ExecuteSQLOnProxyFail(datadir, "INSERT INTO test SET a=2,b='row2'")

    _sql.ExecuteSQLOnProxy(datadir, " DELETE  from   test where a=3")

    rows = _lib.DBGetRows(datadir, "SELECT * FROM test", True)
    _lib.FatalAssert(len(rows) == 2, "Must be 2 rows in a table")

    datadir2 = _lib.CreateTestFolder('_2_')

    address2 = initblockchain.ImportBockchain(datadir2, "localhost", '30000')

    _complex.AddProxyToConfig(datadir2, "localhost:40042")
    _complex.AddInternalKeyToConfig(datadir2,
                                    address2)  # init internal signing

    startnode.StartNode(datadir2, address2, '30001', "Server 2")
    blocks = _blocks.WaitBlocks(datadir2, 4)

    # Send money to new node address
    txid1 = _transfers.Send(datadir, address, address2, 1)

    time.sleep(2)

    # must be 2 delete transaction should be imported
    rows = _lib.DBGetRows(datadir2, "SELECT * FROM test", True)

    _lib.FatalAssert(len(rows) == 2, "Must be 2 rows in a table")

    _sql.ExecuteSQLOnProxy(datadir, " DELETE  from   test where a=2")

    # send money again
    txid2 = _transfers.Send(datadir, address, address2, 1)

    # should be 1 row on first node
    rows = _lib.DBGetRows(datadir, "SELECT * FROM test", True)
    _lib.FatalAssert(len(rows) == 1, "Must be 1 rows in a table")

    time.sleep(1)  # give time to send transaction
    # and 2 row on second
    rows = _lib.DBGetRows(datadir2, "SELECT * FROM test", True)
    _lib.FatalAssert(len(rows) == 1, "Must be 1 rows in a table")

    blocks = _blocks.WaitBlocks(datadir, 5)
    blocks = _blocks.WaitBlocks(datadir2, 5)
    time.sleep(2)

    # send money back

    txid3 = _transfers.Send(datadir2, address2, address, 2)
    time.sleep(1)
    # insert on second node. check on first
    _sql.ExecuteSQLOnProxy(datadir2, "INSERT INTO test SET a=2,b='row2'")

    time.sleep(3)  # give time to send transaction

    rows = _lib.DBGetRows(datadir, "SELECT * FROM test", True)

    _lib.FatalAssert(len(rows) == 2, "Must be 2 rows in a table")

    # check balances
    bal1 = _transfers.GetBalance(datadir, address)
    bal2 = _transfers.GetBalance(datadir2, address2)

    _lib.FatalAssert(bal2[2] == -2,
                     "Pending balance should be -2 for second address")
    _lib.FatalAssert(bal1[2] == 2,
                     "Pending balance should be 2 for first address")

    startnode.StopNode(datadir)
    datadir = ""

    startnode.StopNode(datadir2)
    datadir2 = ""

    #_lib.RemoveTestFolder(datadir)
    _lib.EndTestGroupSuccess()
Esempio n. 2
0
def test(testfilter):
    global datadir

    nodeport = '30000'

    _lib.StartTestGroup("Wallet Balance")

    _lib.CleanTestFolders()

    datadir_tmp = CopyBlockchainWithBlocks()

    balances = _transfers.GetGroupBalance(datadir_tmp)

    address1 = balances.keys()[0]
    address1_2 = balances.keys()[1]
    address1_3 = balances.keys()[2]

    balance = _transfers.GetBalance(datadir_tmp, address1)

    _lib.FatalAssert(balance[0] == balances[address1][0],
                     "Balance is different from group result")
    # address1_3 becomes a minter. we will send money from other 2 and this will receive rewards
    startnode.StartNode(datadir_tmp, address1_3, nodeport)
    datadir = datadir_tmp

    blocks = _blocks.GetBlocks(datadir)
    blockslen = len(blocks)

    #create 2 wallet locations and 2 wallets in each of them
    walletdatadir1 = _lib.CreateTestFolder("wallet")
    walletdatadir2 = _lib.CreateTestFolder("wallet")

    addresses = _wallet.GetWallets(walletdatadir2)

    _lib.FatalAssert(len(addresses) == 0, "Expected 0 wallets")

    waddress1_1 = _wallet.CreateWallet(walletdatadir1)
    waddress1_2 = _wallet.CreateWallet(walletdatadir1)

    waddress2_1 = _wallet.CreateWallet(walletdatadir2)
    waddress2_2 = _wallet.CreateWallet(walletdatadir2)

    addresses = _wallet.GetWallets(walletdatadir2)

    _lib.FatalAssert(len(addresses) == 2, "Expected 2 wallets")

    addresses = _wallet.GetWallets(walletdatadir1)

    _lib.FatalAssert(
        len(addresses) == 2, "Expected 2 wallets for second folder")

    #send some funds to all that wallets
    amounttosend = "%.8f" % round(balances[address1][0] / 8, 8)

    # for next block minimum 6 TXt are required
    _transfers.Send(datadir, address1, waddress1_1, amounttosend)
    tx2_1 = _transfers.Send(datadir, address1, waddress1_2, amounttosend)
    _transfers.Send(datadir, address1, waddress2_1, amounttosend)
    _transfers.Send(datadir, address1, waddress1_1, amounttosend)
    _transfers.Send(datadir, address1, waddress1_1, amounttosend)
    _transfers.Send(datadir, address1, waddress1_1, amounttosend)

    # we control how blocks are created. here we wait on a block started and then send another 3 TX
    # we will get 2 more blocks here
    #blocks = _blocks.WaitBlocks(datadir, blockslen + 1)
    time.sleep(3)
    #_lib.FatalAssert(len(blocks) == blockslen + 1, "Expected "+str(blockslen + 1)+" blocks")

    # 7 TX are required  for next block
    _transfers.Send(datadir, address1, waddress2_2, amounttosend)

    amounttosend2 = "%.8f" % round(balances[address1_2][0] / 8, 8)

    _transfers.Send(datadir, address1_2, waddress1_1, amounttosend2)
    tx2_2 = _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)

    _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)
    _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)
    _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)
    _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)

    # wait to complete blocks
    blocks = _blocks.WaitBlocks(datadir, blockslen + 2)
    time.sleep(5)
    _lib.FatalAssert(
        len(blocks) == blockslen + 2,
        "Expected " + str(blockslen + 2) + " blocks")

    #get balances on wallets
    am1 = _wallet.GetBalanceWallet(walletdatadir1, waddress1_1, "localhost",
                                   nodeport)
    am2 = _wallet.GetBalanceWallet(walletdatadir1, waddress1_2, "localhost",
                                   nodeport)
    am3 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_1, "localhost",
                                   nodeport)
    am4 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_2, "localhost",
                                   nodeport)

    _lib.FatalAssert(
        am1[1] == round(float(amounttosend) * 4 + float(amounttosend2), 8),
        "Expected balance is different for wallet 1_1")
    _lib.FatalAssert(
        am2[1] == round(float(amounttosend) + float(amounttosend2) * 5, 8),
        "Expected balance is different for wallet 1_2")
    _lib.FatalAssert(am3[1] == float(amounttosend),
                     "Expected balance is different for wallet 2_1")
    _lib.FatalAssert(am4[1] == float(amounttosend),
                     "Expected balance is different for wallet 2_2")

    #get group blances on a wallet loc
    balances_new = _transfers.GetGroupBalance(datadir)

    #get balances on node wallets

    balances1 = _wallet.GetGroupBalanceWallet(walletdatadir1, "localhost",
                                              nodeport)
    balances2 = _wallet.GetGroupBalanceWallet(walletdatadir2, "localhost",
                                              nodeport)

    _lib.FatalAssert(
        am1[1] == balances1[waddress1_1][1],
        "Expected balance is different from group listing for 1_1")
    _lib.FatalAssert(
        am2[1] == balances1[waddress1_2][1],
        "Expected balance is different from group listing for 1_2")
    _lib.FatalAssert(
        am3[1] == balances2[waddress2_1][1],
        "Expected balance is different from group listing for 2_1")
    _lib.FatalAssert(
        am4[1] == balances2[waddress2_2][1],
        "Expected balance is different from group listing for 2_2")

    newbalance1 = round(balances[address1][0] - float(amounttosend) * 7, 8)

    _lib.FatalAssert(newbalance1 == balances_new[address1][1],
                     "Expected balance is different after spending")

    #send from wallets . 8 TXs
    _wallet.Send(walletdatadir1, waddress1_1, address1, amounttosend,
                 "localhost", nodeport)
    _wallet.Send(walletdatadir1, waddress1_1, address1_2, amounttosend2,
                 "localhost", nodeport)
    _wallet.Send(walletdatadir1, waddress1_2, address1, amounttosend,
                 "localhost", nodeport)

    amounttosend3 = "%.8f" % round(float(amounttosend2) / 8, 8)

    _wallet.Send(walletdatadir1, waddress1_2, address1_2, amounttosend3,
                 "localhost", nodeport)
    _wallet.Send(walletdatadir1, waddress1_2, address1_2, amounttosend3,
                 "localhost", nodeport)
    _wallet.Send(walletdatadir1, waddress1_2, address1_2, amounttosend3,
                 "localhost", nodeport)
    _wallet.Send(walletdatadir1, waddress1_2, address1_2, amounttosend3,
                 "localhost", nodeport)
    tx2_3 = _wallet.Send(walletdatadir1, waddress1_2, address1_2,
                         amounttosend3, "localhost", nodeport)

    blocks = _blocks.WaitBlocks(datadir, blockslen + 3)
    _lib.FatalAssert(
        len(blocks) == blockslen + 3,
        "Expected " + str(blockslen + 3) + " blocks")
    time.sleep(3)

    am1_back = _wallet.GetBalanceWallet(walletdatadir1, waddress1_1,
                                        "localhost", nodeport)
    am1_expected = round(am1[1] - float(amounttosend) - float(amounttosend2),
                         8)

    _lib.FatalAssert(
        am1_back[1] == am1_expected,
        "Expected balance after sending from wallet 1_1 is wrong: " +
        str(am1_back) + ", expected " + str(am1_expected))

    am2_back = _wallet.GetBalanceWallet(walletdatadir1, waddress1_2,
                                        "localhost", nodeport)

    sa = '%0.8f' % (am2_back[1] + 0.00000001)
    _wallet.SendTooMuch(walletdatadir1, waddress1_2, address1, sa, "localhost",
                        nodeport)

    _lib.StartTestGroup("Node in config")

    _wallet.SetNodeConfig(walletdatadir1, "localhost", nodeport)

    balances1 = _wallet.GetGroupBalanceWalletNoNode(walletdatadir1)

    am1 = _wallet.GetBalanceWalletNoNode(walletdatadir1, waddress1_1)
    am2 = _wallet.GetBalanceWalletNoNode(walletdatadir1, waddress1_2)

    _lib.FatalAssert(
        am1[1] == balances1[waddress1_1][1],
        "Expected balance is different from group listing for 1_1 " +
        str(am1) + " " + str(balances1))
    _lib.FatalAssert(
        am2[1] == balances1[waddress1_2][1],
        "Expected balance is different from group listing for 1_2 " +
        str(am2) + " " + str(balances1))

    tx4 = _wallet.SendNoNode(walletdatadir1, waddress1_2, address1_2,
                             '%0.8f' % (am2[1] / 2))

    _lib.StartTestGroup("Unspent transactions")

    unspent = _wallet.GetUnspentNoNode(walletdatadir1, waddress1_2)

    txunspent = []

    for i in unspent:
        txunspent.append(i[2])

    _lib.FatalAssert(
        tx2_3 in txunspent, "Unspent TX in not in array of expected " +
        str(txunspent) + " " + str(tx2_3))

    unspent2 = _wallet.GetUnspent(walletdatadir2, waddress1_2, "localhost",
                                  nodeport)

    _lib.FatalAssert(
        len(unspent) == len(unspent2),
        "NNNumber of unspent TXs should be same. No config")

    txunspent = []

    for i in unspent2:
        txunspent.append(i[2])

    _lib.FatalAssert(tx2_3 in txunspent,
                     "Unspent TX in not in array of expected. No config")

    _lib.StartTestGroup("Get wallet history")

    history = _wallet.GetHistoryNoNode(walletdatadir1, waddress1_2)

    _lib.FatalAssert(len(history) == 12, "Expected 3 records in a history")

    history = _wallet.GetHistory(walletdatadir2, waddress2_2, "localhost",
                                 nodeport)

    _lib.FatalAssert(len(history) == 1, "Expected 1 record in a history")

    _lib.StartTestGroup("Pending balance")

    # we cancel. we don't need it anymore. for next tests we need 0 TXs
    #transactions.CancelTransaction(datadir,tx4)

    am3 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_1, "localhost",
                                   nodeport)

    addb1_2 = _transfers.GetBalance(datadir, address1_2)

    amounttosend2 = "%.8f" % round(am3[0] / 2 - 0.00000001, 8)

    _wallet.Send(walletdatadir2, waddress2_1, address1_2, amounttosend2,
                 "localhost", nodeport)

    am3_2 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_1, "localhost",
                                     nodeport)

    addb1_2_2 = _transfers.GetBalance(datadir, address1_2)

    _lib.FatalAssert(am3[1] == am3_2[1],
                     "Approved balance should be unchanged")
    _lib.FatalAssert(
        round(am3[0] - float(amounttosend2), 8) == am3_2[0],
        "Total balance should be changed")
    _lib.FatalAssert(
        round(am3[2] - float(amounttosend2), 8) == am3_2[2],
        "Pending balance should be changed")

    _lib.FatalAssert(
        round(addb1_2_2[2] - addb1_2[2], 8) == round(am3[2] - am3_2[2], 8),
        "Pending difference should be same")

    txlist = transactions.GetUnapprovedTransactions(datadir)

    amounttosend2 = "%.8f" % round(am3[1] / 2, 8)

    _wallet.Send(walletdatadir2, waddress2_1, address1_2, amounttosend2,
                 "localhost", nodeport)

    am3_3 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_1, "localhost",
                                     nodeport)

    addb1_2_3 = _transfers.GetBalance(datadir, address1_2)

    _lib.FatalAssert(am3[1] == am3_3[1],
                     "Approved balance should be unchanged")

    _lib.FatalAssert(
        math.fabs(round(am3_2[0] - float(amounttosend2), 8) - am3_3[0]) <=
        0.00000001, "Total balance should be changed")
    _lib.FatalAssert(
        math.fabs(round(am3_2[2] - float(amounttosend2) - am3_3[2], 8)) <=
        0.00000001, "Pending balance should be changed")

    _lib.FatalAssert(
        math.fabs(
            round(addb1_2_3[2] - addb1_2[2], 8) - round(am3[2] - am3_3[2], 8))
        <= 0.00000002, "Pending difference should be same after 2 sends")

    startnode.StopNode(datadir)
    datadir = ""

    #_lib.RemoveTestFolder(datadir)
    _lib.EndTestGroupSuccess()
Esempio n. 3
0
def test(testfilter):
    global datadir
    
    _lib.StartTestGroup("SQL Proxy basic")

    _lib.CleanTestFolders()
    datadir = _lib.CreateTestFolder()

    startnode.StartNodeWithoutBlockchain(datadir)
    
    address2 = transactions.CreateWallet(datadir)
    address3 = transactions.CreateWallet(datadir)
    
    _lib.CopyTestConsensusConfig(datadir,"customnumbers", address2)
    
    address = startnode.InitBockchain(datadir)
    _complex.AddProxyToConfig(datadir, "localhost:40041")
    _complex.AddInternalKeyToConfig(datadir, address3) # init internal signing

    startnode.StartNode(datadir, address, '30000')
    
    _lib.StartTestGroup("Do transactions")

    transactions.GetUnapprovedTransactionsEmpty(datadir)
    
    # address3 signs proxy transactions. it doesn't have money yet
    _transfers.Send(datadir,address, address3 ,5) # needs this to create table
    
    blocks = _blocks.WaitBlocks(datadir, 2)
    time.sleep(1)
    
    _sql.ExecuteSQLOnProxy(datadir, "CREATE TABLE test (a INT auto_increment PRIMARY KEY, b VARCHAR(20))")
    
    tables = _lib.DBGetRows(datadir,"SHOW TABLES")
    found = False
    for table in tables:
        if table[0] == "test":
            found = True
            break
        
    _lib.FatalAssert(found, "Table test not found in the DB")
    
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row1'")
    
    blocks = _blocks.WaitBlocks(datadir, 3)
    time.sleep(1)
    
    # now try to create paid table. it should fail because no money
    _sql.ExecuteSQLOnProxyFail(datadir, "CREATE TABLE members (id INT auto_increment PRIMARY KEY, name VARCHAR(20))")
    
    # send money
    _transfers.Send(datadir,address, address3 ,10) # this table creation costs 10 
    
    _sql.ExecuteSQLOnProxy(datadir, "CREATE TABLE members (id INT auto_increment PRIMARY KEY, name VARCHAR(20))")
    
    tables = _lib.DBGetRows(datadir,"SHOW TABLES")
    found = False
    for table in tables:
        if table[0] == "members":
            found = True
            break
    
    _lib.FatalAssert(found, "Table not found in the DB")
    
    _sql.ExecuteSQLOnProxyFail(datadir, "INSERT INTO members SET name='user1'")
    # but should be abe to isert to free table
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row2'")
    
    blocks = _blocks.WaitBlocks(datadir, 4)
    time.sleep(2)
    
    _transfers.Send(datadir,address, address3 ,1) 
    
    _sql.ExecuteSQLOnProxy(datadir, "INSERT INTO members SET name='user1'")
    _sql.ExecuteSQLOnProxy(datadir, "INSERT INTO members SET name='user2'")
    _sql.ExecuteSQLOnProxyFail(datadir, "INSERT INTO members SET name='user3'")
    
    bal1 = _transfers.GetBalance(datadir, address)
    bal2 = _transfers.GetBalance(datadir, address2)
    bal3 = _transfers.GetBalance(datadir, address3)

    _lib.FatalAssert(bal1[1] == 45.0, "Balance of a first addres is expected to be 45")
    _lib.FatalAssert(bal2[1] == 15.0, "Balance of a second addres is expected to be 15")
    _lib.FatalAssert(bal3[1] == 0.0, "Balance of a third addres is expected to be 0")
    
    startnode.StopNode(datadir)
    datadir = ""
    
    #_lib.RemoveTestFolder(datadir)
    _lib.EndTestGroupSuccess()
    

    
Esempio n. 4
0
def PrepareNodes():
    
    nodeport = '30000'
    
    _lib.StartTestGroup("Wallet Balance")
    
    _lib.CleanTestFolders()
    
    datadir_tmp = CopyBlockchainWithBlocks("_1_")
    
    blocks = _blocks.GetBlocks(datadir_tmp)
    
    balances = _transfers.GetGroupBalance(datadir_tmp)
    
    datadirs = []
    
    address1 = balances.keys()[0]
    
    # address1_3 becomes a minter. we will send money from other 2 and this will receive rewards
    startnode.StartNode(datadir_tmp, address1,nodeport)
    datadir = datadir_tmp
    datadirs.append(datadir_tmp)
    
    nodes = []
    
    for i in range(1, 6):
        port = str(30000+i)
        d = blocksnodes.StartNodeAndImport(port, nodeport, "Server "+str(i),"_"+str(i+1)+"_")
        datadir_n = d[0]
        address_n = d[1]
        
        nodes.append({'number':i, 'port':port, 'datadir':datadir_n,'address':address_n})
        datadirs.append(datadir_n)
    
    _lib.StartTestGroup("Temp Data Dirs")
    _lib.StartTest("Node 0 "+os.path.basename(datadir))
    
    for node in nodes:
        _lib.StartTest("Node "+str(node['number'])+" "+os.path.basename(node['datadir']))
        
    # commmon transfer of blocks between nodes
    _lib.StartTestGroup("Transfer of blocks between nodes")
    
    blocks = _blocks.GetBlocks(datadir)
    blockslen = len(blocks)
    
    balance1 = _transfers.GetBalance(datadir, address1)
    as1 = "%.8f" % round(balance1[0]/10,8)
    
    # should be 6 transactions
    _transfers.Send(datadir,address1, nodes[0]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[1]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[2]['address'] ,as1)
    
    _transfers.Send(datadir,address1, nodes[0]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[1]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[2]['address'] ,as1)
    
    blocks = _blocks.WaitBlocks(datadir, blockslen + 1)
    
    _lib.FatalAssert(len(blocks) == blockslen + 1, "Expected "+str(blockslen +1)+" blocks")
    
    #wait while block is posted to all other nodes
    time.sleep(1)
    # check on each node
    for node in nodes:
        blocks = _blocks.WaitBlocks(node['datadir'], blockslen + 1)
        _lib.FatalAssert(len(blocks) == blockslen + 1, "Expected "+str(blockslen +1)+" blocks o node "+str(node['number']))
    
    _lib.StartTestGroup("Create 2 branches of blockchain")
    
    # remove connection between subnetworks
    managenodes.RemoveAllNodes(nodes[0]['datadir'])
    managenodes.RemoveAllNodes(nodes[1]['datadir'])
    managenodes.RemoveAllNodes(nodes[2]['datadir'])
    managenodes.RemoveAllNodes(nodes[3]['datadir'])
    managenodes.RemoveAllNodes(nodes[4]['datadir'])
    managenodes.RemoveAllNodes(datadir)
    
    # first group - main and 4,5 nodes
    managenodes.AddNode(datadir,"localhost",'30004')
    managenodes.AddNode(datadir,"localhost",'30005')
    managenodes.AddNode(nodes[3]['datadir'],"localhost",'30005')
    
    #second group 1,2,3
    managenodes.AddNode(nodes[0]['datadir'],"localhost",'30002')
    managenodes.AddNode(nodes[0]['datadir'],"localhost",'30003')
    managenodes.AddNode(nodes[1]['datadir'],"localhost",'30003')
    
    time.sleep(1)
    
    #check nodes
    
    nodes0 = managenodes.GetNodes(datadir)
    _lib.FatalAssert("localhost:30005", "Node 5 is not in the list of 0")
    _lib.FatalAssert("localhost:30004", "Node 4 is not in the list of 0")
    
    nodes1 = managenodes.GetNodes(nodes[0]['datadir'])
    
    _lib.FatalAssert("localhost:30002", "Node 2 is not in the list of 1")
    _lib.FatalAssert("localhost:30003", "Node 3 is not in the list of 1")
    
    nodes2 = managenodes.GetNodes(nodes[1]['datadir'])
    
    _lib.FatalAssert("localhost:30001", "Node 1 is not in the list of 2")
    _lib.FatalAssert("localhost:30003", "Node 3 is not in the list of 2")
    
    _lib.StartTestGroup("2 new blocks on first branch")
    
    balance1 = _transfers.GetBalance(datadir, address1)
    as1 = "%.8f" % round(balance1[0]/20,8)
    
    # 7 TX for 8-th block
    tx = [""] * 15
    tx[0] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[0]
    tx[1] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[1]
    tx[2] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[2]
    tx[3] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[3]
    tx[4] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[4]
    tx[5] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[5]
    tx[6] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    print tx[6]
    
    time.sleep(7)
    # 8 TX for 9-th block
    tx[7] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[7]
    tx[8] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[8]
    tx[9] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[9]
    tx[10] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[10]
    tx[11] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[11]
    tx[12] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[12]
    tx[13] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[13]
    tx[14] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    print tx[14]
    
    blocks1 = _blocks.WaitBlocks(nodes[4]['datadir'], blockslen + 3)
    time.sleep(3)
    
    _lib.FatalAssert(len(blocks1) == blockslen + 3, "Expected "+str(blockslen +3)+" blocks for branch 1")
    
    _lib.StartTestGroup("1 new block on second branch")
    
    balance2 = _transfers.GetBalance(nodes[0]['datadir'], nodes[0]['address'])
    as2 = "%.8f" % round(balance2[0]/10,8)
    
    # 7 new TX
    tx1 = _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[1]['address'] ,as2)
    tx2 = _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    tx3 = _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    
    blocks2 = _blocks.WaitBlocks(nodes[2]['datadir'], blockslen + 2)
    _lib.FatalAssert(len(blocks2) == blockslen + 2, "Expected "+str(blockslen +2)+" blocks for branch 2")
    
    dstdir = _lib.getCurrentDir()+"/datafortests/"
    #configs for cluster 1
    copyConfig(datadir, dstdir+"bc6nodes_1/config.t", address1, nodeport, nodes[3]['port'], nodes[4]['port'])
    
    copyConfig(nodes[3]['datadir'], dstdir+"bc6nodes_5/config.t", nodes[3]['address'], nodes[3]['port'], nodeport, nodes[4]['port'])
    
    copyConfig(nodes[4]['datadir'], dstdir+"bc6nodes_6/config.t", nodes[4]['address'], nodes[4]['port'], nodeport, nodes[3]['port'])
    
    #config for cluster 2
    copyConfig(nodes[0]['datadir'], dstdir+"bc6nodes_2/config.t", nodes[0]['address'], nodes[0]['port'], nodes[1]['port'], nodes[2]['port'])
    
    copyConfig(nodes[1]['datadir'], dstdir+"bc6nodes_3/config.t", nodes[1]['address'], nodes[1]['port'], nodes[0]['port'], nodes[2]['port'])
    
    copyConfig(nodes[2]['datadir'], dstdir+"bc6nodes_4/config.t", nodes[2]['address'], nodes[2]['port'], nodes[0]['port'], nodes[1]['port'])
    
    #print os.path.basename(datadir)
    startnode.StopNode(datadir)
    
    dstdir = _lib.getCurrentDir()+"/datafortests/bc6nodes_1/"
    #print dstdir

    copyfile(datadir+"/wallet.dat", dstdir+"wallet.t")
    
    try:
        os.remove(dstdir+"db.sql")
    except OSError:
        pass

    DumpBCDB(datadir, dstdir+"db.sql")
    
    i = 2
    
    for node in nodes:
        #print os.path.basename(node['datadir'])
        startnode.StopNode(node['datadir'])
        
        dstdir = _lib.getCurrentDir()+"/datafortests/bc6nodes_"+str(i)+"/"
        #print dstdir
        copyfile(node['datadir']+"/wallet.dat", dstdir+"wallet.t")
        
        try:
            os.remove(dstdir+"db.sql")
        except OSError:
            pass
        
        DumpBCDB(node['datadir'], dstdir+"db.sql")
        
        i=i+1
    
    return [datadir, address1, nodes, blockslen+1, datadirs]
Esempio n. 5
0
def test(testfilter):
    global datadir

    nodeport = '30000'

    _lib.StartTestGroup("Wallet Balance")

    _lib.CleanTestFolders()

    inf = blocksnodes.MakeBlockchainWithBlocks(nodeport)
    datadir_tmp = inf[0]
    address1 = inf[1]
    address1_2 = inf[2]
    address1_3 = inf[3]

    balances = _transfers.GetGroupBalance(datadir_tmp)

    #get balance when a node is not run
    bal1 = _transfers.GetBalance(datadir_tmp, address1)
    bal1_2 = _transfers.GetBalance(datadir_tmp, address1_2)
    bal1_3 = _transfers.GetBalance(datadir_tmp, address1_3)

    _lib.FatalAssert(bal1 == balances[address1],
                     "Balance is different from group rec for 1")
    _lib.FatalAssert(bal1_2 == balances[address1_2],
                     "Balance is different from group rec for 2")
    _lib.FatalAssert(bal1_3 == balances[address1_3],
                     "Balance is different from group rec for 3")

    s1 = bal1 + bal1_2 + bal1_3

    startnode.StartNode(datadir_tmp, address1, nodeport)
    datadir = datadir_tmp

    #get balaces on nodes wallets
    bal1 = _transfers.GetBalance(datadir, address1)
    bal1_2 = _transfers.GetBalance(datadir, address1_2)
    bal1_3 = _transfers.GetBalance(datadir, address1_3)

    s2 = bal1 + bal1_2 + bal1_3

    _lib.FatalAssert(s1 == s2,
                     "Balances shoul be equal when a node is On and Off")

    #get group balance on a node
    balances = _transfers.GetGroupBalance(datadir)
    _lib.FatalAssert(bal1 == balances[address1],
                     "Balance is different from group rec for 1")
    _lib.FatalAssert(bal1_2 == balances[address1_2],
                     "Balance is different from group rec for 2")
    _lib.FatalAssert(bal1_3 == balances[address1_3],
                     "Balance is different from group rec for 3")

    #create 2 wallet locations and 2 wallets in each of them
    walletdatadir1 = _lib.CreateTestFolder("wallet")
    walletdatadir2 = _lib.CreateTestFolder("wallet")

    waddress1_1 = _wallet.CreateWallet(walletdatadir1)
    waddress1_2 = _wallet.CreateWallet(walletdatadir1)
    waddress1_3 = _wallet.CreateWallet(walletdatadir1)

    waddress2_1 = _wallet.CreateWallet(walletdatadir2)
    waddress2_2 = _wallet.CreateWallet(walletdatadir2)

    #send some funds to all that wallets
    amounttosend = "%.8f" % round(bal1[0] / 5, 8)
    amounttosend3 = "%.8f" % round(bal1_3[0] / 5, 8)

    _transfers.Send(datadir, address1, waddress1_1, amounttosend)
    _transfers.Send(datadir, address1, waddress1_2, amounttosend)
    _transfers.Send(datadir, address1, waddress2_1, amounttosend)
    _transfers.Send(datadir, address1_3, waddress1_3, amounttosend3)

    # we control how blocks are created. here we wait on a block started and then send another 3 TX
    # we will get 2 more blocks here
    time.sleep(1)

    _transfers.Send(datadir, address1, waddress2_2, amounttosend)
    amounttosend2 = "%.8f" % round(bal1_2[0] / 5, 8)
    _transfers.Send(datadir, address1_2, waddress1_1, amounttosend2)
    _transfers.Send(datadir, address1_2, waddress1_2, amounttosend2)

    _transfers.Send(datadir, address1_3, waddress1_3, amounttosend3)
    _transfers.Send(datadir, address1_3, waddress1_3, amounttosend3)

    # wait to complete blocks
    blocks = _blocks.WaitBlocks(datadir, 6)
    time.sleep(2)

    _lib.FatalAssert(len(blocks) == 6, "Expected 6 blocks")

    #get balances on wallets
    am1 = _wallet.GetBalanceWallet(walletdatadir1, waddress1_1, "localhost",
                                   nodeport)
    am2 = _wallet.GetBalanceWallet(walletdatadir1, waddress1_2, "localhost",
                                   nodeport)
    am3 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_1, "localhost",
                                   nodeport)
    am4 = _wallet.GetBalanceWallet(walletdatadir2, waddress2_2, "localhost",
                                   nodeport)

    _lib.FatalAssert(
        am1[1] == round(float(amounttosend) + float(amounttosend2), 8),
        "Expected balance is different for wallet 1_1")
    _lib.FatalAssert(
        am2[1] == round(float(amounttosend) + float(amounttosend2), 8),
        "Expected balance is different for wallet 1_2")
    _lib.FatalAssert(am3[1] == float(amounttosend),
                     "Expected balance is different for wallet 2_1")
    _lib.FatalAssert(am4[1] == float(amounttosend),
                     "Expected balance is different for wallet 2_2")

    #get group blances on a wallet loc
    balances = _transfers.GetGroupBalance(datadir)
    #get balances on node wallets

    balances1 = _wallet.GetGroupBalanceWallet(walletdatadir1, "localhost",
                                              nodeport)
    balances2 = _wallet.GetGroupBalanceWallet(walletdatadir2, "localhost",
                                              nodeport)

    _lib.FatalAssert(
        am1[1] == balances1[waddress1_1][1],
        "Expected balance is different from group listing for 1_1")
    _lib.FatalAssert(
        am2[1] == balances1[waddress1_2][1],
        "Expected balance is different from group listing for 1_2")
    _lib.FatalAssert(
        am3[1] == balances2[waddress2_1][1],
        "Expected balance is different from group listing for 2_1")
    _lib.FatalAssert(
        am4[1] == balances2[waddress2_2][1],
        "Expected balance is different from group listing for 2_2")

    startnode.StopNode(datadir)
    datadir = ""

    #_lib.RemoveTestFolder(datadir)
    _lib.EndTestGroupSuccess()
Esempio n. 6
0
def PrepareNodesWithSQL():
    
    nodeport = '30000'
    
    _lib.StartTestGroup("Prepare 6 nodes with SQL commands in BC")
    
    _lib.CleanTestFolders()
    
    datadir_tmp = CopyBlockchainWithBlocks("_1_")
    
    blocks = _blocks.GetBlocks(datadir_tmp)
    
    balances = _transfers.GetGroupBalance(datadir_tmp)
    
    datadirs = []
    
    address1 = balances.keys()[0]
    
    # address1_3 becomes a minter. we will send money from other 2 and this will receive rewards
    AddProxyToConfig(datadir_tmp, "localhost:40040")
    AddInternalKeyToConfig(datadir_tmp, address1) # init internal signing
    
    startnode.StartNode(datadir_tmp, address1,nodeport)
    datadir = datadir_tmp
    datadirs.append(datadir_tmp)
    
    nodes = []
    
    for i in range(1, 6):
        port = str(30000+i)
        dbproxyport = str(40040+i)
        d = blocksnodes.StartNodeAndImport(port, nodeport, "Server "+str(i), int(dbproxyport),"_"+str(i+1)+"_")
        datadir_n = d[0]
        address_n = d[1]
        
        nodes.append({'number':i, 'port':port, 'datadir':datadir_n,'address':address_n,'proxyport':dbproxyport})
        datadirs.append(datadir_n)
    
    _lib.StartTestGroup("Temp Data Dirs")
    _lib.StartTest("Node 0 "+os.path.basename(datadir))
    
    for node in nodes:
        _lib.StartTest("Node "+str(node['number'])+" "+os.path.basename(node['datadir']))
        
    # commmon transfer of blocks between nodes
    _lib.StartTestGroup("Transfer of blocks between nodes")
    
    blocks = _blocks.GetBlocks(datadir)
    blockslen = len(blocks)
    
    balance1 = _transfers.GetBalance(datadir, address1)
    as1 = "%.8f" % round(balance1[0]/10,8)
    
    # should be 6 transactions. 3 currency and 3 SQL
    _transfers.Send(datadir,address1, nodes[0]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[1]['address'] ,as1)
    _transfers.Send(datadir,address1, nodes[2]['address'] ,as1)
    
    _sql.ExecuteSQLOnProxy(datadir,"CREATE TABLE test (a INT auto_increment PRIMARY KEY, b VARCHAR(20))")
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row1'")
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET a=2,b='row2'")
    
    blocks = _blocks.WaitBlocks(datadir, blockslen + 1)
    
    _lib.FatalAssert(len(blocks) == blockslen + 1, "Expected "+str(blockslen +1)+" blocks")
    
    #wait while block is posted to all other nodes
    time.sleep(2)
    # check on each node
    for node in nodes:
        blocks = _blocks.WaitBlocks(node['datadir'], blockslen + 1)
        _lib.FatalAssert(len(blocks) == blockslen + 1, "Expected "+str(blockslen +1)+" blocks o node "+str(node['number']))
    
    _lib.StartTestGroup("Create 2 branches of blockchain")
    
    while True:
        time.sleep(4)# to complete all operations in progress
    
        
    
        # remove connection between subnetworks
        managenodes.RemoveAllNodes(nodes[0]['datadir'])
        managenodes.RemoveAllNodes(nodes[1]['datadir'])
        managenodes.RemoveAllNodes(nodes[2]['datadir'])
        managenodes.RemoveAllNodes(nodes[3]['datadir'])
        managenodes.RemoveAllNodes(nodes[4]['datadir'])
        managenodes.RemoveAllNodes(datadir)
    
        time.sleep(1)
        nodes0 = managenodes.GetNodes(datadir)
        nodes1 = managenodes.GetNodes(nodes[0]['datadir'])
        nodes2 = managenodes.GetNodes(nodes[1]['datadir'])
        
        if len(nodes0) == 0 and len(nodes1) == 0 and len(nodes2) == 0:
            break
        _lib.StartTestGroup("Nodes addresses are still not clean")
        
    # first group - main and 4,5 nodes
    managenodes.AddNode(datadir,"localhost",'30004')
    managenodes.AddNode(datadir,"localhost",'30005')
    managenodes.AddNode(nodes[3]['datadir'],"localhost",'30005')
    
    #second group 1,2,3
    managenodes.AddNode(nodes[0]['datadir'],"localhost",'30002')
    managenodes.AddNode(nodes[0]['datadir'],"localhost",'30003')
    managenodes.AddNode(nodes[1]['datadir'],"localhost",'30003')
    
    time.sleep(1)
    
    #check nodes
    
    nodes0 = managenodes.GetNodes(datadir)
    _lib.FatalAssert("localhost:30005", "Node 5 is not in the list of 0")
    _lib.FatalAssert("localhost:30004", "Node 4 is not in the list of 0")
    
    nodes1 = managenodes.GetNodes(nodes[0]['datadir'])
    
    _lib.FatalAssert("localhost:30002", "Node 2 is not in the list of 1")
    _lib.FatalAssert("localhost:30003", "Node 3 is not in the list of 1")
    
    nodes2 = managenodes.GetNodes(nodes[1]['datadir'])
    
    _lib.FatalAssert("localhost:30001", "Node 1 is not in the list of 2")
    _lib.FatalAssert("localhost:30003", "Node 3 is not in the list of 2")
    
    _lib.StartTestGroup("2 new blocks on first branch")
    
    balance1 = _transfers.GetBalance(datadir, address1)
    as1 = "%.8f" % round(balance1[0]/20,8)
    
    # 7 TX for 8-th block
    tx = [""] * 15
    tx[0] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    
    tx[1] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    
    tx[2] = _transfers.Send(datadir,address1, nodes[3]['address'] ,as1)
    
    _sql.ExecuteSQLOnProxy(datadir,"UPDATE test SET b='row2_updated' WHERE a=2")
    
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row3'")
    
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row4'")
    
    _sql.ExecuteSQLOnProxy(datadir,"UPDATE test SET b='row4_updated' WHERE a=4")
    
    time.sleep(7)
    # 8 TX for 9-th block
    tx[7] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    
    tx[8] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    
    tx[9] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    
    tx[10] = _transfers.Send(datadir,address1, nodes[4]['address'] ,as1)
    
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row7', a=7")
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row8', a=8")
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row9', a=9")
    _sql.ExecuteSQLOnProxy(datadir,"INSERT INTO test SET b='row10', a=10")
    
    blocks1 = _blocks.WaitBlocks(nodes[4]['datadir'], blockslen + 3)
    time.sleep(3)
    
    _lib.FatalAssert(len(blocks1) == blockslen + 3, "Expected "+str(blockslen +3)+" blocks for branch 1")
    
    rows = _lib.DBGetRows(nodes[3]['datadir'],"SELECT * FROM test",True)
    _lib.FatalAssert(len(rows) == 8, "Must be 8 rows in a table on 3-th node")
    
    rows = _lib.DBGetRows(nodes[4]['datadir'],"SELECT * FROM test",True)
    _lib.FatalAssert(len(rows) == 8, "Must be 8 rows in a table on 4-th node")
    
    _lib.StartTestGroup("1 new block on second branch")
    
    balance2 = _transfers.GetBalance(nodes[0]['datadir'], nodes[0]['address'])
    as2 = "%.8f" % round(balance2[0]/10,8)
    
    # 7 new TX
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[1]['address'] ,as2)
    _transfers.Send(nodes[0]['datadir'], nodes[0]['address'], nodes[2]['address'] ,as2)
    
    # unique row
    _sql.ExecuteSQLOnProxy(nodes[0]['datadir'],"INSERT INTO test SET b='row5', a = 5")
    # identical as in parallel
    _sql.ExecuteSQLOnProxy(nodes[0]['datadir'],"INSERT INTO test SET b='row7', a=7")
    # other value and same ID
    _sql.ExecuteSQLOnProxy(nodes[0]['datadir'],"INSERT INTO test SET b='row3_other', a=3")
    # update same
    _sql.ExecuteSQLOnProxy(nodes[0]['datadir'],"UPDATE test SET b='row2_updated_other' WHERE a=2")
    # delete
    _sql.ExecuteSQLOnProxy(nodes[0]['datadir'],"DELETE FROM test WHERE a=7")
    
    blocks2 = _blocks.WaitBlocks(nodes[0]['datadir'], blockslen + 2)
    _lib.FatalAssert(len(blocks2) == blockslen + 2, "Expected "+str(blockslen +2)+" blocks for branch 2. Node 1")
    
    blocks2 = _blocks.WaitBlocks(nodes[1]['datadir'], blockslen + 2)
    _lib.FatalAssert(len(blocks2) == blockslen + 2, "Expected "+str(blockslen +2)+" blocks for branch 2. Node 2")
    
    blocks2 = _blocks.WaitBlocks(nodes[2]['datadir'], blockslen + 2)
    _lib.FatalAssert(len(blocks2) == blockslen + 2, "Expected "+str(blockslen +2)+" blocks for branch 2. Node 2")
    
    time.sleep(3)# to allow to update all references after block add
    
    #rows = _lib.DBGetRows(datadir,"SELECT * FROM test",True)
    #print "0",rows
    #rows = _lib.DBGetRows(nodes[0]['datadir'],"SELECT * FROM test",True)
    #print "1",rows
    #rows = _lib.DBGetRows(nodes[1]['datadir'],"SELECT * FROM test",True)
    #print "2",rows
    #rows = _lib.DBGetRows(nodes[2]['datadir'],"SELECT * FROM test",True)
    #print "3",rows
    #rows = _lib.DBGetRows(nodes[3]['datadir'],"SELECT * FROM test",True)
    #print "4",rows
    #rows = _lib.DBGetRows(nodes[4]['datadir'],"SELECT * FROM test",True)
    #print "5",rows
    
    # index 2 is 4-th node (3-rd in second network)
    rows = _lib.DBGetRows(nodes[2]['datadir'],"SELECT * FROM test",True)
    
    _lib.FatalAssert(len(rows) == 4, "Must be 4 rows in a table on 4-th node")
    
    dstdir = _lib.getCurrentDir()+"/datafortests/"
    #configs for cluster 1
    copyConfig(datadir, dstdir+"bc6nodessql_1/config.t", address1, nodeport, nodes[3]['port'], nodes[4]['port'])
    
    copyConfig(nodes[3]['datadir'], dstdir+"bc6nodessql_5/config.t", nodes[3]['address'], nodes[3]['port'], nodeport, nodes[4]['port'])
    
    copyConfig(nodes[4]['datadir'], dstdir+"bc6nodessql_6/config.t", nodes[4]['address'], nodes[4]['port'], nodeport, nodes[3]['port'])
    
    #config for cluster 2
    copyConfig(nodes[0]['datadir'], dstdir+"bc6nodessql_2/config.t", nodes[0]['address'], nodes[0]['port'], nodes[1]['port'], nodes[2]['port'])
    
    copyConfig(nodes[1]['datadir'], dstdir+"bc6nodessql_3/config.t", nodes[1]['address'], nodes[1]['port'], nodes[0]['port'], nodes[2]['port'])
    
    copyConfig(nodes[2]['datadir'], dstdir+"bc6nodessql_4/config.t", nodes[2]['address'], nodes[2]['port'], nodes[0]['port'], nodes[1]['port'])
    
    #print os.path.basename(datadir)
    startnode.StopNode(datadir)
    
    dstdir = _lib.getCurrentDir()+"/datafortests/bc6nodessql_1/"
    #print dstdir

    copyfile(datadir+"/wallet.dat", dstdir+"wallet.t")
    
    try:
        os.remove(dstdir+"db.sql")
    except OSError:
        pass

    DumpBCDB(datadir, dstdir+"db.sql")
    
    i = 2
    
    for node in nodes:
        #print os.path.basename(node['datadir'])
        startnode.StopNode(node['datadir'])
        
        dstdir = _lib.getCurrentDir()+"/datafortests/bc6nodessql_"+str(i)+"/"
        #print dstdir
        copyfile(node['datadir']+"/wallet.dat", dstdir+"wallet.t")
        
        try:
            os.remove(dstdir+"db.sql")
        except OSError:
            pass
        
        DumpBCDB(node['datadir'], dstdir+"db.sql")
        
        i=i+1
    
    return [datadir, address1, nodes, blockslen+1, datadirs]