コード例 #1
0
        public void ShouldGenerateNoActionsOnSameState()
        {
            MockConfigProvider cp = new MockConfigProvider {
                CurrentState = new NodeState
                {
                    IsSigning             = true,
                    DockerImage           = "parity/parity:v2.3.4",
                    DockerChecksum        = "9f0142e1ae1641fbcf6116c49b5c73d5a4b48340e07f9ecb4da8d2d9847a76e6",
                    ChainspecUrl          = "https://foo.bar",
                    ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                    UpdateIntroducedBlock = 1234567
                }
            };

            // Recreate the same state so state object references are different
            NodeState newState = new NodeState
            {
                IsSigning             = true,
                DockerImage           = "parity/parity:v2.3.4",
                DockerChecksum        = "9f0142e1ae1641fbcf6116c49b5c73d5a4b48340e07f9ecb4da8d2d9847a76e6",
                ChainspecUrl          = "https://foo.bar",
                ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                UpdateIntroducedBlock = 1234567
            };

            StateCompare             sc      = new StateCompare(cp);
            List <StateChangeAction> actions = sc.ComputeActionsFromState(newState);

            // Assert
            actions.Should().BeEmpty();
        }
コード例 #2
0
        public void ShouldGenerateSigningAction()
        {
            MockConfigProvider cp = new MockConfigProvider {
                CurrentState = new NodeState
                {
                    IsSigning             = true,
                    DockerImage           = "parity/parity:v2.3.4",
                    DockerChecksum        = "9f0142e1ae1641fbcf6116c49b5c73d5a4b48340e07f9ecb4da8d2d9847a76e6",
                    ChainspecUrl          = "https://www.example.com/chainspec-20190210.json",
                    ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                    UpdateIntroducedBlock = 1234567
                }
            };

            // Recreate the same state so state object references are different
            NodeState newState = new NodeState
            {
                IsSigning             = false,
                DockerImage           = "parity/parity:v2.3.4",
                DockerChecksum        = "9f0142e1ae1641fbcf6116c49b5c73d5a4b48340e07f9ecb4da8d2d9847a76e6",
                ChainspecUrl          = "https://www.example.com/chainspec-20190210.json",
                ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                UpdateIntroducedBlock = 1234567
            };

            StateCompare             sc      = new StateCompare(cp);
            List <StateChangeAction> actions = sc.ComputeActionsFromState(newState);

            // Assert
            actions.Should().HaveCount(1);
            actions.Should().ContainSingle(action =>
                                           action.Mode == UpdateMode.ToggleSigning &&
                                           action.Payload == false.ToString() &&
                                           action.PayloadHash == string.Empty);
        }
コード例 #3
0
        public void ShouldGenerateDockerAction()
        {
            MockConfigProvider cp = new MockConfigProvider {
                CurrentState = new NodeState
                {
                    IsSigning             = true,
                    DockerImage           = "parity/parity:v2.3.4",
                    DockerChecksum        = "9f0142e1ae1641fbcf6116c49b5c73d5a4b48340e07f9ecb4da8d2d9847a76e6",
                    ChainspecUrl          = "https://foo.bar",
                    ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                    UpdateIntroducedBlock = 1234567
                }
            };

            // Recreate the same state so state object references are different
            NodeState newState = new NodeState
            {
                IsSigning             = true,
                DockerImage           = "parity/parity:v2.4.4",
                DockerChecksum        = "c30bcff5580cb5d9c4edb0a0c8794210e85a134c2f12ffd166735e7c26079211",
                ChainspecUrl          = "https://foo.bar",
                ChainspecChecksum     = "b76377f4f130134f352e81c8929fb0c8ffca94da722f704d16d0873fc9e030ea",
                UpdateIntroducedBlock = 1234567
            };

            StateCompare             sc      = new StateCompare(cp);
            List <StateChangeAction> actions = sc.ComputeActionsFromState(newState);

            // Assert
            actions.Should().HaveCount(1);
            actions.Should().ContainSingle(action =>
                                           action.Mode == UpdateMode.Docker &&
                                           action.Payload == "parity/parity:v2.4.4" &&
                                           action.PayloadHash == "c30bcff5580cb5d9c4edb0a0c8794210e85a134c2f12ffd166735e7c26079211");
        }
コード例 #4
0
        public void ShouldThrowWhenComparingNullState()
        {
            MockConfigProvider cp = new MockConfigProvider();
            StateCompare       sc = new StateCompare(cp);

            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => { sc.ComputeActionsFromState(null); });

            Assert.Equal("newState", ex.ParamName);
        }
コード例 #5
0
        public void ShouldThrowWhenNullStateFromConfigProvider()
        {
            MockConfigProvider cp = new MockConfigProvider {
                CurrentState = null
            };
            StateCompare sc = new StateCompare(cp);

            StateCompareException ex = Assert.Throws <StateCompareException>(() =>
            {
                sc.ComputeActionsFromState(new NodeState());
            });

            Assert.Equal("Received state from configuration provider is null. Can't compare", ex.Message);
        }
コード例 #6
0
        public void ShouldGenerateActionCombinations(NodeState currentState, NodeState newState, List <StateChangeAction> expectedActions)
        {
            MockConfigProvider cp = new MockConfigProvider {
                CurrentState = currentState
            };

            StateCompare             sc      = new StateCompare(cp);
            List <StateChangeAction> actions = sc.ComputeActionsFromState(newState);

            // Assert
            actions.Should().HaveCount(expectedActions.Count);

            foreach (StateChangeAction expAction in expectedActions)
            {
                actions.Should().ContainEquivalentOf(expAction);
            }
        }