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); }
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)); }
public override void CheckTransaction(MempoolValidationContext context) { P2PKHNotContractRule.CheckTransaction(this.stateRepositoryRoot, context.Transaction); }