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 Setup_chain()
        {
            // Import blocks
            _blockTree = Build.A.BlockTree().TestObject;
            Block block1       = Rlp.Decode <Block>(new Rlp(Bytes.FromHexString(Block1Rlp)));
            Block block2       = Rlp.Decode <Block>(new Rlp(Bytes.FromHexString(Block2Rlp)));
            Block block3       = Rlp.Decode <Block>(new Rlp(Bytes.FromHexString(Block3Rlp)));
            Block block4       = Rlp.Decode <Block>(new Rlp(Bytes.FromHexString(Block4Rlp)));
            Block block5       = Rlp.Decode <Block>(new Rlp(Bytes.FromHexString(Block5Rlp)));
            Block genesisBlock = CliqueTests.GetRinkebyGenesis();

            // Add blocks
            MineBlock(_blockTree, genesisBlock);
            MineBlock(_blockTree, block1);
            MineBlock(_blockTree, block2);
            MineBlock(_blockTree, block3);
            MineBlock(_blockTree, block4);
            MineBlock(_blockTree, block5);
        }
Exemplo n.º 4
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));
        }