Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 3545 characters in body
Source Link
Amir Ali
  • 447
  • 6
  • 18

and myData is all my testcases/parameters like this [c1(constructor), g1, g2, s1, s2, s3, g3, g4, s4, g5, g6.........]... it should be noted that these values are encoded pareamters like this [0x000000, 0x123fs000, ........, 0x23abc220000]and also noted that myData contain millions of such testcase.. in finalGetters = [g1, g2, g3,.. ], finalSetter =[s1, s2, s3...]

and myData is all my testcases/parameters like this [c1(constructor), g1, g2, s1, s2, s3, g3, g4, s4, g5, g6.........]... it should be noted that these values are encoded pareamters like this [0x000000, 0x123fs000, ........, 0x23abc220000]and also noted that myData contain millions of such testcase..

and myData is all my testcases/parameters like this [c1(constructor), g1, g2, s1, s2, s3, g3, g4, s4, g5, g6.........]... it should be noted that these values are encoded pareamters like this [0x000000, 0x123fs000, ........, 0x23abc220000]and also noted that myData contain millions of such testcase.. in finalGetters = [g1, g2, g3,.. ], finalSetter =[s1, s2, s3...]

added 3545 characters in body
Source Link
Amir Ali
  • 447
  • 6
  • 18

UDDATE: my code is here

const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider("HTTP://127.0.0.1:8545");
const web3 = new Web3(provider);
const account1 = "0x2cAe18ac37d85CccdE2e...." // Ganache GUI
const privateKey1 ="0x19c30ab1a928ab11f18..........." // Ganache GUI

//////////////////// Final Deploy //////////////////////////////
async function finalDeploy(r){

    const options = {
      data: '0x' + myBin[0]+constructorParams[r],
      gas: 5000000,
  };
  const signed = await web3.eth.accounts.signTransaction(options, privateKey1);
  const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
  console.log("Contract: is deployed at  " +receipt.contractAddress);
  var address = receipt.contractAddress;
  return address;
  // contractAddressess.push(receipt.contractAddress)


}
//////////////////// Final Setter //////////////////////////////
async function finalSettersFunctions(address, r, j){
  var myFunc; 
      myContAddr = address;

          myFunc = finalSetters[r][j];
      
            try {
              await web3.eth.sendTransaction(
                // web3.eth.sendTransaction(
                {from:account1,
                // nonce: myNonce,
                to:myContAddr,
                data: myFunc
                    }, function(err, receipt) {
                      console.log("Normal Setters: ",receipt)
                    //   myNonce++;
                    //   console.log("Current nonce Normal is : ", myNonce)
                    });
            } catch (error) {
              console.log(" Normal Setters: ERROR !", error); 
            //   myNonce--;
            }
}

//////////// Getting Status ////////////////////////
async function finalGetStatus(statusArr, address) {
  var myFunc; 
  var myFuncParams; 
  var res;
  var myContractAbiDefenition = myAbi[0]
 
    var myContractInstance = new web3.eth.Contract(myContractAbiDefenition, address);
    for(j=0; j<selectorObjects.length; j++) {
      // console.log("function name: ", selectorObjects[j].func);
      myFunc = selectorObjects[j].func;

      try {
        res = await myContractInstance.methods[myFunc](...[...Array(finalGettersParams[j].__length__).keys()].map(key => finalGettersParams[j][key])).call({from: account1})  // without input
        console.log("Getter output", res);
        statusArr.push(res)
      } catch (error) {
        console.log("Getter output: ERROR !", error);
        noOfErrors++;
        statusArr.push(noOfErrors)
      }

    }       

  // return statusArr;
}

async function main() {
  myData =  fs.readFileSync('./param/param0.txt', 'utf8').split('\n');

  for(r=0; r<myData.length; r++) {

    for(let i = 0; i < finalGetters[r].length; i++){
      for(let j =0; j < finalSetters[r].length; j++){
        console.log("============TestCase No. "+r+"  Getter  g"+i+"  Setter   s"+j+"=================")
      var myReceipt = await finalDeploy(r);
      console.log("============  Setter Function of Contract No. ", r);
      var myget = await finalSettersFunctions(myReceipt, r,j);
    console.log("============ NORMAL ORDER Status Functions of Contract No. ", r);
        var myset =await finalGetStatus(prvResult, myReceipt);
      }
    }
  }
}
main().then(() => {
    console.log("ALL has been DONE !")
  })

and myData is all my testcases/parameters like this [c1(constructor), g1, g2, s1, s2, s3, g3, g4, s4, g5, g6.........]... it should be noted that these values are encoded pareamters like this [0x000000, 0x123fs000, ........, 0x23abc220000]and also noted that myData contain millions of such testcase..

Ganche GUI version: v2.1.2 Web3 version: [email protected] Node version: v10.17.0 Windows 10

UDDATE: my code is here

const Web3 = require('web3');
const provider = new Web3.providers.HttpProvider("HTTP://127.0.0.1:8545");
const web3 = new Web3(provider);
const account1 = "0x2cAe18ac37d85CccdE2e...." // Ganache GUI
const privateKey1 ="0x19c30ab1a928ab11f18..........." // Ganache GUI

//////////////////// Final Deploy //////////////////////////////
async function finalDeploy(r){

    const options = {
      data: '0x' + myBin[0]+constructorParams[r],
      gas: 5000000,
  };
  const signed = await web3.eth.accounts.signTransaction(options, privateKey1);
  const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction);
  console.log("Contract: is deployed at  " +receipt.contractAddress);
  var address = receipt.contractAddress;
  return address;
  // contractAddressess.push(receipt.contractAddress)


}
//////////////////// Final Setter //////////////////////////////
async function finalSettersFunctions(address, r, j){
  var myFunc; 
      myContAddr = address;

          myFunc = finalSetters[r][j];
      
            try {
              await web3.eth.sendTransaction(
                // web3.eth.sendTransaction(
                {from:account1,
                // nonce: myNonce,
                to:myContAddr,
                data: myFunc
                    }, function(err, receipt) {
                      console.log("Normal Setters: ",receipt)
                    //   myNonce++;
                    //   console.log("Current nonce Normal is : ", myNonce)
                    });
            } catch (error) {
              console.log(" Normal Setters: ERROR !", error); 
            //   myNonce--;
            }
}

//////////// Getting Status ////////////////////////
async function finalGetStatus(statusArr, address) {
  var myFunc; 
  var myFuncParams; 
  var res;
  var myContractAbiDefenition = myAbi[0]
 
    var myContractInstance = new web3.eth.Contract(myContractAbiDefenition, address);
    for(j=0; j<selectorObjects.length; j++) {
      // console.log("function name: ", selectorObjects[j].func);
      myFunc = selectorObjects[j].func;

      try {
        res = await myContractInstance.methods[myFunc](...[...Array(finalGettersParams[j].__length__).keys()].map(key => finalGettersParams[j][key])).call({from: account1})  // without input
        console.log("Getter output", res);
        statusArr.push(res)
      } catch (error) {
        console.log("Getter output: ERROR !", error);
        noOfErrors++;
        statusArr.push(noOfErrors)
      }

    }       

  // return statusArr;
}

async function main() {
  myData =  fs.readFileSync('./param/param0.txt', 'utf8').split('\n');

  for(r=0; r<myData.length; r++) {

    for(let i = 0; i < finalGetters[r].length; i++){
      for(let j =0; j < finalSetters[r].length; j++){
        console.log("============TestCase No. "+r+"  Getter  g"+i+"  Setter   s"+j+"=================")
      var myReceipt = await finalDeploy(r);
      console.log("============  Setter Function of Contract No. ", r);
      var myget = await finalSettersFunctions(myReceipt, r,j);
    console.log("============ NORMAL ORDER Status Functions of Contract No. ", r);
        var myset =await finalGetStatus(prvResult, myReceipt);
      }
    }
  }
}
main().then(() => {
    console.log("ALL has been DONE !")
  })

and myData is all my testcases/parameters like this [c1(constructor), g1, g2, s1, s2, s3, g3, g4, s4, g5, g6.........]... it should be noted that these values are encoded pareamters like this [0x000000, 0x123fs000, ........, 0x23abc220000]and also noted that myData contain millions of such testcase..

Ganche GUI version: v2.1.2 Web3 version: [email protected] Node version: v10.17.0 Windows 10

Source Link
Amir Ali
  • 447
  • 6
  • 18

Ganache become disconnected after some hours

I am running my program to deploy thousand of contracts and millions of transaction to interact with them, which definitely need a lot of hours. But, when i let my program running during night (without using my laptop at all), then Ganache GUI become disconnected after some hours, which cause my program to stop. and my program shows this error Error: Invalid JSON RPC response: ""

It should be noted that i turned off all option of auto sleep and choose Never/Do nothing options. Why Ganache become unresponsive after some hours ? Is there any way to keep Ganache running all the time ?