Esempio n. 1
0
        private void Initialize()
        {
            NewStorage();
            var transactionManager      = new TransactionManager(_dataStore, _logger);
            var transactionTraceManager = new TransactionTraceManager(_dataStore);

            _functionMetadataService = new FunctionMetadataService(_dataStore, _logger);
            var chainManagerBasic = new ChainManagerBasic(_dataStore);

            ChainService = new ChainService(chainManagerBasic, new BlockManagerBasic(_dataStore),
                                            transactionManager, transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();
            var runner = new SmartContractRunner("../../../../AElf.Runtime.CSharp.Tests.TestContract/bin/Debug/netstandard2.0/");

            _smartContractRunnerFactory.AddRunner(0, runner);
            _chainCreationService = new ChainCreationService(ChainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);
            SmartContractManager = new SmartContractManager(_dataStore);
            Task.Factory.StartNew(async() =>
            {
                await Init();
            }).Unwrap().Wait();
            SmartContractService = new SmartContractService(SmartContractManager, _smartContractRunnerFactory, StateStore, _functionMetadataService);
            ChainService         = new ChainService(new ChainManagerBasic(_dataStore), new BlockManagerBasic(_dataStore), new TransactionManager(_dataStore), new TransactionTraceManager(_dataStore), _dataStore, StateStore);
        }
Esempio n. 2
0
        private void Initialize()
        {
            _transactionManager        = new TransactionManager(_dataStore, _logger);
            _transactionReceiptManager = new TransactionReceiptManager(_database);
            _smartContractManager      = new SmartContractManager(_dataStore);
            _transactionResultManager  = new TransactionResultManager(_dataStore);
            _transactionTraceManager   = new TransactionTraceManager(_dataStore);
            _functionMetadataService   = new FunctionMetadataService(_dataStore, _logger);
            _chainManagerBasic         = new ChainManagerBasic(_dataStore);
            _chainService = new ChainService(_chainManagerBasic, new BlockManagerBasic(_dataStore),
                                             _transactionManager, _transactionTraceManager, _dataStore, StateStore);
            _smartContractRunnerFactory = new SmartContractRunnerFactory();

            /*var runner = new SmartContractRunner("../../../../AElf.SDK.CSharp/bin/Debug/netstandard2.0/");
             * _smartContractRunnerFactory.AddRunner(0, runner);*/
            var runner = new SmartContractRunner(ContractCodes.TestContractFolder);

            _smartContractRunnerFactory.AddRunner(0, runner);
            _concurrencyExecutingService = new SimpleExecutingService(
                new SmartContractService(_smartContractManager, _smartContractRunnerFactory, StateStore,
                                         _functionMetadataService), _transactionTraceManager, StateStore,
                new ChainContextService(_chainService));

            _chainCreationService = new ChainCreationService(_chainService,
                                                             new SmartContractService(new SmartContractManager(_dataStore), _smartContractRunnerFactory,
                                                                                      StateStore, _functionMetadataService), _logger);

            _binaryMerkleTreeManager = new BinaryMerkleTreeManager(_dataStore);
            _chainContextService     = new ChainContextService(_chainService);
            _stateStore = new StateStore(_database);
        }
Esempio n. 3
0
 public SmartContractController()
 {
     this.smartContractDb      = new SmartContractDb();
     this.accountDb            = new AccountDb();
     this.logger               = new BlockchainLogger();
     this.smartContractManager = new SmartContractManager(this.smartContractDb, this.accountDb, this.logger);
 }
Esempio n. 4
0
 public SmartContractService(ISmartContractManager smartContractManager, ISmartContractRunnerFactory smartContractRunnerFactory, IStateStore stateStore,
                             IFunctionMetadataService functionMetadataService)
 {
     _smartContractManager       = smartContractManager;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     _stateStore = stateStore;
     _functionMetadataService = functionMetadataService;
 }
Esempio n. 5
0
 public ContractTest(IStateStore stateStore,
                     IChainCreationService chainCreationService, IChainService chainService,
                     ITransactionManager transactionManager, ISmartContractManager smartContractManager,
                     IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
 {
     _stateStore                 = stateStore;
     _chainCreationService       = chainCreationService;
     _chainService               = chainService;
     _transactionManager         = transactionManager;
     _smartContractManager       = smartContractManager;
     _chainContextService        = chainContextService;
     _functionMetadataService    = functionMetadataService;
     _smartContractRunnerFactory = smartContractRunnerFactory;
     _smartContractService       = new SmartContractService(_smartContractManager, _smartContractRunnerFactory, stateStore, _functionMetadataService);
 }
Esempio n. 6
0
        public MockSetup(IDataStore dataStore, IStateStore stateStore, ITxHub txHub)
        {
            _dataStore  = dataStore;
            _stateStore = stateStore;

            _smartContractManager        = new SmartContractManager(_dataStore);
            _transactionManager          = new TransactionManager(_dataStore);
            _transactionTraceManager     = new TransactionTraceManager(_dataStore);
            _transactionResultManager    = new TransactionResultManager(_dataStore);
            _smartContractRunnerFactory  = new SmartContractRunnerFactory();
            _concurrencyExecutingService = new SimpleExecutingService(
                new SmartContractService(_smartContractManager, _smartContractRunnerFactory, _stateStore,
                                         _functionMetadataService), _transactionTraceManager, _stateStore,
                new ChainContextService(GetChainService()));
            _txHub             = txHub;
            _chainManagerBasic = new ChainManagerBasic(dataStore);
        }
Esempio n. 7
0
 public MockSetup(IStateStore stateStore, IChainCreationService chainCreationService, IDataStore dataStore, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
 {
     StateStore                  = stateStore;
     _chainCreationService       = chainCreationService;
     _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();
 }
Esempio n. 8
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));
        }
Esempio n. 9
0
        public MockSetup(IStateStore stateStore, IChainCreationService chainCreationService, IDataStore dataStore, IChainContextService chainContextService, IFunctionMetadataService functionMetadataService, ISmartContractRunnerFactory smartContractRunnerFactory)
        {
            StateStore                  = stateStore;
            _chainCreationService       = chainCreationService;
            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);

            ServicePack = new ServicePack()
            {
                ChainContextService      = chainContextService,
                SmartContractService     = SmartContractService,
                ResourceDetectionService = null,
                StateStore = StateStore
            };
        }
Esempio n. 10
0
 public BlockChainTests_MockSetup(IDataStore dataStore, IChainCreationService chainCreationService,
                                  IChainService chainService,
                                  IChainContextService chainContextService, IFunctionMetadataService functionMetadataService,
                                  ISmartContractRunnerFactory smartContractRunnerFactory, ILogger logger,
                                  IStateStore stateStore, HashManager hashManager, TransactionManager transactionManager)
 {
     _logger                     = logger;
     _stateStore                 = stateStore;
     _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();
 }