public async Task can_return_tracked_list(uint trackedCount)
        {
            SingleReleaseSpecProvider spec    = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1);
            TestRpcBlockchain         testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec);

            IStateReader   stateReader    = Substitute.For <IStateReader>();
            BaselineModule baselineModule = new BaselineModule(
                testRpc.TxSender,
                stateReader,
                testRpc.LogFinder,
                testRpc.BlockTree,
                _abiEncoder,
                _fileSystem,
                new MemDb(),
                LimboLogs.Instance);

            for (int i = 0; i < trackedCount; i++)
            {
                stateReader.GetCode(null, null).ReturnsForAnyArgs(new byte[] { 255 });
                await baselineModule.baseline_track(TestItem.Addresses[i]);
            }

            var result = (await baselineModule.baseline_getTracked());

            result.Data.Length.Should().Be((int)trackedCount);
        }
        public async Task can_restore_tracking_list_on_startup(uint trackedCount)
        {
            SingleReleaseSpecProvider spec    = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1);
            TestRpcBlockchain         testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec);

            MemDb          memDb          = new MemDb();
            BaselineModule baselineModule = new BaselineModule(
                testRpc.TxPoolBridge,
                testRpc.LogFinder,
                testRpc.BlockTree,
                _abiEncoder,
                _fileSystem,
                memDb,
                LimboLogs.Instance);

            for (int i = 0; i < trackedCount; i++)
            {
                await baselineModule.baseline_track(TestItem.Addresses[i]); // any address (no need for tree there)
            }

            BaselineModule restored = new BaselineModule(
                testRpc.TxPoolBridge,
                testRpc.LogFinder,
                testRpc.BlockTree,
                _abiEncoder,
                _fileSystem,
                memDb,
                LimboLogs.Instance);

            var resultRestored = await restored.baseline_getTracked();

            resultRestored.Data.Length.Should().Be((int)trackedCount);
        }
Esempio n. 3
0
        public async Task can_restore_tracking_list_on_startup(uint trackedCount)
        {
            SingleReleaseSpecProvider spec    = new SingleReleaseSpecProvider(ConstantinopleFix.Instance, 1);
            TestRpcBlockchain         testRpc = await TestRpcBlockchain.ForTest(SealEngineType.NethDev).Build(spec);

            MemDb memDb = new MemDb();
            MemDb baselineMetaDataDb = new MemDb();

            IStateReader   stateReader    = Substitute.For <IStateReader>();
            BaselineModule baselineModule = new BaselineModule(
                testRpc.TxSender,
                stateReader,
                testRpc.LogFinder,
                testRpc.BlockTree,
                _abiEncoder,
                _fileSystem,
                memDb,
                baselineMetaDataDb,
                LimboLogs.Instance,
                testRpc.BlockProcessor,
                new DisposableStack());

            for (int i = 0; i < trackedCount; i++)
            {
                stateReader.GetCode(null, null).ReturnsForAnyArgs(new byte[] { 255 });
                await baselineModule.baseline_track(TestItem.Addresses[i]); // any address (no need for tree there)
            }

            BaselineModule restored = new BaselineModule(
                testRpc.TxSender,
                stateReader,
                testRpc.LogFinder,
                testRpc.BlockTree,
                _abiEncoder,
                _fileSystem,
                memDb,
                baselineMetaDataDb,
                LimboLogs.Instance,
                testRpc.BlockProcessor,
                new DisposableStack());

            var resultRestored = await restored.baseline_getTracked();

            resultRestored.Data.Length.Should().Be((int)trackedCount);
        }
        public async Task can_return_tracked_list(uint trackedCount)
        {
            SingleReleaseSpecProvider spec = new(ConstantinopleFix.Instance, 1);

            using TestRpcBlockchain testRpc = await TestRpcBlockchain.ForTest <BaseLineRpcBlockchain>(SealEngineType.NethDev).Build(spec);

            IStateReader   stateReader    = Substitute.For <IStateReader>();
            BaselineModule baselineModule = CreateBaselineModule(testRpc, stateReader);

            for (int i = 0; i < trackedCount; i++)
            {
                stateReader.GetCode(null, null).ReturnsForAnyArgs(new byte[] { 255 });
                await baselineModule.baseline_track(TestItem.Addresses[i]);
            }

            var result = (await baselineModule.baseline_getTracked());

            result.Data.Length.Should().Be((int)trackedCount);
        }