public void Can_read_regression() { NetworkNodeDecoder networkNodeDecoder = new NetworkNodeDecoder(); Rlp encoded = new Rlp(Bytes.FromHexString("f8a7b84013a1107b6f78a4977222d2d5a4cd05a8a042b75222c8ec99129b83793eda3d214208d4e835617512fc8d148d3d1b4d89530861644f531675b1fb64b785c6c152953a3a666666663a38352e3131322e3131332e3138368294c680ce0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); NetworkNode decoded = networkNodeDecoder.Decode(encoded.Bytes.AsRlpStream()); Assert.AreEqual("::ffff:85.112.113.186", decoded.Host); Assert.AreEqual(new PublicKey(Bytes.FromHexString("0x13a1107b6f78a4977222d2d5a4cd05a8a042b75222c8ec99129b83793eda3d214208d4e835617512fc8d148d3d1b4d89530861644f531675b1fb64b785c6c152")), decoded.NodeId); Assert.AreEqual(38086, decoded.Port); Assert.AreEqual(0L, decoded.Reputation); }
public void Negative_port_just_in_case_for_resilience() { NetworkNodeDecoder networkNodeDecoder = new NetworkNodeDecoder(); NetworkNode node = new NetworkNode(TestItem.PublicKeyA, "127.0.0.1", -1, -100L); Rlp encoded = networkNodeDecoder.Encode(node); NetworkNode decoded = networkNodeDecoder.Decode(encoded.Bytes.AsRlpStream()); Assert.AreEqual(node.Host, decoded.Host); Assert.AreEqual(node.NodeId, decoded.NodeId); Assert.AreEqual(node.Port, decoded.Port); Assert.AreEqual(node.Reputation, decoded.Reputation); }
public void Can_do_roundtrip_negative_reputation() { NetworkNodeDecoder networkNodeDecoder = new NetworkNodeDecoder(); NetworkNode node = new NetworkNode(TestItem.PublicKeyA, "127.0.0.1", 30303, -100L); Rlp encoded = networkNodeDecoder.Encode(node); NetworkNode decoded = networkNodeDecoder.Decode(encoded.Bytes.AsRlpStream()); Assert.AreEqual(node.Host, decoded.Host); Assert.AreEqual(node.NodeId, decoded.NodeId); Assert.AreEqual(node.Port, decoded.Port); Assert.AreEqual(node.Reputation, decoded.Reputation); }