Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proxy/grpc/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (s *ProxyTestSuite) SetupTest() {

s.client = client
s.Exec = client
s.TxInjector = exec
s.cleanup = func() {
_ = client.Stop()
s.server.Stop()
Expand Down
4 changes: 3 additions & 1 deletion test/dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type DummyTestSuite struct {
}

func (s *DummyTestSuite) SetupTest() {
s.Exec = NewDummyExecutor()
dummy := NewDummyExecutor()
s.Exec = dummy
s.TxInjector = dummy
}

func TestDummySuite(t *testing.T) {
Expand Down
25 changes: 23 additions & 2 deletions test/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import (
// ExecutorSuite is a reusable test suite for Execution API implementations.
type ExecutorSuite struct {
suite.Suite
Exec execution.Executor
Exec execution.Executor
TxInjector TxInjector
}

// TxInjector provides an interface for injecting transactions into a test suite.
type TxInjector interface {
InjectTx(tx types.Tx)
}

// TestInitChain tests InitChain method.
Expand All @@ -30,9 +36,24 @@ func (s *ExecutorSuite) TestInitChain() {

// TestGetTxs tests GetTxs method.
func (s *ExecutorSuite) TestGetTxs() {
s.skipIfInjectorNotSet()

tx1 := types.Tx("tx1")
tx2 := types.Tx("tx2")

s.TxInjector.InjectTx(tx1)
s.TxInjector.InjectTx(tx2)
txs, err := s.Exec.GetTxs(context.TODO())
s.Require().NoError(err)
s.Empty(txs)
s.Require().Len(txs, 2)
s.Require().Contains(txs, tx1)
s.Require().Contains(txs, tx2)
}

func (s *ExecutorSuite) skipIfInjectorNotSet() {
if s.TxInjector == nil {
s.T().Skipf("Skipping %s because TxInjector is not provided", s.T().Name())
}
}

// TestExecuteTxs tests ExecuteTxs method.
Expand Down