public void TestInitialize() { Initialize(mockedServices: true); ApiKeyAuthentication = AppSettings.RestAdminAPIKey; rpcClientFactoryMock = server.Services.GetRequiredService <IRpcClientFactory>() as RpcClientFactoryMock; if (rpcClientFactoryMock != null) { rpcClientFactoryMock.AddKnownBlock(0, HelperTools.HexStringToByteArray(TestBase.genesisBlock)); rpcClientFactoryMock.Reset(); // remove calls that are used to test node connection when adding a new node } }
public override void Initialize(bool mockedServices = false, IEnumerable <KeyValuePair <string, string> > overridenSettings = null) { base.Initialize(mockedServices, overridenSettings); // setup repositories NodeRepository = server.Services.GetRequiredService <INodeRepository>() as NodeRepositoryPostgres; TxRepositoryPostgres = server.Services.GetRequiredService <ITxRepository>() as TxRepositoryPostgres; FeeQuoteRepository = server.Services.GetRequiredService <IFeeQuoteRepository>() as FeeQuoteRepositoryPostgres; MinerId = server.Services.GetRequiredService <IMinerId>(); // setup common services Nodes = server.Services.GetRequiredService <INodes>(); BlockChainInfo = server.Services.GetRequiredService <IBlockChainInfo>(); RpcMultiClient = server.Services.GetRequiredService <IRpcMultiClient>(); EventBus = server.Services.GetRequiredService <IEventBus>(); rpcClientFactoryMock = server.Services.GetRequiredService <IRpcClientFactory>() as RpcClientFactoryMock; feeQuoteRepositoryMock = server.Services.GetRequiredService <IFeeQuoteRepository>() as FeeQuoteRepositoryMock; FeeQuoteRepositoryMock.quoteExpiryMinutes = quoteExpiryMinutes; if (rpcClientFactoryMock != null) { rpcClientFactoryMock.SetUpTransaction( txC3Hex, txC2Hex, txZeroFeeHex, txZeroFeeInput1Hex, txZeroFeeInput2Hex, tx2Hex, tx2Input1Hex, tx2Input2Hex); rpcClientFactoryMock.AddKnownBlock(0, HelperTools.HexStringToByteArray(genesisBlock)); rpcClientFactoryMock.Reset(); // remove calls that are used to test node connection when adding a new node } }
public void Initialize(bool mockedServices = false) { SyncTest.WaitOne(); // tests must not run in parallel since each test first deletes database try { // setup call back server serverCallback = CallbackServer.GetTestServer(Callback.Url, Callback); clientCallback = serverCallback.CreateClient(); //setup server server = TestServerBase.CreateServer(mockedServices, serverCallback, dbConnectionString); client = server.CreateClient(); // setup repositories NodeRepository = server.Services.GetRequiredService <INodeRepository>() as NodeRepositoryPostgres; TxRepositoryPostgres = server.Services.GetRequiredService <ITxRepository>() as TxRepositoryPostgres; FeeQuoteRepository = server.Services.GetRequiredService <IFeeQuoteRepository>() as FeeQuoteRepositoryPostgres; BlockChainInfo = server.Services.GetRequiredService <IBlockChainInfo>(); MinerId = server.Services.GetRequiredService <IMinerId>(); // setup common services loggerFactory = server.Services.GetRequiredService <ILoggerFactory>(); loggerTest = loggerFactory.CreateLogger(LOG_CATEGORY); Nodes = server.Services.GetRequiredService <INodes>(); blockChainInfo = server.Services.GetRequiredService <IBlockChainInfo>(); rpcMultiClient = server.Services.GetRequiredService <IRpcMultiClient>(); eventBus = server.Services.GetRequiredService <IEventBus>(); rpcClientFactoryMock = server.Services.GetRequiredService <IRpcClientFactory>() as RpcClientFactoryMock; feeQuoteRepositoryMock = server.Services.GetRequiredService <IFeeQuoteRepository>() as FeeQuoteRepositoryMock; FeeQuoteRepositoryMock.quoteExpiryMinutes = quoteExpiryMinutes; if (rpcClientFactoryMock != null) { rpcClientFactoryMock.SetUpTransaction( txC3Hex, txC2Hex, txZeroFeeHex, txZeroFeeInput1Hex, txZeroFeeInput2Hex, tx2Hex, tx2Input1Hex, tx2Input2Hex); rpcClientFactoryMock.AddKnownBlock(0, HelperTools.HexStringToByteArray(genesisBlock)); rpcClientFactoryMock.Reset(); // remove calls that are used to test node connection when adding a new node } loggerTest.LogInformation($"Path: {Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)}"); loggerTest.LogInformation($"ConnString: {dbConnectionString}"); } catch { SyncTest.Reset(); // If there was error during initialization, let the other tests run (although they will probably also fail) throw; } }