0

I am running a test which involves sending transactions to a smart contract from multiple nodes. Right now, I have seperate truffle folders in each node, with a test file that sends the transactions to the right contract. In addition, the first node's test file includes additional logic (apart from sending the transactions) that monitors the generated events from all transactions and makes calculations. From my understanding, there is no way to implement this logic in a single test file as truffle uses the config file to open only 1 connection and it is not possible to have multiple connections in 1 truffle instance?

  • Sounds about right AFAIK. – goodvibration Mar 10 at 17:00
  • I wish I created my tests using web3 myself rather than using truffle test but I reckon it is too late for that at this point – Aleksi Daskalov Mar 10 at 17:03
  • Not really. Just a little bit of porting work is all it takes... You'll need to create the web3 = new Web3(...) instance given to you by Truffle "for free" yourself, but that's about it. If you're on Truffle 4.x or lower and your web3.js version is 1.x or higher, then you'll need to do some more work in adjusting your code. But all in all, it shouldn't be that difficult. – goodvibration Mar 10 at 17:05
  • 1
    If it isn't too long, then you can post it here and ask specific questions on how to do the porting (don't forget to specify both your Truffle version and your Web3 version). – goodvibration Mar 10 at 17:12
  • pastebin.com/eUPrqZcZ That's the code I used with 1 node sending all the transactions. I would have to modify it a bit so that they are send from 5 nodes. My issue with using different truffle tests is that I cannot get the individual transaction submission times into the array to be used in the calculations. As for changing it to using web3, what I am unsure about is how to get the contract instance ( as in truffle I use artifacts.require + the address of the contract on the chain). – Aleksi Daskalov Mar 10 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.