1

I have recently started developement on Ethereum and the concepts are pretty much new to me. I need to test event emitting/listening on multiple machines for my contract. For the same, I have tried creating a private network and adding peers. I have been stuck for a while now in submitting transactions to the network via a nodejs script. I had posted a question for that purpose Question 1, Question 2.

I am looking for another methods to do this thing. I have developed my contract on Truffle Suite. What is the an another alternate way to test these functionalities on multiple machines?

Thank you.

2
  • Why do you need multiple machines? Everything is added to the blockchain synchronously anyway, so you may as well do your testing on a single machine. Commented Nov 4, 2019 at 9:36
  • It's a requirement of the overall project. Some machines will be always running scripts to listen to emitted events. Hence, we need to check this functionality. Also, I have read that event emitter work through web sockets only now. So, do we need to setup the network in such a way that it allows listening on web-sockets or is it just a property while deploying contract? Commented Nov 4, 2019 at 9:50

1 Answer 1

0

You can have a small private network of 2 or 3 nodes, for example using docker-compose.

There are a lots of tutorials out these explaining how to make sure that your nodes are connecting to each others, by passing the addresses explicitly.

If you don't like Docker, here is an example of how I setup a private net of 2 geth nodes using a Makefile: https://github.com/WeTrustPlatform/poa-interchain-node/blob/develop/dev/Makefile

Now what you want to achieve with monitoring events is a very common use case. There are APIs in multiple languages to subscribe to these events, or list the past events.

But as @goodvibration said in his comment, you may as well have multiple process talking to a single node, because events will be pushed to your listener when the block is mined, so having multiple nodes is useless.

I would go even further and say that if your information system rely on Ethereum, and you want to avoid sync issues, you'd better have all your services pointing to the same RPC endpoint. It's a very common source of UI bugs, when people have their client connected to let say infura.io, and their server to a hosted geth node, if the two nodes are a bit out of sync your system will have to handle that. By using a single endpoint you avoid a lot of complexity.

1
  • thanks for the answer. I will currently work with a single node and expose it's RPC endpoint to all the services. But, I still am not submit transactions via a node script to my private network. The complete problem is stated in my second question: ethereum.stackexchange.com/questions/77115/…. Do you think I am missing anything in there for which it doesn't work? Commented Nov 5, 2019 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.