Initial update for the bitmessage-js package #1
14
test.js
14
test.js
|
@ -296,7 +296,7 @@ describe("Common structures", function() {
|
||||||
res = var_int.decode(Buffer.from("7b", "hex"));
|
res = var_int.decode(Buffer.from("7b", "hex"));
|
||||||
expect(res.value).to.equal(123);
|
expect(res.value).to.equal(123);
|
||||||
expect(res.length).to.equal(1);
|
expect(res.length).to.equal(1);
|
||||||
expect(res.rest.toString("hex")).to.equal("")
|
expect(res.rest.toString("hex")).to.equal("");
|
||||||
|
|
||||||
res = var_int.decode(Buffer.from("fd123456", "hex"));
|
res = var_int.decode(Buffer.from("fd123456", "hex"));
|
||||||
expect(res.value).to.equal(0x1234);
|
expect(res.value).to.equal(0x1234);
|
||||||
|
@ -410,7 +410,7 @@ describe("Common structures", function() {
|
||||||
expect(res.port).to.equal(8444);
|
expect(res.port).to.equal(8444);
|
||||||
|
|
||||||
expect(net_addr.decode.bind(null, Buffer.from(
|
expect(net_addr.decode.bind(null, Buffer.from(
|
||||||
"000000000000000100000000000000000000ffff7f00000120fc", "hex"))).to.throw(Error);;
|
"000000000000000100000000000000000000ffff7f00000120fc", "hex"))).to.throw(Error);
|
||||||
|
|
||||||
res = net_addr.decode(Buffer.from("000000000000000100000000000000000000ffff7f00000120fc", "hex"), {short: true});
|
res = net_addr.decode(Buffer.from("000000000000000100000000000000000000ffff7f00000120fc", "hex"), {short: true});
|
||||||
expect(res.services.get(ServicesBitfield.NODE_NETWORK)).to.be.true;
|
expect(res.services.get(ServicesBitfield.NODE_NETWORK)).to.be.true;
|
||||||
|
@ -793,7 +793,7 @@ describe("Object types", function() {
|
||||||
ttl: 100,
|
ttl: 100,
|
||||||
to: "2cTux3PGRqHTEH6wyUP2sWeT4LrsGgy63z",
|
to: "2cTux3PGRqHTEH6wyUP2sWeT4LrsGgy63z",
|
||||||
}).then(function(payload) {
|
}).then(function(payload) {
|
||||||
expect(POW.check({ttl: 100, payload: payload})).to.be.true;;
|
expect(POW.check({ttl: 100, payload: payload})).to.be.true;
|
||||||
return getpubkey.decodePayloadAsync(payload);
|
return getpubkey.decodePayloadAsync(payload);
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
expect(res.ttl).to.be.at.most(100);
|
expect(res.ttl).to.be.at.most(100);
|
||||||
|
@ -877,7 +877,7 @@ describe("Object types", function() {
|
||||||
this.timeout(300000);
|
this.timeout(300000);
|
||||||
return pubkey.encodePayloadAsync({ttl: 789, from: from, to: from})
|
return pubkey.encodePayloadAsync({ttl: 789, from: from, to: from})
|
||||||
.then(function(payload) {
|
.then(function(payload) {
|
||||||
expect(POW.check({ttl: 789, payload: payload})).to.be.true;;
|
expect(POW.check({ttl: 789, payload: payload})).to.be.true;
|
||||||
return pubkey.decodePayloadAsync(payload, {needed: from});
|
return pubkey.decodePayloadAsync(payload, {needed: from});
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
expect(res.ttl).to.be.at.most(789);
|
expect(res.ttl).to.be.at.most(789);
|
||||||
|
@ -1001,7 +1001,7 @@ describe("Object types", function() {
|
||||||
to: from,
|
to: from,
|
||||||
message: "test",
|
message: "test",
|
||||||
}).then(function(payload) {
|
}).then(function(payload) {
|
||||||
expect(POW.check({ttl: 111, payload: payload})).to.be.true;;
|
expect(POW.check({ttl: 111, payload: payload})).to.be.true;
|
||||||
return msg.decodePayloadAsync(payload, {identities: from});
|
return msg.decodePayloadAsync(payload, {identities: from});
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
expect(res.ttl).to.be.at.most(111);
|
expect(res.ttl).to.be.at.most(111);
|
||||||
|
@ -1131,7 +1131,7 @@ describe("Object types", function() {
|
||||||
from: from,
|
from: from,
|
||||||
message: "test",
|
message: "test",
|
||||||
}).then(function(payload) {
|
}).then(function(payload) {
|
||||||
expect(POW.check({ttl: 101, payload: payload})).to.be.true;;
|
expect(POW.check({ttl: 101, payload: payload})).to.be.true;
|
||||||
return broadcast.decodePayloadAsync(payload, {subscriptions: from});
|
return broadcast.decodePayloadAsync(payload, {subscriptions: from});
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
expect(res.ttl).to.be.at.most(101);
|
expect(res.ttl).to.be.at.most(101);
|
||||||
|
@ -1412,7 +1412,7 @@ describe("High-level classes", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should encode bitmessage's user agent", function() {
|
it("should encode bitmessage's user agent", function() {
|
||||||
var res = UserAgent.decode(UserAgent.encodeSelf())
|
var res = UserAgent.decode(UserAgent.encodeSelf());
|
||||||
var software = UserAgent.parse(res.str);
|
var software = UserAgent.parse(res.str);
|
||||||
expect(software[0].name).to.equal("bitmessage");
|
expect(software[0].name).to.equal("bitmessage");
|
||||||
expect(software[0]).to.have.property("version");
|
expect(software[0]).to.have.property("version");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user