public CliApiBuilder(Engine engine, IJsonSerializer jsonSerializer, IJsonRpcClient client, ILogManager logManager) { _engine = engine; _serializer = jsonSerializer; _client = client; _logManager = logManager; }
public NdmContext MakeDeposit(Func <MakeDepositDto> deposit, string name = "Make deposit", Func <string, bool> validator = null, Action <NdmState, JsonRpcResponse <string> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_makeDeposit", () => client.PostAsync <string>(nameof(MakeDeposit), new object[] { deposit() }), validator, stateUpdater)); }
public NdmContext SendData(Func <DataAssetDataDto> data, string name = "Send data", Func <string, bool> validator = null, Action <NdmState, JsonRpcResponse <string> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_sendData", () => client.PostAsync <string>(nameof(SendData), new object[] { data() }), validator, stateUpdater)); }
public static async Task <(JsonRpcError Error, Hash TransactionHash)> TryDeploy( bool expectException, SolidityContractAttribute contractAttribute, IJsonRpcClient rpcClient, byte[] bytecode, TransactionParams sendParams, ReadOnlyMemory <byte> abiEncodedConstructorArgs = default) { // If we have no code, we shouldn't append our constructor arguments, so we blank ours out. if (bytecode == null || bytecode.Length == 0) { abiEncodedConstructorArgs = default; } // If constructor args are provided, append to contract bytecode. if (!abiEncodedConstructorArgs.IsEmpty) { sendParams.Data = new byte[bytecode.Length + abiEncodedConstructorArgs.Length]; Memory <byte> deploymentMem = new Memory <byte>(sendParams.Data); bytecode.CopyTo(deploymentMem); abiEncodedConstructorArgs.CopyTo(deploymentMem.Slice(bytecode.Length)); } else { sendParams.Data = bytecode; } return(await rpcClient.TrySendTransaction(sendParams, expectException)); }
public CliqueContext Propose(Address address, bool vote) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc($"vote {vote} for {address}", "clique_propose", () => client.PostAsync <string>("clique_propose", new object[] { address, vote }))); }
public CliqueContext Discard(Address address) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc($"discard vote for {address}", "clique_discard", () => client.PostAsync <string>("clique_discard", new object[] { address }))); }
public void SetUp() { _jsonSerializer = Substitute.For <IJsonSerializer>(); _jsonRpcClient = Substitute.For <IJsonRpcClient>(); _recordDb = Substitute.For <IDb>(); _rpcDb = new RpcDb("Name", _jsonSerializer, _jsonRpcClient, LimboLogs.Instance, _recordDb); }
public void ValidateDbs() { void ValidateDb <T>(params IDb[] dbs) where T : IDb { foreach (IDb db in dbs) { db.Should().BeAssignableTo <T>(db.Name); db.Innermost.Should().BeAssignableTo <RpcDb>(db.Name); } } IJsonSerializer jsonSerializer = Substitute.For <IJsonSerializer>(); IJsonRpcClient jsonRpcClient = Substitute.For <IJsonRpcClient>(); IMemDbFactory rpcDbFactory = new RpcDbFactory(new MemDbFactory(), null, jsonSerializer, jsonRpcClient, LimboLogs.Instance); IDbProvider memDbProvider = new DbProvider(DbModeHint.Mem); StandardDbInitializer standardDbInitializer = new(memDbProvider, null, rpcDbFactory); standardDbInitializer.InitStandardDbs(true); ValidateDb <ReadOnlyDb>( memDbProvider.BlocksDb, memDbProvider.BloomDb, memDbProvider.HeadersDb, memDbProvider.ReceiptsDb, memDbProvider.BlockInfosDb, memDbProvider.PendingTxsDb); ValidateDb <ReadOnlyDb>( memDbProvider.StateDb, memDbProvider.CodeDb); }
public NethermindProcessWrapper(string name, Process process, string enode, IJsonRpcClient jsonRpcClient) { Enode = enode; JsonRpcClient = jsonRpcClient; Name = name; Process = process; }
public CliqueContext SendTransaction(TransactionForRpc tx) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc($"send tx to {TestBuilder.CurrentNode.HttpPort}", "eth_sendTransaction", () => client.PostAsync <string>("eth_SendTransaction", new object[] { tx }))); }
public AuRaContext ReadBlockNumber() { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc("Read block number", "eth_blockNumber", () => client.PostAsync <long>("eth_blockNumber"), stateUpdater: (s, r) => s.BlocksCount = r.Result )); }
public RpcServerProxy(Uri targetHost, int?proxyServerPort = null, IPAddress address = null) { _proxyClient = JsonRpcClient.Create(targetHost, ArbitraryDefaults.DEFAULT_GAS_LIMIT, ArbitraryDefaults.DEFAULT_GAS_PRICE); _httpServer = new JsonRpcHttpServer(_proxyClient, ConfigureWebHost, proxyServerPort, address); //var undefinedRpcMethods = this.GetUndefinedRpcMethods(); //Console.WriteLine("Warning: following RPC methods are not defined: \n" + string.Join(", ", undefinedRpcMethods.Select(r => r.Value()))); }
public NdmContext AddDataHeader(Func <DataHeaderDto> dataHeader, string name = "Add data header", Func <string, bool> validator = null, Action <NdmState, JsonRpcResponse <string> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_addDataHeader", () => client.PostAsync <string>(nameof(AddDataHeader), new object[] { dataHeader() }), validator, stateUpdater)); }
public NdmContext PullData(Func <string> depositId, string name = "Pull data", Func <string, bool> validator = null, Action <NdmState, JsonRpcResponse <string> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_pullData", () => client.PostAsync <string>(nameof(PullData), new object[] { depositId() }), validator, stateUpdater)); }
public RpcDb(string dbName, IJsonSerializer jsonSerializer, IJsonRpcClient rpcClient, ILogManager logManager, IDb recordDb) { _dbName = dbName; _rpcClient = rpcClient ?? throw new ArgumentNullException(nameof(rpcClient)); _jsonSerializer = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer)); _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _recordDb = recordDb; }
public CashOutQueueTrigger(string component, IJsonRpcClient rpcClient, INoSQLTableStorage <ExistingCashOutEntity> existingTxes, ILog log, ISlackNotifier slackNotifier) { _component = component + ".QueueTrigger"; _rpcClient = rpcClient; _existingTxes = existingTxes; _log = log; _slackNotifier = slackNotifier; }
public NdmContext GetDeposits(string name = "Get deposits", Func <DepositDetailsDto[], bool> validator = null, Action <NdmState, JsonRpcResponse <DepositDetailsDto[]> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_getDeposits", () => client.PostAsync <DepositDetailsDto[]>(nameof(GetDeposits)), validator, stateUpdater)); }
public NethermindProcessWrapper(string name, Process process, int httpPort, Address address, string enode, IJsonRpcClient jsonRpcClient) { HttpPort = httpPort; Address = address; Enode = enode; JsonRpcClient = jsonRpcClient; Name = name; Process = process; }
public NdmContext GetDiscoveredDataHeaders(string name = "Get discovered data headers", Func <DataHeaderDto[], bool> validator = null, Action <NdmState, JsonRpcResponse <DataHeaderDto[]> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_getDiscoveredDataHeaders", () => client.PostAsync <DataHeaderDto[]>(nameof(GetDiscoveredDataHeaders)), validator, stateUpdater)); }
public NdmContext EnableDataStream(Func <string> depositId, string[] args, string name = "Enable data stream", Func <string, bool> validator = null, Action <NdmState, JsonRpcResponse <string> > stateUpdater = null) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc(name, "npm_enableDataStream", () => client.PostAsync <string>(nameof(EnableDataStream), new object[] { depositId(), args }), validator, stateUpdater)); }
public RpcApp() { Server = new MockServerApp(); Server.RpcServer.WebHost.Start(); var port = Server.RpcServer.ServerPort; HttpClient = JsonRpcClient.Create(new Uri($"http://{IPAddress.Loopback}:{port}"), ArbitraryDefaults.DEFAULT_GAS_LIMIT, ArbitraryDefaults.DEFAULT_GAS_PRICE); WebSocketClient = JsonRpcClient.Create(new Uri($"ws://{IPAddress.Loopback}:{port}"), ArbitraryDefaults.DEFAULT_GAS_LIMIT, ArbitraryDefaults.DEFAULT_GAS_PRICE); }
/// <summary> /// The default constructor, creates a test chain for tests to share. /// </summary> public TestChainFixture() { // Create a test node on this port. Server = new Meadow.TestNode.TestNodeServer(); Server.RpcServer.Start(); int port = Server.RpcServer.ServerPort; // Create our client and grab our account list. Client = JsonRpcClient.Create(new Uri($"http://{IPAddress.Loopback}:{port}"), ArbitraryDefaults.DEFAULT_GAS_LIMIT, ArbitraryDefaults.DEFAULT_GAS_PRICE); }
public void SwitchUri(Uri uri) { CurrentUri = uri.ToString(); if (!_clients.ContainsKey(uri)) { _clients[uri] = new BasicJsonRpcClient(uri, _serializer, _logManager); } _currentClient = _clients[uri]; }
private AuRaContext ReadBlockAuthor(long blockNumber) { IJsonRpcClient client = TestBuilder.CurrentNode.JsonRpcClient; return(AddJsonRpc("Read block", "eth_getBlockByNumber", () => client.PostAsync <JObject>("eth_getBlockByNumber", new object[] { blockNumber, false }), stateUpdater: (s, r) => s.Blocks.Add( Convert.ToInt64(r.Result["number"].Value <string>(), 16), (r.Result["miner"].Value <string>(), Convert.ToInt64(r.Result["step"].Value <string>(), 16))))); }
public RpcDbProvider(IJsonSerializer serializer, IJsonRpcClient client, ILogManager logManager, IDbProvider recordDbProvider) { _recordDbProvider = recordDbProvider; StateDb = new StateDb(new ReadOnlyDb(new RpcDb(DbNames.State, serializer, client, logManager, recordDbProvider?.StateDb), true)); CodeDb = new StateDb(new ReadOnlyDb(new RpcDb(DbNames.Code, serializer, client, logManager, recordDbProvider?.CodeDb), true)); ReceiptsDb = new ReadOnlyDb(new RpcDb(DbNames.Receipts, serializer, client, logManager, recordDbProvider?.ReceiptsDb), true); BlocksDb = new ReadOnlyDb(new RpcDb(DbNames.Blocks, serializer, client, logManager, recordDbProvider?.BlocksDb), true); BlockInfosDb = new ReadOnlyDb(new RpcDb(DbNames.BlockInfos, serializer, client, logManager, recordDbProvider?.BlockInfosDb), true); PendingTxsDb = new ReadOnlyDb(new RpcDb(DbNames.PendingTxs, serializer, client, logManager, recordDbProvider?.ReceiptsDb), true); TraceDb = new ReadOnlyDb(new RpcDb(DbNames.Trace, serializer, client, logManager, recordDbProvider?.ReceiptsDb), true); }
public async Task RpcExecutionCallback(IJsonRpcClient client, bool expectingException) { // Obtain an execution trace from our client. var executionTrace = await client.GetExecutionTrace(); var executionTraceAnalysis = new ExecutionTraceAnalysis(executionTrace); // Process our execution trace in the debug adapter. await DebugAdapter.ProcessExecutionTraceAnalysis(client, executionTraceAnalysis, expectingException); await Task.CompletedTask; }
public ContractInstance( string contractSolFilePath, string contractName, IJsonRpcClient rpcClient, Address contractAddress, Address defaultFromAccount) : base(rpcClient, contractAddress, defaultFromAccount) { ContractAddress = contractAddress; DefaultFromAccount = defaultFromAccount; JsonRpcClient = rpcClient; ContractSolFilePath = contractSolFilePath; ContractName = contractName; }
public CashInHandlerQueueTrigger(string component, INoSQLTableStorage <WalletStorageEntity> generatedWallets, ILog log, IQueueExt txesQueue, IJsonRpcClient rpcClient, ISlackNotifier slackNotifier, string hotWalletAddress, decimal txFee, decimal minTxAmount) { _component = component + ".QueueTrigger"; _generatedWallets = generatedWallets; _log = log; _txesQueue = txesQueue; _rpcClient = rpcClient; _hotWalletAddress = hotWalletAddress; _txFee = txFee; _minTxAmount = minTxAmount; _slackNotifier = slackNotifier; }
public RpcDbFactory( IMemDbFactory wrappedMemDbFactory, IRocksDbFactory wrappedRocksDbFactory, IJsonSerializer jsonSerializer, IJsonRpcClient jsonRpcClient, ILogManager logManager) { _wrappedMemDbFactory = wrappedMemDbFactory; _wrappedRocksDbFactory = wrappedRocksDbFactory; _jsonSerializer = jsonSerializer; _jsonRpcClient = jsonRpcClient; _logManager = logManager; }
public void Setup() { _serializer = new EthereumJsonSerializer(); _jsonRpcClient = Substitute.For <IJsonRpcClient>(); _engine = new CliEngine(_cliConsole); NodeManager nodeManager = new NodeManager(_engine, _serializer, _cliConsole, LimboLogs.Instance); nodeManager.SwitchClient(_jsonRpcClient); ICliConsole cliConsole = Substitute.For <ICliConsole>(); CliModuleLoader moduleLoader = new CliModuleLoader(_engine, nodeManager, cliConsole); moduleLoader.LoadModule(typeof(ProofCliModule)); }
public PluginsModule(IPluginEngine pluginEngine, IJsonRpcClient rpcClient) : base("plugins") { Get["/{id}/{path*}"] = _ => { string id = _.id; string path = _.path; var plugin = pluginEngine.Get(id); if (plugin == null) { return 404; } var data = rpcClient.Call<byte[]>(string.Format("{0}.resource.get", id), new[] {path}); if (data == null) { return 404; } var contentType = MimeTypes.GetMimeType(path); return Response.FromStream(() => new MemoryStream(data), contentType); }; }
public EventsService(ILogger logger, IPluginEngine pluginEngine, IJsonRpcClient rpcClient) { _logger = logger; _pluginEngine = pluginEngine; _rpcClient = rpcClient; }