private static void SetPriority(
     IDictionaryContractDataStore <TxPriorityContract.Destination> priorities,
     BlockHeader blockHeader,
     Address target,
     byte[] prioritizedFnSignature,
     UInt256 value)
 {
     priorities.TryGetValue(blockHeader,
                            Arg.Is <TxPriorityContract.Destination>(d => d.Target == target && Bytes.AreEqual(d.FnSignature, prioritizedFnSignature)),
                            out Arg.Any <TxPriorityContract.Destination>())
     .Returns(x =>
     {
         x[2] = new TxPriorityContract.Destination(target, prioritizedFnSignature, value);
         return(true);
     });
 }
Example #2
0
        public bool is_allowed_returns_correct(Address address, ulong gasLimit)
        {
            ITxFilter minGasPriceFilter = new MinGasPriceTxFilter(UInt256.One);
            IDictionaryContractDataStore <TxPriorityContract.Destination> dictionaryContractDataStore = Substitute.For <IDictionaryContractDataStore <TxPriorityContract.Destination> >();

            dictionaryContractDataStore.TryGetValue(
                Arg.Any <BlockHeader>(),
                Arg.Is <TxPriorityContract.Destination>(d => d.Target == TestItem.AddressA),
                out Arg.Any <TxPriorityContract.Destination>())
            .Returns(x =>
            {
                x[2] = new TxPriorityContract.Destination(TestItem.AddressA, Array.Empty <byte>(), 5);
                return(true);
            });

            var txFilter = new MinGasPriceContractTxFilter(minGasPriceFilter, dictionaryContractDataStore);
            var tx       = Build.A.Transaction.WithTo(address).WithGasPrice(gasLimit).TestObject;

            return(txFilter.IsAllowed(tx, Build.A.BlockHeader.TestObject));
        }