Exemple #1
0
        public SmartContractExceptionTests()
        {
            var context = new ContractExecutorTestContext();

            this.network    = context.Network;
            this.repository = context.State;
            this.vm         = context.Vm;
        }
        public ReflectionVirtualMachineTests()
        {
            // Take what's needed for these tests
            var context = new ContractExecutorTestContext();

            this.network = context.Network;
            this.vm      = context.Vm;
        }
Exemple #3
0
        public GasInjectorTests()
        {
            // Only take from context what these tests require.
            var context = new ContractExecutorTestContext();

            this.vm         = context.Vm;
            this.repository = context.State;
            this.network    = context.Network;
        }
        public ObserverTests()
        {
            var context = new ContractExecutorTestContext();

            this.network        = context.Network;
            this.TestAddress    = "0x0000000000000000000000000000000000000001".HexToAddress();
            this.repository     = context.State;
            this.moduleReader   = new ContractModuleDefinitionReader();
            this.assemblyLoader = new ContractAssemblyLoader();
            this.gasMeter       = new GasMeter((Gas)5000000);

            var block = new TestBlock
            {
                Coinbase = TestAddress,
                Number   = 1
            };
            var message = new TestMessage
            {
                ContractAddress = TestAddress,
                GasLimit        = (Gas)GasLimit,
                Sender          = TestAddress,
                Value           = Value
            };
            var getBalance      = new Func <ulong>(() => Balance);
            var persistentState = new TestPersistentState();
            var network         = new SmartContractsRegTest();
            var serializer      = new ContractPrimitiveSerializer(network);

            this.state = new SmartContractState(
                new Stratis.SmartContracts.Block(1, TestAddress),
                new Message(TestAddress, TestAddress, 0),
                new PersistentState(new MeteredPersistenceStrategy(this.repository, this.gasMeter, new BasicKeyEncodingStrategy()),
                                    context.Serializer, TestAddress.ToUint160()),
                context.Serializer,
                this.gasMeter,
                new ContractLogHolder(),
                Mock.Of <IInternalTransactionExecutor>(),
                new InternalHashHelper(),
                () => 1000);

            this.rewriter = new ObserverRewriter(new Observer(this.gasMeter, ReflectionVirtualMachine.MemoryUnitLimit));
        }
        public ReflectionVirtualMachineTests()
        {
            // Take what's needed for these tests
            var context = new ContractExecutorTestContext();

            this.network       = context.Network;
            this.vm            = context.Vm;
            this.state         = context.State;
            this.contractState = new SmartContractState(
                new Block(1, TestAddress),
                new Message(TestAddress, TestAddress, 0),
                new PersistentState(new PersistenceStrategy(this.state),
                                    context.ContractPrimitiveSerializer, TestAddress.ToUint160(this.network)),
                context.ContractPrimitiveSerializer,
                new GasMeter((Gas)5000000),
                new ContractLogHolder(this.network),
                Mock.Of <IInternalTransactionExecutor>(),
                new InternalHashHelper(),
                () => 1000);
        }
        public GasInjectorTests()
        {
            // Only take from context what these tests require.
            var context = new ContractExecutorTestContext();

            this.vm             = context.Vm;
            this.repository     = context.State;
            this.network        = context.Network;
            this.moduleReader   = new ContractModuleDefinitionReader();
            this.assemblyLoader = new ContractAssemblyLoader();
            this.gasMeter       = new GasMeter((Gas)5000000);
            this.state          = new SmartContractState(
                new Block(1, TestAddress),
                new Message(TestAddress, TestAddress, 0),
                new PersistentState(new MeteredPersistenceStrategy(this.repository, this.gasMeter, new BasicKeyEncodingStrategy()),
                                    context.ContractPrimitiveSerializer, TestAddress.ToUint160(this.network)),
                context.ContractPrimitiveSerializer,
                this.gasMeter,
                new ContractLogHolder(this.network),
                Mock.Of <IInternalTransactionExecutor>(),
                new InternalHashHelper(),
                () => 1000);
        }