diff --git a/proxy/grpc/proxy_test.go b/proxy/grpc/proxy_test.go index ab45ae0..cff25d4 100644 --- a/proxy/grpc/proxy_test.go +++ b/proxy/grpc/proxy_test.go @@ -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() diff --git a/test/dummy_test.go b/test/dummy_test.go index 17330c7..4c44618 100644 --- a/test/dummy_test.go +++ b/test/dummy_test.go @@ -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) { diff --git a/test/suite.go b/test/suite.go index b6c0068..6508763 100644 --- a/test/suite.go +++ b/test/suite.go @@ -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. @@ -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.