Esempio n. 1
0
        public void TestOnSysCall()
        {
            InteropDescriptor     descriptor = new InteropDescriptor("System.Blockchain.GetHeight", Blockchain_GetHeight, 0_00000400, TriggerType.Application, CallFlags.None);
            TestApplicationEngine engine     = new TestApplicationEngine(TriggerType.Application, null, null, 0);

            byte[] SyscallSystemRuntimeCheckWitnessHash = new byte[] { 0x68, 0xf8, 0x27, 0xec, 0x8c };
            engine.LoadScript(SyscallSystemRuntimeCheckWitnessHash);
            engine.GetOnSysCall(descriptor.Hash).Should().BeFalse();

            var snapshot = Blockchain.Singleton.GetSnapshot();

            engine = new TestApplicationEngine(TriggerType.Application, null, snapshot, 0, true);
            engine.LoadScript(SyscallSystemRuntimeCheckWitnessHash);
            engine.GetOnSysCall(descriptor.Hash).Should().BeTrue();
        }
Esempio n. 2
0
        public void TestOnSysCall()
        {
            InteropDescriptor     descriptor = new InteropDescriptor("System.Blockchain.GetHeight", Blockchain_GetHeight, 0_00000400, TriggerType.Application);
            TestApplicationEngine engine     = new TestApplicationEngine(TriggerType.Application, null, null, 0);

            byte[] SyscallSystemRuntimeCheckWitnessHash = new byte[] { 0x68, 0xf8, 0x27, 0xec, 0x8c };
            engine.LoadScript(SyscallSystemRuntimeCheckWitnessHash);
            engine.GetOnSysCall(descriptor.Hash).Should().BeFalse();

            var mockSnapshot = new Mock <Snapshot>();
            TestMetaDataCache <HashIndexState> testCache = new TestMetaDataCache <HashIndexState>();

            mockSnapshot.SetupGet(p => p.BlockHashIndex).Returns(testCache);
            engine = new TestApplicationEngine(TriggerType.Application, null, mockSnapshot.Object, 0, true);
            engine.LoadScript(SyscallSystemRuntimeCheckWitnessHash);
            engine.GetOnSysCall(descriptor.Hash).Should().BeTrue();
        }