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(); }
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); }
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"); }
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); }
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); }
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); } }