Example #1
0
        public MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                         IChainService chainService, IActorEnvironment actorEnvironment,
                         IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                         ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                         IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
        {
            _logger          = logger;
            _stateStore      = stateStore;
            ActorEnvironment = actorEnvironment;
            if (!ActorEnvironment.Initialized)
            {
                ActorEnvironment.InitActorSystem();
            }
            _hashManager                = hashManager;
            _transactionManager         = transactionManager;
            _chainCreationService       = chainCreationService;
            _chainService               = chainService;
            ChainContextService         = chainContextService;
            _functionMetadataService    = functionMetadataService;
            _smartContractRunnerFactory = smartContractRunnerFactory;
            SmartContractManager        = new SmartContractManager(dataStore);
            Task.Factory.StartNew(async() => { await Init(); }).Unwrap().Wait();
            SmartContractService =
                new SmartContractService(SmartContractManager, _smartContractRunnerFactory, stateStore,
                                         functionMetadataService);
            Task.Factory.StartNew(async() => { await DeploySampleContracts(); }).Unwrap().Wait();
            ServicePack = new ServicePack()
            {
                ChainContextService      = chainContextService,
                SmartContractService     = SmartContractService,
                ResourceDetectionService = new NewMockResourceUsageDetectionService(),
                StateStore = _stateStore
            };

            // These are only required for workertest
            // other tests use ActorEnvironment
            var workers = new[] { "/user/worker1", "/user/worker2" };

            Worker1 = Sys.ActorOf(Props.Create <Worker>(), "worker1");
            Worker2 = Sys.ActorOf(Props.Create <Worker>(), "worker2");
            Router  = Sys.ActorOf(Props.Empty.WithRouter(new TrackedGroup(workers)), "router");
            Worker1.Tell(new LocalSerivcePack(ServicePack));
            Worker2.Tell(new LocalSerivcePack(ServicePack));
            Requestor = Sys.ActorOf(AElf.Execution.Execution.Requestor.Props(Router));
        }
 public ParallelTransactionExecutingService(IActorEnvironment actorEnvironment, IGrouper grouper, ServicePack servicePack)
 {
     _actorEnvironment      = actorEnvironment;
     _grouper               = grouper;
     _singlExecutingService = new SimpleExecutingService(servicePack.SmartContractService, servicePack.TransactionTraceManager, servicePack.StateStore, servicePack.ChainContextService);
 }