it('to view', function(){ var oa = a3.Output(uint.mk(4, 0xffffffff), uint.mk(2, 0xffff)); expect(oa.bytes().value()).to.equal(16); expect(oa.header.length.value()).to.equal(16); var buf = new Buffer(oa.bytes().value()); var v = new view.View(buf); oa.toView(v); });
function Header(args) { if(args) { this.version = _(args.version).isFinite() ? args.version : null; this.type = _(args.type).isFinite() ? args.type : null; this.length = args.length || bytes(); this.xid = args.xid || uint.mk(4, Math.floor((Math.random() * 0xffffffff) + 1)); } else { this.version = null; this.type = null; this.length = bytes(); this.xid = uint.mk(4, Math.floor((Math.random() * 0xffffffff) + 1)); } }
function Address(address) { if(address){ } else { this._value = uint.mk(4, 0); //new uint.UInt({ bytes: 4 }); } }
it('from view', function(){ var buf2 = new Buffer(8); var v2 = new view.View(buf2); var o = a.Output({ port: uint.mk(2, 1), max_len: uint.mk(2, 1) }); o.toView(v2); });