public async Task OpSpend_PreviousTransactionOpCall_SuccessAsync() { TestRulesContext testContext = TestRulesContextFactory.CreateAsync(this.network); OpSpendRule rule = testContext.CreateRule <OpSpendRule>(); var context = new RuleContext(new ValidationContext(), testContext.DateTimeProvider.GetTimeOffset()); context.ValidationContext.BlockToValidate = testContext.Network.Consensus.ConsensusFactory.CreateBlock(); context.ValidationContext.BlockToValidate.Header.HashPrevBlock = testContext.Chain.Tip.HashBlock; context.ValidationContext.BlockToValidate.Transactions = new List <Transaction> { new Transaction() { Outputs = { new TxOut(Money.Zero, new Script(new [] { (byte)ScOpcodeType.OP_CALLCONTRACT })) } }, new Transaction() { Outputs = { new TxOut(new Money(1000), new Script(new [] { (byte)ScOpcodeType.OP_SPEND })) } } }; await rule.RunAsync(context); }
public async Task OpSpend_PreviousTransactionOther_FailureAsync() { TestRulesContext testContext = TestRulesContextFactory.CreateAsync(this.network); OpSpendRule rule = testContext.CreateRule <OpSpendRule>(); var context = new RuleContext(new ValidationContext(), testContext.DateTimeProvider.GetTimeOffset()); context.ValidationContext.BlockToValidate = testContext.Network.Consensus.ConsensusFactory.CreateBlock(); context.ValidationContext.BlockToValidate.Header.HashPrevBlock = testContext.Chain.Tip.HashBlock; context.ValidationContext.BlockToValidate.Transactions = new List <Transaction> { new Transaction() { Outputs = { new TxOut(Money.Zero, new Script(OpcodeType.OP_NOP)) } }, new Transaction() { Outputs = { new TxOut(Money.Zero, new Script(OpcodeType.OP_NOP)) } }, new Transaction() { Outputs = { new TxOut(Money.Zero, new Script(OpcodeType.OP_NOP)) } }, new Transaction() { Inputs = { new TxIn(new Script(new [] { (byte)ScOpcodeType.OP_SPEND })) } } }; await Assert.ThrowsAsync <ConsensusErrorException>(async() => await rule.RunAsync(context)); }