hobbits-js

0.1.6 • Public • Published

hobbits-js

Javascript implementation of hobbits(wire protocol for ethereum 2.0 network testing)

npm version Build Status codecov Codacy Badge

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

Package Sidebar

Install

npm i hobbits-js

Weekly Downloads

9

Version

0.1.6

License

MIT

Unpacked Size

1.06 MB

Total Files

42

Last publish

Collaborators

  • ns55ai