0.1.6 • Published 5 years ago

hobbits-js v0.1.6

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago