public void CanCalculateDifficulty() { var main = new ConcurrentChain(LoadMainChain(), Network.Main); var histories = File.ReadAllText("data/targethistory.csv").Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (var history in histories) { var height = int.Parse(history.Split(',')[0]); var expectedTarget = new Target(new BouncyCastle.Math.BigInteger(history.Split(',')[1], 10)); var block = main.GetBlock(height).Header; Assert.Equal(expectedTarget, block.Bits); var target = main.GetWorkRequired(Network.Main, height); Assert.Equal(expectedTarget, target); } }
public void CanCalculateDifficulty() { var main = new ConcurrentChain(this.network, this.LoadMainChain()); // The state of the line separators may be affected by copy operations - so do an environment independent line split... string[] histories = File.ReadAllText(TestDataLocations.GetFileFromDataFolder("targethistory.csv")).Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string history in histories) { int height = int.Parse(history.Split(',')[0]); var expectedTarget = new Target(new BouncyCastle.Math.BigInteger(history.Split(',')[1], 10)); BlockHeader block = main.GetBlock(height).Header; Assert.Equal(expectedTarget, block.Bits); Target target = main.GetWorkRequired(this.network, height); Assert.Equal(expectedTarget, target); } }
public void CanCalculateDifficulty() { var histories = File.ReadAllLines("data/targethistory.csv"); var store = new BlockStore(@"download\blocks", Network.Main); // todo: load the chain with a heder only file ConcurrentChain chain = store.GetChain(); foreach (var history in histories) { var height = int.Parse(history.Split(',')[0]); var expectedTarget = new Target(BigInteger.Parse(history.Split(',')[1])); var block = chain.GetBlock(height).Header; Assert.Equal(expectedTarget, block.Bits); var target = chain.GetWorkRequired(Network.Main, height); Assert.Equal(expectedTarget, target); } }
public void CanCalculateDifficulty() { var histories = File.ReadAllLines(TestDataLocations.DataFolder(@"targethistory.csv")); var store = new BlockStore(TestDataLocations.BlockFolderLocation, Network.Main); // todo: load the chain with a header only file ConcurrentChain chain = store.GetChain(); foreach (var history in histories) { var height = int.Parse(history.Split(',')[0]); var expectedTarget = new Target(new BigInteger(history.Split(',')[1].Trim(), 10)); var block = chain.GetBlock(height).Header; Assert.Equal(expectedTarget, block.Bits); var target = chain.GetWorkRequired(Network.Main, height); Assert.Equal(expectedTarget, target); } }
public void CanCalculateDifficulty() { var main = new ConcurrentChain(LoadMainChain()); var histories = File.ReadAllText("data/targethistory.csv").Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach(var history in histories) { var height = int.Parse(history.Split(',')[0]); var expectedTarget = new Target(BigInteger.Parse(history.Split(',')[1])); var block = main.GetBlock(height).Header; Assert.Equal(expectedTarget, block.Bits); var target = main.GetWorkRequired(Network.Main, height); Assert.Equal(expectedTarget, target); } }