public BadContractTests() { StateProvider = GetRequiredService <IStateProviderFactory>().CreateStateProvider(); BridgeContext = GetRequiredService <IHostSmartContractBridgeContextService>().Create(); var transactionContext = new TransactionContext() { Transaction = new Transaction() { From = SampleAddress.AddressList[0], To = SampleAddress.AddressList[1] } }; BridgeContext.TransactionContext = transactionContext; Contract.InternalInitialize(BridgeContext); var injectedCounter = Contract.GetType().Assembly .GetTypes().SingleOrDefault(t => t.Name == nameof(ExecutionObserverProxy)); injectedCounter.ShouldNotBeNull(); _proxyCountMethod = injectedCounter.GetMethod(nameof(ExecutionObserverProxy.SetObserver), new[] { typeof(IExecutionObserver) }); _proxyCountMethod.ShouldNotBeNull(); }
private IHostSmartContractBridgeContext CreateNewContext() { _bridgeContext = GetRequiredService <IHostSmartContractBridgeContext>(); var transactionContext = new TransactionContext() { Transaction = new Transaction() { From = Address.FromPublicKey(_keyPair.PublicKey), To = SampleAddress.AddressList[0], MethodName = "Test", Params = ByteString.CopyFrom(new byte[10]), RefBlockNumber = 1, RefBlockPrefix = ByteString.CopyFrom(new byte[4]) }, BlockHeight = 3, CurrentBlockTime = TimestampHelper.GetUtcNow(), PreviousBlockHash = Hash.Empty, Trace = new TransactionTrace(), StateCache = new NullStateCache() }; var signature = CryptoHelper.SignWithPrivateKey(_keyPair.PrivateKey, transactionContext.Transaction .GetHash().ToByteArray()); transactionContext.Transaction.Signature = ByteString.CopyFrom(signature); _bridgeContext.Initialize(transactionContext); return(_bridgeContext); }
public HostSmartContractBridgeContextTests() { _blockchainService = GetRequiredService <IBlockchainService>(); _smartContractAddressService = GetRequiredService <ISmartContractAddressService>(); _defaultContractZeroCodeProvider = GetRequiredService <IDefaultContractZeroCodeProvider>(); _keyPair = CryptoHelpers.GenerateKeyPair(); _bridgeContext = CreateNewContext(); }
public TestContractTests() { StateProvider = GetRequiredService <IStateProviderFactory>().CreateStateProvider(); BridgeContext = GetRequiredService <IHostSmartContractBridgeContextService>().Create(); var transactionContext = new TransactionContext() { Transaction = new Transaction() { From = SampleAddress.AddressList[0], To = SampleAddress.AddressList[1] } }; BridgeContext.TransactionContext = transactionContext; Contract.InternalInitialize(BridgeContext); }
public ContractTest() { StateProvider = GetRequiredService <IStateProviderFactory>().CreateStateProvider(); BridgeContext = GetRequiredService <IHostSmartContractBridgeContextService>().Create(); Contract.InternalInitialize(BridgeContext); //Contract.SetStateProvider(StateProvider); var transactionContext = new TransactionContext() { Transaction = new Transaction() { From = AddressList[1], To = AddressList[0] } }; BridgeContext.TransactionContext = transactionContext; //StateProvider.TransactionContext = transactionContext; }
public IExecutive SetHostSmartContractBridgeContext(IHostSmartContractBridgeContext smartContractBridgeContext) { _hostSmartContractBridgeContext = smartContractBridgeContext; _smartContractProxy.InternalInitialize(_hostSmartContractBridgeContext); return(this); }
public MethodStubFactory(IHostSmartContractBridgeContext context) { _context = context; }