public void Setup() { _subject = new ResultWrapper(new SubsonicServiceConfiguration(), 10); }
public ResultWrapper <bool?> eth_submitHashrate(string hashRate, string id) { return(ResultWrapper <bool?> .Fail("eth_submitHashrate not supported", ErrorType.MethodNotFound, null)); }
public ResultWrapper <Address> eth_coinbase() { return(ResultWrapper <Address> .Success(Address.Zero)); }
public ResultWrapper <BigInteger?> eth_newPendingTransactionFilter() { int filterId = _blockchainBridge.NewPendingTransactionFilter(); return(ResultWrapper <BigInteger?> .Success(filterId)); }
public ResultWrapper <IEnumerable <byte[]> > eth_getWork() { return(ResultWrapper <IEnumerable <byte[]> > .Fail("eth_getWork not supported")); }
public ResultWrapper <BigInteger?> eth_hashrate() { return(ResultWrapper <BigInteger?> .Success(0)); }
public ResultWrapper <string> eth_protocolVersion() { return(ResultWrapper <string> .Success("62")); }
public ResultWrapper <Address> net_localAddress() { return(ResultWrapper <Address> .Success(_netBridge.LocalAddress)); }
public ResultWrapper <string> net_localEnode() { return(ResultWrapper <string> .Success(_netBridge.LocalEnode)); }
public ResultWrapper <IEnumerable <byte[]> > eth_getWork() { return(ResultWrapper <IEnumerable <byte[]> > .Fail("eth_getWork not supported", ErrorCodes.MethodNotFound)); }
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); }
public ResultWrapper <UInt256?> eth_newPendingTransactionFilter() { int filterId = _blockchainBridge.NewPendingTransactionFilter(); return(ResultWrapper <UInt256?> .Success((UInt256)filterId)); }
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))); }
public Task <ResultWrapper <long?> > eth_blockNumber() { long number = _blockchainBridge.BeamHead?.Number ?? 0; return(Task.FromResult(ResultWrapper <long?> .Success(number))); }
public ResultWrapper <UInt256?> eth_gasPrice() { return(ResultWrapper <UInt256?> .Success(20.GWei())); }
public ResultWrapper <string> net_version() { return(ResultWrapper <string> .Success(_netBridge.NetworkId.ToString())); }
public ResultWrapper <bool?> eth_mining() { return(ResultWrapper <bool?> .Success(false)); }
public ResultWrapper <bool> net_listening() { return(ResultWrapper <bool> .Success(false)); }
public ResultWrapper <BigInteger?> eth_gasPrice() { return(ResultWrapper <BigInteger?> .Success(20.GWei())); }
public ResultWrapper <BigInteger> net_peerCount() { return(ResultWrapper <BigInteger> .Success(_netBridge.PeerCount)); }
public ResultWrapper <BigInteger?> eth_newBlockFilter() { int filterId = _blockchainBridge.NewBlockFilter(); return(ResultWrapper <BigInteger?> .Success(filterId)); }
public ResultWrapper <bool> net_dumpPeerConnectionDetails() { var result = _netBridge.LogPeerConnectionDetails(); return(ResultWrapper <bool> .Success(result)); }
public ResultWrapper <bool?> eth_uninstallFilter(BigInteger filterId) { _blockchainBridge.UninstallFilter((int)filterId); return(ResultWrapper <bool?> .Success(true)); }
public ResultWrapper <Address[]> personal_listAccounts() { return(ResultWrapper <Address[]> .Success(_bridge.ListAccounts())); }
public ResultWrapper <bool?> eth_submitWork(byte[] nonce, Keccak headerPowHash, byte[] mixDigest) { return(ResultWrapper <bool?> .Fail("eth_submitWork not supported", ErrorType.MethodNotFound, null)); }
public ResultWrapper <bool> personal_lockAccount(Address address) { _bridge.LockAccount(address); return(ResultWrapper <bool> .Success(true)); }
public ResultWrapper <byte[]> eth_snapshot() { return(ResultWrapper <byte[]> .Fail("eth_snapshot not supported")); }
public ResultWrapper <bool> parity_clearEngineSigner() { _signerStore.SetSigner((ProtectedPrivateKey)null); return(ResultWrapper <bool> .Success(true)); }
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());
public ResultWrapper <string> parity_enode() => ResultWrapper <string> .Success(_enode.ToString());
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$$"), } }; }
public ResultWrapper <UInt256?> eth_hashrate() { return(ResultWrapper <UInt256?> .Success(0)); }