private static void EraTesting() { var t1 = Era.Decode(Utils.HexToByteArray("0x1503")); Console.WriteLine($"NODE: {t1}"); var t2 = Era.Decode(Utils.HexToByteArray("0xD503")); Console.WriteLine($" API: {t2}"); var t3 = Era.Create(64, 15793); Console.WriteLine($" API: {t3}"); ulong currentBlockNumber = (ulong)15689; var lastBit = currentBlockNumber & (ulong)-(long)currentBlockNumber; var nextPowerOf2 = Math.Pow(2, Math.Round(Math.Log(15689, 2))); Console.WriteLine($"currentBlockNumber[{currentBlockNumber}]: {Math.Round(Math.Log(15689, 2))} {nextPowerOf2}"); }
public void EraEncodeDecodeTest() { var era1 = Era.Decode(new byte[] { 58, 6 }); Assert.AreEqual(2048, era1.Period); Assert.AreEqual(99, era1.Phase); Assert.AreEqual(new byte[] { 58, 6 }, era1.Encode()); var era2 = Era.Decode(Utils.HexToByteArray("0x4503")); Assert.AreEqual(64, era2.Period); Assert.AreEqual(52, era2.Phase); Assert.AreEqual(new byte[] { 69, 3 }, era2.Encode()); var era3 = Era.Decode(Utils.HexToByteArray("0xF502")); Assert.AreEqual(64, era3.Period); Assert.AreEqual(47, era3.Phase); Assert.AreEqual(new byte[] { 245, 2 }, era3.Encode()); }