public void TestBloqueGenesis() { Manager man = Manager.Instance; DateTime ini = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); man.Inicializar(ini); Bloque gen = man.GetBloqueIndice(0); Assert.AreEqual(0, gen.GetIndice()); Assert.AreEqual("00000", gen.GetNombre()); Assert.AreEqual("00000", gen.GetMotivo()); Assert.AreEqual("00000", gen.GetFileHash()); Assert.AreEqual("00000", gen.GetPrevHash()); Assert.AreEqual("fc5ab006e039fa9c10fae52c08d2eba8b52a04b27548b36612586c9c442d4b89", gen.GetHash()); }
public void TestDeBlockchain_TraeBloquePorIndice() { Manager man = Manager.Instance; DateTime pfech = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); DateTime now = new DateTime(2021, 4, 20, 12, 30, 00, 00, System.DateTimeKind.Utc); man.Inicializar(now); man.AgregarBloque("manuel", "enfermedad", "certmed.pdf", pfech); man.AgregarBloque("jose", "vacaciones", "solicitud.doc", pfech); man.AgregarBloque("arturo", "licencia", "licencia.pdf", pfech); man.AgregarBloque("arturo", "vacaciones", "boletos.pdf", pfech); Bloque block = man.GetBloqueIndice(3); Bloque pre = man.GetBloqueIndice(2); Assert.AreEqual("arturo", block.GetNombre()); Assert.AreEqual("licencia", block.GetMotivo()); Assert.AreEqual("licencia.pdf", block.GetFileHash()); Assert.AreEqual(3, (int)block.GetIndice()); Assert.AreEqual(pre.GetHash(), block.GetPrevHash()); }
public void TestDeBloque() { Manager man = Manager.Instance; DateTime ini = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); man.Inicializar(ini); ulong p = 42; DateTime pfech = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); man.AgregarBloque("manuel", "enfermedad", "certmed.pdf", pfech); Bloque b1 = man.GetBloqueIndice(1); Assert.AreEqual("6/7/2001 12:30:00 PM", b1.GetFecha().ToString()); Assert.AreEqual("certmed.pdf", b1.GetFileHash()); Assert.AreEqual("031df73849ef340b02e8442b9cc9b1afdf78efae02041f2cc4962af80e8ad357", b1.GetHash()); Assert.AreEqual(1, b1.GetIndice()); Assert.AreEqual("enfermedad", b1.GetMotivo()); Assert.AreEqual("manuel", b1.GetNombre()); Assert.AreEqual(p, b1.GetNonce()); Assert.AreEqual("fc5ab006e039fa9c10fae52c08d2eba8b52a04b27548b36612586c9c442d4b89", b1.GetPrevHash()); }
public void CadenaCheck() { Manager man = Manager.Instance; ulong p = 58; DateTime ini = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); man.Inicializar(ini); DateTime fechapar = new DateTime(2001, 6, 12, 12, 30, 00, 00, System.DateTimeKind.Utc); DateTime fechaimpar = new DateTime(2001, 6, 7, 12, 30, 00, 00, System.DateTimeKind.Utc); for (int i = 1; i <= 100; i++) { if (i % 2 == 0) { man.AgregarBloque(String.Concat("bloque", i.ToString(), "@gmail.com"), "motivo", "motivo.doc", fechapar); } else if (i % 2 != 0) { man.AgregarBloque(String.Concat("bloque", i.ToString(), "@gmail.com"), "motivo", "motivo.doc", fechaimpar); } } Bloque b50 = man.GetBloqueIndice(50); Assert.AreEqual("6/12/2001 12:30:00 PM", b50.GetFecha().ToString()); Assert.AreEqual("motivo.doc", b50.GetFileHash()); Assert.AreEqual("00a57c6f990750962dad825676f4f0ac7ffc66365c4decacf68d42f03c304baf", b50.GetHash()); Assert.AreEqual(50, b50.GetIndice()); Assert.AreEqual("motivo", b50.GetMotivo()); Assert.AreEqual("*****@*****.**", b50.GetNombre()); Assert.AreEqual(p, b50.GetNonce()); Assert.AreEqual("0cf51538490e85eb2bcbe99886ddd33c504e341a1d342944a1d72ffe9147a31b", b50.GetPrevHash()); Assert.AreEqual(man.GetBloqueIndice(49), man.GetBloquePorHash("0cf51538490e85eb2bcbe99886ddd33c504e341a1d342944a1d72ffe9147a31b")); Assert.AreEqual("*****@*****.**", man.GetBloqueIndice(100).GetNombre()); Bloque b90 = man.GetBloqueIndice(90); Assert.AreEqual("00bffae1ff83525f39ec4f3fd3c0bc9a754f0d28a0438a0ac018f163e7c07452", b90.GetHash()); Assert.AreEqual(man.Hash256(b90), "00bffae1ff83525f39ec4f3fd3c0bc9a754f0d28a0438a0ac018f163e7c07452"); }