public void TestSimpleDatabaseStoreLeaseSetEd25519Creation() { var linfo = new I2PLeaseInfo(Public, PublicSigningEd25519, Private, PrivateSigningEd25519); var leases = new List <I2PLease>(); for (int i = 0; i < 5; ++i) { leases.Add(new I2PLease(new I2PIdentHash(true), (uint)((i * 72 + 6) * i * 1314 + 5) % 40000, I2PDate.Now)); } var ls = new I2PLeaseSet(new I2PDestination(Public, PublicSigningEd25519), leases, linfo); var dbsm = new DatabaseStoreMessage(ls); var data = dbsm.Header16.HeaderAndPayload; var recreated = I2NPMessage.ReadHeader16(new BufRefLen(data)); Assert.IsTrue(recreated.MessageType == I2NPMessage.MessageTypes.DatabaseStore); var rdsm = (DatabaseStoreMessage)recreated.Message; Assert.IsTrue(rdsm.LeaseSet.Leases.Count == 5); Assert.IsTrue(BufUtils.Equal(ls.Destination.ToByteArray(), rdsm.LeaseSet.Destination.ToByteArray())); Assert.IsTrue(BufUtils.Equal(ls.PublicKey.ToByteArray(), rdsm.LeaseSet.PublicKey.ToByteArray())); Assert.IsTrue(BufUtils.Equal(ls.PublicSigningKey.ToByteArray(), rdsm.LeaseSet.PublicSigningKey.ToByteArray())); for (int i = 0; i < 5; ++i) { Assert.IsTrue(BufUtils.Equal(ls.Leases[i].ToByteArray(), rdsm.LeaseSet.Leases[i].ToByteArray())); } Assert.IsTrue(rdsm.LeaseSet.VerifySignature()); }
public CreateLeaseSetMessage( I2PDestination dest, ushort sessionid, I2PLeaseInfo info, List <I2PLease> leases) : base(ProtocolMessageType.CreateLS) { SessionId = sessionid; Info = info; Leases = new I2PLeaseSet(dest, leases, info); }
public void TestSimpleDatabaseStoreLeaseSetCreation() { var linfo = new I2PLeaseInfo(Public, PublicSigning, Private, PrivateSigning); var leases = new List <I2PLease>(); for (int i = 0; i < 5; ++i) { leases.Add(new I2PLease( new I2PIdentHash(true), new I2PTunnelId())); } var ls = new I2PLeaseSet(new I2PDestination(Public, PublicSigning), leases, linfo); var dbsm = new DatabaseStoreMessage(ls); var data = dbsm.CreateHeader16.HeaderAndPayload.Clone(); var recreated = I2NPMessage.ReadHeader16(new BufRefLen(data)); Assert.IsTrue(recreated.MessageType == I2NPMessage.MessageTypes.DatabaseStore); var rdsm = (DatabaseStoreMessage)recreated.Message; Assert.IsTrue(rdsm.LeaseSet.Leases.Count() == 5); Assert.IsTrue(BufUtils.Equal(ls.Destination.ToByteArray(), rdsm.LeaseSet.Destination.ToByteArray())); Assert.IsTrue(BufUtils.Equal(ls.PublicKey.ToByteArray(), rdsm.LeaseSet.PublicKey.ToByteArray())); Assert.IsTrue(BufUtils.Equal(ls.PublicSigningKey.ToByteArray(), rdsm.LeaseSet.PublicSigningKey.ToByteArray())); var rdsmlsar = rdsm.LeaseSet.Leases.ToArray(); var lsar = ls.Leases.ToArray(); // Order should be maintained for (int i = 0; i < 5; ++i) { Assert.IsTrue( BufUtils.Equal( lsar[i].ToByteArray(), rdsmlsar[i].ToByteArray())); } Assert.IsTrue(rdsm.LeaseSet.VerifySignature(PublicSigning)); }