hobbits-js
v0.1.6
Published
Javascript implementation of hobbits(wire protocol for ethereum 2.0 network testing)
Downloads
2
Maintainers
Readme
hobbits-js
Javascript implementation of hobbits(wire protocol for ethereum 2.0 network testing)
Documentation
https://ns55ai.github.io/hobbits-js/index.html
Installation
npm install hobbits-js
Tests
Run mocha tests
npm test
Conformance test server
npm run ping
Usage
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();
});
License
MIT