Javascript implementation of hobbits(wire protocol for ethereum 2.0 network testing)
https://ns55ai.github.io/hobbits-js/index.html
npm install hobbits-js
Run mocha tests
npm test
Conformance test server
npm run ping
Encode a message
let msg = new Message('EWP','0.2', 'RPC','','{"id":1,"method_id":0x00}');
encoded = encode(msg)
print(encoded)
Decode a message
msg = 'EWP 0.2 RPC 0 25\n{"id":1,"method_id":0x00}'
decoded = decode(msg)
print(JSON.stringify(decoded))
Here is a demo server
server.listen(PORT,HOST,function() {
console.log("Server is listening on "+HOST+":"+PORT);
});
const client = new net.Socket();
const payload = "EWP 0.2 RPC 0 25\n{\"id\":1,\"method_id\":0x00}";
client.connect(PORT, HOST, function() {
client.write(payload);
});
client.on("data", function(data) {
const pongOutput = data.toString("utf-8")
if(payload===pongOutput) {
console.log("Test Passed: PONG OUTPUT === PING PAYLOAD");
}
client.destroy();
});
MIT