|
|
@ -4,7 +4,6 @@ import static net.consensys.pantheon.consensus.common.VoteType.ADD; |
|
|
|
import static net.consensys.pantheon.consensus.common.VoteType.DROP; |
|
|
|
import static net.consensys.pantheon.consensus.common.VoteType.DROP; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
|
|
import net.consensys.pantheon.consensus.common.VoteProposer.Vote; |
|
|
|
|
|
|
|
import net.consensys.pantheon.ethereum.core.Address; |
|
|
|
import net.consensys.pantheon.ethereum.core.Address; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.AbstractMap; |
|
|
|
import java.util.AbstractMap; |
|
|
@ -46,9 +45,9 @@ public class VoteProposerTest { |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.DROP))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.DROP))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.DROP))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.DROP))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
} |
|
|
|
} |
|
|
@ -63,13 +62,13 @@ public class VoteProposerTest { |
|
|
|
proposer.auth(a1); |
|
|
|
proposer.auth(a1); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -84,13 +83,13 @@ public class VoteProposerTest { |
|
|
|
proposer.discard(a2); |
|
|
|
proposer.discard(a2); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.singletonList(a1)))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a1, a2, a3)))) |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
.isEqualTo(Optional.empty()); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Arrays.asList(a2, a3)))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -105,13 +104,13 @@ public class VoteProposerTest { |
|
|
|
proposer.auth(a3); |
|
|
|
proposer.auth(a3); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a3, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a3, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -128,13 +127,13 @@ public class VoteProposerTest { |
|
|
|
proposer.drop(a4); |
|
|
|
proposer.drop(a4); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a3, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a3, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
assertThat(proposer.getVote(localAddress, new VoteTally(Collections.emptyList()))) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a2, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -150,7 +149,7 @@ public class VoteProposerTest { |
|
|
|
tally.addVote(localAddress, a1, ADD); |
|
|
|
tally.addVote(localAddress, a1, ADD); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.DROP))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.DROP))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -166,7 +165,7 @@ public class VoteProposerTest { |
|
|
|
tally.addVote(localAddress, a1, DROP); |
|
|
|
tally.addVote(localAddress, a1, DROP); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -182,7 +181,7 @@ public class VoteProposerTest { |
|
|
|
proposer.drop(a1); |
|
|
|
proposer.drop(a1); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.DROP))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.DROP))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
@ -198,6 +197,6 @@ public class VoteProposerTest { |
|
|
|
proposer.auth(a1); |
|
|
|
proposer.auth(a1); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
assertThat(proposer.getVote(localAddress, tally)) |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, Vote.AUTH))); |
|
|
|
.isEqualTo(Optional.of(new AbstractMap.SimpleEntry<>(a1, VoteType.ADD))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|