Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed May 27, 2024
1 parent ccb44b3 commit c784cc9
Showing 1 changed file with 60 additions and 86 deletions.
146 changes: 60 additions & 86 deletions x/delayedack/types/rollapp_packets_list_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,42 @@ func TestByRollappID(t *testing.T) {
tests := []struct {
name string
args args
want types.RollappPacketListFilter
want []types.Prefix
}{
{
name: "Test with rollappID 1",
args: args{
rollappID: "testRollappID1",
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x03, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x03, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
},
}, {
name: "Test with empty rollappID",
args: args{
rollappID: "",
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x2f},
}, {
Start: []uint8{0x00, 0x03, 0x2f, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x2f},
}, {
Start: []uint8{0x00, 0x03, 0x2f, 0x2f},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filter := types.ByRollappID(tt.args.rollappID)
require.Equal(t, tt.want, filter)
require.Equal(t, tt.want, filter.Prefixes)
})
}
}
Expand All @@ -69,19 +65,17 @@ func TestByRollappIDByStatus(t *testing.T) {
tests := []struct {
name string
args args
want types.RollappPacketListFilter
want []types.Prefix
}{
{
name: "Test with rollappID 1 and status PENDING",
args: args{
rollappID: "testRollappID1",
status: []commontypes.Status{commontypes.Status_PENDING},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
},
}, {
Expand All @@ -90,11 +84,9 @@ func TestByRollappIDByStatus(t *testing.T) {
rollappID: "testRollappID1",
status: []commontypes.Status{commontypes.Status_FINALIZED},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
},
}, {
Expand All @@ -103,11 +95,9 @@ func TestByRollappIDByStatus(t *testing.T) {
rollappID: "testRollappID1",
status: []commontypes.Status{commontypes.Status_REVERTED},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x03, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x03, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
},
}, {
Expand All @@ -116,13 +106,11 @@ func TestByRollappIDByStatus(t *testing.T) {
rollappID: "testRollappID1",
status: []commontypes.Status{commontypes.Status_PENDING, commontypes.Status_FINALIZED},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
}, {
Start: []uint8{0x00, 0x02, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f},
},
},
}, {
Expand All @@ -131,19 +119,17 @@ func TestByRollappIDByStatus(t *testing.T) {
rollappID: "",
status: []commontypes.Status{commontypes.Status_PENDING},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x2f},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filter := types.ByRollappIDByStatus(tt.args.rollappID, tt.args.status...)
require.Equal(t, tt.want, filter)
require.Equal(t, tt.want, filter.Prefixes)
})
}
}
Expand All @@ -155,50 +141,44 @@ func TestByStatus(t *testing.T) {
tests := []struct {
name string
args args
want types.RollappPacketListFilter
want []types.Prefix
}{
{
name: "Test with status PENDING",
args: args{
status: []commontypes.Status{commontypes.Status_PENDING},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f},
},
},
}, {
name: "Test with status FINALIZED",
args: args{
status: []commontypes.Status{commontypes.Status_FINALIZED},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x02, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x02, 0x2f},
},
},
}, {
name: "Test with status REVERTED",
args: args{
status: []commontypes.Status{commontypes.Status_REVERTED},
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x03, 0x2f},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x03, 0x2f},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filter := types.ByStatus(tt.args.status...)
require.Equal(t, tt.want, filter)
require.Equal(t, tt.want, filter.Prefixes)
})
}
}
Expand All @@ -211,20 +191,18 @@ func TestPendingByRollappIDByMaxHeight(t *testing.T) {
tests := []struct {
name string
args args
want types.RollappPacketListFilter
want []types.Prefix
}{
{
name: "Test with rollappID 1 and maxProofHeight 100",
args: args{
rollappID: "testRollappID1",
maxProofHeight: 100,
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
End: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65},
},
want: []types.Prefix{
{
Start: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
End: []uint8{0x00, 0x01, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65},
},
},
}, {
Expand All @@ -233,12 +211,10 @@ func TestPendingByRollappIDByMaxHeight(t *testing.T) {
rollappID: "",
maxProofHeight: 100,
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x0, 0x1, 0x2f, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
End: []uint8{0x0, 0x1, 0x2f, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65},
},
want: []types.Prefix{
{
Start: []uint8{0x0, 0x1, 0x2f, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
End: []uint8{0x0, 0x1, 0x2f, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65},
},
},
}, {
Expand All @@ -247,20 +223,18 @@ func TestPendingByRollappIDByMaxHeight(t *testing.T) {
rollappID: "testRollappID1",
maxProofHeight: 0,
},
want: types.RollappPacketListFilter{
Prefixes: []types.Prefix{
{
Start: []uint8{0x0, 0x1, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
End: []uint8{0x0, 0x1, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1},
},
want: []types.Prefix{
{
Start: []uint8{0x0, 0x1, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
End: []uint8{0x0, 0x1, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x49, 0x44, 0x31, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filter := types.PendingByRollappIDByMaxHeight(tt.args.rollappID, tt.args.maxProofHeight)
require.Equal(t, tt.want, filter)
require.Equal(t, tt.want, filter.Prefixes)
})
}
}
Expand Down

0 comments on commit c784cc9

Please sign in to comment.