Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4418: repaired a few other tests that weren't mocking out Transactio…
Browse files Browse the repository at this point in the history
…nByHash/PreFilteredTransactionByHash
sreuland committed Jun 6, 2022

Verified

This commit was signed with the committer’s verified signature.
sreuland shawn
1 parent 1aaecf4 commit 32b11f0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions services/horizon/internal/txsub/system_test.go
Original file line number Diff line number Diff line change
@@ -161,6 +161,8 @@ func (suite *SystemTestSuite) TestTimeoutDuringSequnceLoop() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil)
@@ -188,6 +190,8 @@ func (suite *SystemTestSuite) TestClientDisconnectedDuringSequnceLoop() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil).
@@ -229,6 +233,8 @@ func (suite *SystemTestSuite) TestSubmit_NotFoundError() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil).
@@ -257,8 +263,6 @@ func (suite *SystemTestSuite) TestSubmit_BadSeq() {
ReadOnly: true,
}).Return(nil).Once()
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil).
@@ -267,6 +271,10 @@ func (suite *SystemTestSuite) TestSubmit_BadSeq() {
Return(map[string]uint64{suite.unmuxedSource.Address(): 1}, nil).
Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Twice()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Run(func(args mock.Arguments) {
ptr := args.Get(1).(*history.Transaction)
*ptr = suite.successTx.Transaction
@@ -295,6 +303,8 @@ func (suite *SystemTestSuite) TestSubmit_BadSeqNotFound() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Twice()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Twice()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Twice()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil).
@@ -327,6 +337,8 @@ func (suite *SystemTestSuite) TestSubmit_OpenTransactionList() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, suite.successTx.Transaction.TransactionHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{suite.unmuxedSource.Address()}).
Return(map[string]uint64{suite.unmuxedSource.Address(): 0}, nil).
@@ -442,6 +454,8 @@ func (suite *SystemTestSuite) TestTickFinishFeeBumpTransaction() {
suite.db.On("Rollback").Return(nil).Once()
suite.db.On("PreFilteredTransactionByHash", suite.ctx, mock.Anything, innerHash).
Return(sql.ErrNoRows).Once()
suite.db.On("TransactionByHash", suite.ctx, mock.Anything, innerHash).
Return(sql.ErrNoRows).Once()
suite.db.On("NoRows", sql.ErrNoRows).Return(true).Once()
suite.db.On("GetSequenceNumbers", suite.ctx, []string{"GABQGAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2MX"}).
Return(map[string]uint64{"GABQGAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2MX": 96}, nil).

0 comments on commit 32b11f0

Please sign in to comment.