@ -1117,54 +1117,80 @@ func TestIBFT_IsAcceptableMessage(t *testing.T) {
testTable := [ ] struct {
testTable := [ ] struct {
name string
name string
view * proto . View
msgView * proto . View
currentView * proto . View
stateView * proto . View
invalidSender bool
invalidSender bool
acceptable bool
acceptable bool
} {
} {
{
{
"invalid sender" ,
name : "invalid sender" ,
nil ,
msgView : nil ,
baseView ,
stateView : baseView ,
true ,
invalidSender : true ,
false ,
acceptable : false ,
} ,
} ,
{
{
"malformed message" ,
name : "malformed message" ,
nil ,
msgView : nil ,
baseView ,
stateView : baseView ,
false ,
invalidSender : false ,
false ,
acceptable : false ,
} ,
} ,
{
{
"higher height number" ,
name : "higher height, same round number" ,
& proto . View {
msgView : & proto . View {
Height : baseView . Height + 100 ,
Height : baseView . Height + 100 ,
Round : baseView . Round ,
Round : baseView . Round ,
} ,
} ,
baseView ,
stateView : baseView ,
false ,
invalidSender : false ,
true ,
acceptable : true ,
} ,
} ,
{
{
"higher round number" ,
name : "higher height, lower round number" ,
& proto . View {
msgView : & proto . View {
Height : baseView . Height + 100 ,
Round : baseView . Round ,
} ,
stateView : & proto . View {
Height : baseView . Height ,
Height : baseView . Height ,
Round : baseView . Round + 1 ,
Round : baseView . Round + 1 ,
} ,
} ,
baseView ,
invalidSender : false ,
false ,
acceptable : true ,
true ,
} ,
} ,
{
{
"lower height number" ,
name : "same heights, higher round number" ,
baseView ,
msgView : & proto . View {
& proto . View {
Height : baseView . Height ,
Round : baseView . Round + 1 ,
} ,
stateView : baseView ,
invalidSender : false ,
acceptable : true ,
} ,
{
name : "same heights, lower round number" ,
msgView : & proto . View {
Height : baseView . Height ,
Round : baseView . Round + 1 ,
} ,
stateView : & proto . View {
Height : baseView . Height ,
Round : baseView . Round + 2 ,
} ,
invalidSender : false ,
acceptable : false ,
} ,
{
name : "lower height number" ,
msgView : baseView ,
stateView : & proto . View {
Height : baseView . Height + 1 ,
Height : baseView . Height + 1 ,
Round : baseView . Round ,
Round : baseView . Round ,
} ,
} ,
false ,
invalidSender : false ,
false ,
acceptable : false ,
} ,
} ,
}
}
@ -1184,10 +1210,10 @@ func TestIBFT_IsAcceptableMessage(t *testing.T) {
}
}
)
)
i := NewIBFT ( log , backend , transport )
i := NewIBFT ( log , backend , transport )
i . state . view = testCase . current View
i . state . view = testCase . state View
message := & proto . Message {
message := & proto . Message {
View : testCase . v iew,
View : testCase . msgV iew,
}
}
assert . Equal ( t , testCase . acceptable , i . isAcceptableMessage ( message ) )
assert . Equal ( t , testCase . acceptable , i . isAcceptableMessage ( message ) )