Exemplo n.º 1
0
        public void Creates_new_snapshot()
        {
            SnapshotManager snapshotManager = new SnapshotManager(CliqueConfig.Default, _snapshotDb, _blockTree, NullEthereumEcdsa.Instance, LimboLogs.Instance);
            Block           genesis         = CliqueTests.GetRinkebyGenesis();
            Snapshot        snapshot        = snapshotManager.GetOrCreateSnapshot(0, genesis.Hash);

            Assert.AreEqual(genesis.Hash, snapshot.Hash);
        }
Exemplo n.º 2
0
        public void Loads_snapshot()
        {
            SnapshotManager snapshotManager = new SnapshotManager(CliqueConfig.Default, _snapshotDb, _blockTree, NullEthereumEcdsa.Instance, LimboLogs.Instance);
            Block           genesis         = CliqueTests.GetRinkebyGenesis();
            Snapshot        snapshot        = snapshotManager.GetOrCreateSnapshot(0, genesis.Hash);

            Assert.NotNull(snapshot);
            Assert.AreEqual(genesis.Hash, snapshot.Hash);
            Assert.AreEqual(genesis.Number, snapshot.Number);
            // Check signers
            Assert.IsTrue(snapshot.Signers.ContainsKey(_signer1));
            Assert.IsTrue(snapshot.Signers.ContainsKey(_signer2));
            Assert.IsTrue(snapshot.Signers.ContainsKey(_signer3));
        }
Exemplo n.º 3
0
        public void Recognises_signer_turn()
        {
            SnapshotManager snapshotManager = new SnapshotManager(CliqueConfig.Default, _snapshotDb, _blockTree, NullEthereumEcdsa.Instance, LimboLogs.Instance);
            Block           genesis         = CliqueTests.GetRinkebyGenesis();
            Snapshot        snapshot        = snapshotManager.GetOrCreateSnapshot(0, genesis.Hash);
            SnapshotManager manager         = new SnapshotManager(CliqueConfig.Default, _snapshotDb, _blockTree, new EthereumEcdsa(ChainId.Goerli, LimboLogs.Instance), LimboLogs.Instance);

            // Block 1
            Assert.IsTrue(manager.IsInTurn(snapshot, 1, _signer1));
            Assert.IsFalse(manager.IsInTurn(snapshot, 1, _signer2));
            Assert.IsFalse(manager.IsInTurn(snapshot, 1, _signer3));
            // Block 2
            Assert.IsFalse(manager.IsInTurn(snapshot, 2, _signer1));
            Assert.IsTrue(manager.IsInTurn(snapshot, 2, _signer2));
            Assert.IsFalse(manager.IsInTurn(snapshot, 2, _signer3));
            // Block 3
            Assert.IsFalse(manager.IsInTurn(snapshot, 3, _signer1));
            Assert.IsFalse(manager.IsInTurn(snapshot, 3, _signer2));
            Assert.IsTrue(manager.IsInTurn(snapshot, 3, _signer3));
        }