Skip to content

Commit

Permalink
Removed flakey testcases and optimized for parallel test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Dec 17, 2024
1 parent 10f03fd commit 0384b94
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 94 deletions.
2 changes: 2 additions & 0 deletions pkg/loop/internal/goplugin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package goplugin
import (
"context"
"errors"
"fmt"
"time"

"google.golang.org/grpc"
Expand Down Expand Up @@ -82,6 +83,7 @@ type ServiceServer struct {
}

func (s *ServiceServer) Close(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) {
fmt.Println("CLOSING CLIENT SERVICE")
return &emptypb.Empty{}, s.Srv.Close()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func (c *Client) Bind(ctx context.Context, bindings []types.BoundContract) error
}

_, err := c.grpc.Bind(ctx, &pb.BindRequest{Bindings: pbBindings})
fmt.Println("ERROR:", err)
return net.WrapRPCErr(err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ func (it *fakeContractReaderInterfaceTester) Setup(_ *testing.T) {
}
}

func (it *fakeContractReaderInterfaceTester) Init(_ *testing.T) {

}

func (it *fakeContractReaderInterfaceTester) GetContractReader(_ *testing.T) types.ContractReader {
return it.impl
}
Expand Down Expand Up @@ -1014,6 +1018,7 @@ func runContractReaderByIDQueryKey(t *testing.T) {
func(t *testing.T) {
t.Parallel()
fake := &fakeContractReader{}
fakeCW := &fakeContractWriter{}
tester := &fakeContractReaderInterfaceTester{impl: fake}
tester.Setup(t)

Expand All @@ -1031,14 +1036,14 @@ func runContractReaderByIDQueryKey(t *testing.T) {
require.NoError(t, cr.Bind(ctx, toBind))

ts1AnyContract := CreateTestStruct(0, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnyContract, anyContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnyContract, anyContract, types.Unconfirmed)
ts2AnyContract := CreateTestStruct(1, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnyContract, anyContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnyContract, anyContract, types.Unconfirmed)

ts1AnySecondContract := CreateTestStruct(0, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnySecondContract, anySecondContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnySecondContract, anySecondContract, types.Unconfirmed)
ts2AnySecondContract := CreateTestStruct(1, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnySecondContract, anySecondContract, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnySecondContract, anySecondContract, types.Unconfirmed)

tsAnyContractType := &TestStruct{}
require.Eventually(t, func() bool {
Expand All @@ -1057,6 +1062,8 @@ func runContractReaderByIDQueryKey(t *testing.T) {
func(t *testing.T) {
t.Parallel()
fake := &fakeContractReader{}
fakeCW := &fakeContractWriter{}

tester := &fakeContractReaderInterfaceTester{impl: fake}
tester.Setup(t)

Expand All @@ -1077,22 +1084,22 @@ func runContractReaderByIDQueryKey(t *testing.T) {
require.NoError(t, cr.Bind(ctx, toBind))

ts1AnyContract1 := CreateTestStruct(0, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnyContract1, anyContract1, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnyContract1, anyContract1, types.Unconfirmed)
ts2AnyContract1 := CreateTestStruct(1, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnyContract1, anyContract1, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnyContract1, anyContract1, types.Unconfirmed)
ts1AnyContract2 := CreateTestStruct(2, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnyContract2, anyContract2, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnyContract2, anyContract2, types.Unconfirmed)
ts2AnyContract2 := CreateTestStruct(3, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnyContract2, anyContract2, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnyContract2, anyContract2, types.Unconfirmed)

ts1AnySecondContract1 := CreateTestStruct(4, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnySecondContract1, anySecondContract1, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnySecondContract1, anySecondContract1, types.Unconfirmed)
ts2AnySecondContract1 := CreateTestStruct(5, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnySecondContract1, anySecondContract1, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnySecondContract1, anySecondContract1, types.Unconfirmed)
ts1AnySecondContract2 := CreateTestStruct(6, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts1AnySecondContract2, anySecondContract2, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts1AnySecondContract2, anySecondContract2, types.Unconfirmed)
ts2AnySecondContract2 := CreateTestStruct(7, tester)
_ = SubmitTransactionToCW(t, tester, MethodTriggeringEvent, ts2AnySecondContract2, anySecondContract2, types.Unconfirmed)
_ = SubmitTransactionToCW(t, tester, fakeCW, MethodTriggeringEvent, ts2AnySecondContract2, anySecondContract2, types.Unconfirmed)

tsAnyContractType := &TestStruct{}
require.Eventually(t, func() bool {
Expand Down
Loading

0 comments on commit 0384b94

Please sign in to comment.