コード例 #1
0
        public void SendTo_NotAContract_Success()
        {
            var walletAddress = new uint160(321);

            var state = new Mock <IStateRepositoryRoot>();

            state.Setup(x => x.GetAccountState(walletAddress)).Returns <AccountState>(null);

            Transaction transaction = this.network.CreateTransaction();

            transaction.Outputs.Add(new TxOut(100, PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(new KeyId(walletAddress))));
            P2PKHNotContractRule.CheckTransaction(state.Object, transaction);
        }
コード例 #2
0
        public void SendTo_Contract_Fails()
        {
            var contractAddress = new uint160(123);

            var state = new Mock <IStateRepositoryRoot>();

            state.Setup(x => x.GetAccountState(contractAddress)).Returns(new AccountState()); // not null

            Transaction transaction = this.network.CreateTransaction();

            transaction.Outputs.Add(new TxOut(100, PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(new KeyId(contractAddress))));
            Assert.Throws <ConsensusErrorException>(() => P2PKHNotContractRule.CheckTransaction(state.Object, transaction));
        }
        public void SendTo_Contract_Fails()
        {
            uint160 contractAddress = new uint160(123);

            var state = new Mock <IStateRepositoryRoot>();

            state.Setup(x => x.GetAccountState(contractAddress)).Returns(new AccountState()); // not null
            this.rulesEngine.OriginalStateRoot = state.Object;

            var rule = new P2PKHNotContractRule();

            rule.Parent = this.rulesEngine;
            rule.Initialize();

            Transaction transaction = this.network.CreateTransaction();

            transaction.Outputs.Add(new TxOut(100, PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(new KeyId(contractAddress))));
            Assert.Throws <ConsensusErrorException>(() => rule.CheckTransaction(new MempoolValidationContext(transaction, null)));
        }
        public void SendTo_NotAContract_Success()
        {
            uint160 walletAddress = new uint160(321);

            var state = new Mock <IStateRepositoryRoot>();

            state.Setup(x => x.GetAccountState(walletAddress)).Returns <AccountState>(null);
            this.rulesEngine.OriginalStateRoot = state.Object;

            var rule = new P2PKHNotContractRule();

            rule.Parent = this.rulesEngine;
            rule.Initialize();

            Transaction transaction = this.network.CreateTransaction();

            transaction.Outputs.Add(new TxOut(100, PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(new KeyId(walletAddress))));
            rule.CheckTransaction(new MempoolValidationContext(transaction, null));
        }
コード例 #5
0
 public override void CheckTransaction(MempoolValidationContext context)
 {
     P2PKHNotContractRule.CheckTransaction(this.stateRepositoryRoot, context.Transaction);
 }