public Optional<VoterSet> updateVoter(VoterNode voter) {
        VoterNode oldVoter = voters.get(voter.voterKey().id());
        if (oldVoter != null && oldVoter.isVoter(voter.voterKey())) {
            HashMap<Integer, VoterNode> newVoters = new HashMap<>(voters);
            newVoters.put(voter.voterKey().id(), voter);

            return Optional.of(new VoterSet(newVoters));
        }

        return Optional.empty();
    }
@Test
    void testUpdateVoter() {
        Map<Integer, VoterSet.VoterNode> aVoterMap = voterMap(IntStream.of(1, 2, 3), true);
        VoterSet voterSet = VoterSet.fromMap(new HashMap<>(aVoterMap));

        assertEquals(Optional.empty(), voterSet.updateVoter(voterNode(4, true)));
        assertFalse(voterSet.voterNodeNeedsUpdate(voterNode(4, true)));
        assertEquals(Optional.empty(), voterSet.updateVoter(voterNode(3, true)));
        assertFalse(voterSet.voterNodeNeedsUpdate(voterNode(3, true)));

        VoterSet.VoterNode voter3 = aVoterMap.get(3);
        VoterSet.VoterNode newVoter3 = VoterSet.VoterNode.of(
            voter3.voterKey(),
            Endpoints.fromInetSocketAddresses(
                Collections.singletonMap(
                    ListenerName.normalised("ABC"),
                    InetSocketAddress.createUnresolved("abc", 1234)
                )
            ),
            new SupportedVersionRange((short) 1, (short) 1)
        );
        aVoterMap.put(3, newVoter3);

        assertTrue(voterSet.voterNodeNeedsUpdate(newVoter3));
        assertEquals(
            Optional.of(VoterSet.fromMap(new HashMap<>(aVoterMap))),
            voterSet.updateVoter(newVoter3)
        );
    }