示例#1
0
        public void DoesTransactionFollowPolicy()
        {
            var validKey = new PrivateKey();

            bool IsSignerValid(Transaction <DumbAction> tx)
            {
                var validAddress = validKey.PublicKey.ToAddress();

                return(tx.Signer.Equals(validAddress));
            }

            var policy = new BlockPolicy <DumbAction>(doesTransactionFollowPolicy: IsSignerValid);

            // Valid Transaction
            var validTx  = _chain.MakeTransaction(validKey, new DumbAction[] { });
            var expected = policy.DoesTransactionFollowsPolicy(validTx);

            Assert.True(expected);

            // Invalid Transaction
            var invalidKey = new PrivateKey();
            var invalidTx  = _chain.MakeTransaction(invalidKey, new DumbAction[] { });

            expected = policy.DoesTransactionFollowsPolicy(invalidTx);
            Assert.False(expected);
        }