public void Setup()
 {
     _subject = new ResultWrapper(new SubsonicServiceConfiguration(), 10);
 }
Пример #2
0
 public ResultWrapper <bool?> eth_submitHashrate(string hashRate, string id)
 {
     return(ResultWrapper <bool?> .Fail("eth_submitHashrate not supported", ErrorType.MethodNotFound, null));
 }
Пример #3
0
 public ResultWrapper <Address> eth_coinbase()
 {
     return(ResultWrapper <Address> .Success(Address.Zero));
 }
Пример #4
0
        public ResultWrapper <BigInteger?> eth_newPendingTransactionFilter()
        {
            int filterId = _blockchainBridge.NewPendingTransactionFilter();

            return(ResultWrapper <BigInteger?> .Success(filterId));
        }
Пример #5
0
 public ResultWrapper <IEnumerable <byte[]> > eth_getWork()
 {
     return(ResultWrapper <IEnumerable <byte[]> > .Fail("eth_getWork not supported"));
 }
Пример #6
0
 public ResultWrapper <BigInteger?> eth_hashrate()
 {
     return(ResultWrapper <BigInteger?> .Success(0));
 }
Пример #7
0
 public ResultWrapper <string> eth_protocolVersion()
 {
     return(ResultWrapper <string> .Success("62"));
 }
Пример #8
0
 public ResultWrapper <Address> net_localAddress()
 {
     return(ResultWrapper <Address> .Success(_netBridge.LocalAddress));
 }
Пример #9
0
 public ResultWrapper <string> net_localEnode()
 {
     return(ResultWrapper <string> .Success(_netBridge.LocalEnode));
 }
Пример #10
0
 public ResultWrapper <IEnumerable <byte[]> > eth_getWork()
 {
     return(ResultWrapper <IEnumerable <byte[]> > .Fail("eth_getWork not supported", ErrorCodes.MethodNotFound));
 }
Пример #11
0
        public void GetBlockByNumberTest()
        {
            IEthModule ethModule = Substitute.For <IEthModule>();

            ethModule.eth_getBlockByNumber(Arg.Any <BlockParameter>(), true).ReturnsForAnyArgs(x => ResultWrapper <BlockForRpc> .Success(new BlockForRpc(Build.A.Block.WithNumber(2).TestObject, true)));
            JsonRpcResponse response = TestRequest <IEthModule>(ethModule, "eth_getBlockByNumber", "0x1b4", "true");

            Assert.AreEqual((BigInteger)2, (response.Result as BlockForRpc)?.Number);
        }
Пример #12
0
        public ResultWrapper <UInt256?> eth_newPendingTransactionFilter()
        {
            int filterId = _blockchainBridge.NewPendingTransactionFilter();

            return(ResultWrapper <UInt256?> .Success((UInt256)filterId));
        }
Пример #13
0
        public ResultWrapper <string> eth_call(TransactionForRpc transactionCall, BlockParameter blockParameter = null)
        {
            SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter);

            if (searchResult.IsError)
            {
                return(ResultWrapper <string> .Fail(searchResult));
            }

            BlockHeader header = searchResult.Object;

            if (!HasStateForBlock(header))
            {
                return(ResultWrapper <string> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable));
            }

            FixCallTx(transactionCall, header);

            Transaction tx = transactionCall.ToTransaction();

            BlockchainBridge.CallOutput result = _blockchainBridge.Call(header, tx);

            return(result.Error != null ? ResultWrapper <string> .Fail("VM execution error.", ErrorCodes.ExecutionError, result.Error) : ResultWrapper <string> .Success(result.OutputData.ToHexString(true)));
        }
Пример #14
0
        public Task <ResultWrapper <long?> > eth_blockNumber()
        {
            long number = _blockchainBridge.BeamHead?.Number ?? 0;

            return(Task.FromResult(ResultWrapper <long?> .Success(number)));
        }
Пример #15
0
 public ResultWrapper <UInt256?> eth_gasPrice()
 {
     return(ResultWrapper <UInt256?> .Success(20.GWei()));
 }
Пример #16
0
 public ResultWrapper <string> net_version()
 {
     return(ResultWrapper <string> .Success(_netBridge.NetworkId.ToString()));
 }
Пример #17
0
 public ResultWrapper <bool?> eth_mining()
 {
     return(ResultWrapper <bool?> .Success(false));
 }
Пример #18
0
 public ResultWrapper <bool> net_listening()
 {
     return(ResultWrapper <bool> .Success(false));
 }
Пример #19
0
 public ResultWrapper <BigInteger?> eth_gasPrice()
 {
     return(ResultWrapper <BigInteger?> .Success(20.GWei()));
 }
Пример #20
0
 public ResultWrapper <BigInteger> net_peerCount()
 {
     return(ResultWrapper <BigInteger> .Success(_netBridge.PeerCount));
 }
Пример #21
0
        public ResultWrapper <BigInteger?> eth_newBlockFilter()
        {
            int filterId = _blockchainBridge.NewBlockFilter();

            return(ResultWrapper <BigInteger?> .Success(filterId));
        }
Пример #22
0
        public ResultWrapper <bool> net_dumpPeerConnectionDetails()
        {
            var result = _netBridge.LogPeerConnectionDetails();

            return(ResultWrapper <bool> .Success(result));
        }
Пример #23
0
 public ResultWrapper <bool?> eth_uninstallFilter(BigInteger filterId)
 {
     _blockchainBridge.UninstallFilter((int)filterId);
     return(ResultWrapper <bool?> .Success(true));
 }
Пример #24
0
 public ResultWrapper <Address[]> personal_listAccounts()
 {
     return(ResultWrapper <Address[]> .Success(_bridge.ListAccounts()));
 }
Пример #25
0
 public ResultWrapper <bool?> eth_submitWork(byte[] nonce, Keccak headerPowHash, byte[] mixDigest)
 {
     return(ResultWrapper <bool?> .Fail("eth_submitWork not supported", ErrorType.MethodNotFound, null));
 }
Пример #26
0
        public ResultWrapper <bool> personal_lockAccount(Address address)
        {
            _bridge.LockAccount(address);

            return(ResultWrapper <bool> .Success(true));
        }
Пример #27
0
 public ResultWrapper <byte[]> eth_snapshot()
 {
     return(ResultWrapper <byte[]> .Fail("eth_snapshot not supported"));
 }
Пример #28
0
 public ResultWrapper <bool> parity_clearEngineSigner()
 {
     _signerStore.SetSigner((ProtectedPrivateKey)null);
     return(ResultWrapper <bool> .Success(true));
 }
Пример #29
0
 public ResultWrapper <ParityTransaction[]> parity_pendingTransactions()
 => ResultWrapper <ParityTransaction[]> .Success(_txPool.GetPendingTransactions().Where(pt => pt.SenderAddress != null)
                                                 .Select(t => new ParityTransaction(t, Rlp.Encode(t).Bytes,
                                                                                    t.IsSigned ? _ecdsa.RecoverPublicKey(t.Signature, t.Hash) : null)).ToArray());
Пример #30
0
 public ResultWrapper <string> parity_enode() => ResultWrapper <string> .Success(_enode.ToString());
Пример #31
0
            public CustomStartupSequence BuildSequence(string targetPath, Dictionary<string, string> bspDict, Dictionary<string, string> debugMethodConfig, LiveMemoryLineHandler lineHandler)
            {
                if (!File.Exists(targetPath))
                    throw new Exception(targetPath + " not found. Debugging will not be possible.");

                bool stubFound = false;
                using (var elf = new ELFFile(targetPath))
                {
                    foreach (var sym in elf.LoadAllSymbols())
                    {
                        if (sym.Name == "gdbstub_init")
                        {
                            stubFound = true;
                            break;
                        }
                    }
                }

                if (!stubFound)
                {
                    var wrp = new ResultWrapper();
                    _SyncContext.Send(o => ((ResultWrapper)o).Result = MessageBox.Show("The programmed image does not contain the GDB stub. Do you want to open instructions on debugging with ESP8266 GDB stub?", "VisualGDB", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information), wrp);
                    switch(wrp.Result)
                    {
                        case DialogResult.Yes:
                            Process.Start("http://visualgdb.com/KB/esp8266gdbstub");
                            goto case DialogResult.Cancel;
                        case DialogResult.No:
                            break;
                        case DialogResult.Cancel:
                            throw new OperationCanceledException();
                    }
                }

                string val;
                if (!debugMethodConfig.TryGetValue("com.sysprogs.esp8266.program_flash", out val) || val != "0")
                {
                    var wrp = new ResultWrapper();
                    _SyncContext.Send(o => ((ResultWrapper)o).Result = MessageBox.Show("Please reboot your ESP8266 into the bootloader mode and press OK.", "VisualGDB", MessageBoxButtons.OKCancel, MessageBoxIcon.Information), wrp);
                    if (wrp.Result != DialogResult.OK)
                        throw new OperationCanceledException();

                    using (var serialPort = new SerialPortStream(debugMethodConfig["com.sysprogs.esp8266.gdbstub.com_port"], int.Parse(debugMethodConfig["com.sysprogs.esp8266.gdbstub.bl_baud"]), System.IO.Ports.Handshake.None))
                    {
                        serialPort.AllowTimingOutWithZeroBytes = true;
                        int resetDelay;
                        if (!debugMethodConfig.TryGetValue("com.sysprogs.esp8266.reset_delay", out val) || !int.TryParse(val, out resetDelay))
                            resetDelay = 25;

                        string seq;
                        debugMethodConfig.TryGetValue("com.sysprogs.esp8266.gdbstub.reset_sequence", out seq);
                        ESP8266BootloaderClient client = new ESP8266BootloaderClient(serialPort, resetDelay, seq);
                        client.Sync();
                        var regions = ESP8266StartupSequence.BuildFLASHImages(targetPath, bspDict, debugMethodConfig, lineHandler);

                        ProgramProgressForm frm = null;
                        _SyncContext.Post(o => { frm = new ProgramProgressForm(); frm.ShowDialog(); }, null);
                        int totalSize = 0;
                        foreach (var r in regions)
                            totalSize += r.Size;

                        ESP8266BootloaderClient.BlockWrittenHandler handler = (s, a, len) => frm.UpdateProgressAndThrowIfCanceled(a, len, totalSize);
                        bool useDIO = false;

                        try
                        {
                            client.BlockWritten += handler;
                            foreach (var r in regions)
                            {
                                var data = File.ReadAllBytes(r.FileName);
                                if (r.Offset == 0 && data.Length >= 4)
                                    useDIO = (data[2] == 2);

                                client.ProgramFLASH((uint)r.Offset, data);
                            }
                        }
                        finally
                        {
                            client.BlockWritten -= handler;
                            _SyncContext.Post(o => { frm.Close(); frm.Dispose(); }, null);
                        }

                        client.RunProgram(useDIO, false);
                    }
                }

                string tmp = null;
                if (debugMethodConfig?.TryGetValue("SYS:PROGRAM_WITHOUT_DEBUGGING", out tmp) == true && tmp == "1")
                    return null;    //Suppress connecting to gdb

                return new CustomStartupSequence
                {
                    Steps = new List<CustomStartStep> {
                        new CustomStartStep("set serial baud $$com.sysprogs.esp8266.gdbstub.baud$$"),
                        new CustomStartStep(@"target remote \\.\$$com.sysprogs.esp8266.gdbstub.com_port$$"),
                    }
                };
            }
Пример #32
0
 public ResultWrapper <UInt256?> eth_hashrate()
 {
     return(ResultWrapper <UInt256?> .Success(0));
 }