public static void SetupBlockWithValues(Block block, UInt256 val256, out UInt256 merkRootVal, out UInt160 val160, out uint timestampVal, out uint indexVal, out ulong consensusDataVal, out Witness scriptVal, out Transaction[] transactionsVal, int numberOfTransactions) { setupBlockBaseWithValues(block, val256, out merkRootVal, out val160, out timestampVal, out indexVal, out consensusDataVal, out scriptVal); transactionsVal = new Transaction[numberOfTransactions]; if (numberOfTransactions > 0) { for (int i = 0; i < numberOfTransactions; i++) { transactionsVal[i] = TestUtils.GetMinerTransaction(); } } block.Transactions = transactionsVal; }
public void CalculateNetFee_Ignores_MinerTransactions() { UInt256 val256 = UInt256.Zero; UInt256 merkRootVal; UInt160 val160; uint timestampVal, indexVal; ulong consensusDataVal; Witness scriptVal; Transaction[] transactionsVal; TestUtils.SetupBlockWithValues(uut, val256, out merkRootVal, out val160, out timestampVal, out indexVal, out consensusDataVal, out scriptVal, out transactionsVal, 0); uut.Transactions = new Transaction[1] { TestUtils.GetMinerTransaction() }; Block.CalculateNetFee(uut.Transactions).Should().Be(Fixed8.Zero); }
public void FromTrimmedData() { UInt256 val256 = UInt256.Zero; UInt256 merkRoot; UInt160 val160; uint timestampVal, indexVal; ulong consensusDataVal; Witness scriptVal; Transaction[] transactionsVal; TestUtils.SetupBlockWithValues(new Block(), val256, out merkRoot, out val160, out timestampVal, out indexVal, out consensusDataVal, out scriptVal, out transactionsVal, 1); byte[] data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 87, 42, 69, 155, 149, 217, 19, 107, 122, 113, 60, 84, 133, 202, 112, 159, 158, 250, 79, 8, 241, 194, 93, 215, 146, 103, 45, 43, 215, 91, 251, 128, 171, 4, 253, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 81, 1, 214, 87, 42, 69, 155, 149, 217, 19, 107, 122, 113, 60, 84, 133, 202, 112, 159, 158, 250, 79, 8, 241, 194, 93, 215, 146, 103, 45, 43, 215, 91, 251 }; uut = Block.FromTrimmedData(data, 0, x => TestUtils.GetMinerTransaction()); assertStandardBlockTestVals(val256, merkRoot, val160, timestampVal, indexVal, consensusDataVal, scriptVal, transactionsVal); uut.Transactions[0].Should().Be(TestUtils.GetMinerTransaction()); }
public void Size_Get_1_Transaction() { UInt256 val256 = UInt256.Zero; UInt256 merkRootVal; UInt160 val160; uint timestampVal, indexVal; ulong consensusDataVal; Witness scriptVal; Transaction[] transactionsVal; TestUtils.SetupBlockWithValues(uut, val256, out merkRootVal, out val160, out timestampVal, out indexVal, out consensusDataVal, out scriptVal, out transactionsVal, 0); uut.Transactions = new Transaction[1] { TestUtils.GetMinerTransaction() }; // blockbase 4 + 32 + 32 + 4 + 4 + 8 + 20 + 1 + 3 // block 11 uut.Size.Should().Be(119); }