Skip to content

Commit ade3c1f

Browse files
committed
#134 fix mempool tests
1 parent ff2c94b commit ade3c1f

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

common/query/mempoolQuery_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var mockMempoolQuery = &MempoolQuery{
1616
TableName: "mempool",
1717
Fields: []string{
1818
"id", "fee_per_byte", "arrival_timestamp", "transaction_bytes",
19-
"sender_account_id", "recipient_account_id",
19+
"sender_account_address", "recipient_account_address",
2020
},
2121
}
2222

@@ -67,8 +67,8 @@ func TestMempoolQuery_getTableName(t *testing.T) {
6767
func TestMempoolQuery_GetMempoolTransactions(t *testing.T) {
6868
t.Run("GetMempoolTransactions:success", func(t *testing.T) {
6969
q := mockMempoolQuery.GetMempoolTransactions()
70-
wantQ := "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_id" +
71-
", recipient_account_id FROM mempool"
70+
wantQ := "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_address" +
71+
", recipient_account_address FROM mempool"
7272
if q != wantQ {
7373
t.Errorf("query returned wrong: get: %s\nwant: %s", q, wantQ)
7474
}
@@ -78,8 +78,8 @@ func TestMempoolQuery_GetMempoolTransactions(t *testing.T) {
7878
func TestMempoolQuery_GetMempoolTransaction(t *testing.T) {
7979
t.Run("GetMempoolTransaction:success", func(t *testing.T) {
8080
q := mockMempoolQuery.GetMempoolTransaction()
81-
wantQ := "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_id," +
82-
" recipient_account_id FROM mempool WHERE id = :id"
81+
wantQ := "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_address," +
82+
" recipient_account_address FROM mempool WHERE id = :id"
8383
if q != wantQ {
8484
t.Errorf("query returned wrong: get: %s\nwant: %s", q, wantQ)
8585
}
@@ -89,9 +89,9 @@ func TestMempoolQuery_GetMempoolTransaction(t *testing.T) {
8989
func TestMempoolQuery_InsertMempoolTransaction(t *testing.T) {
9090
t.Run("InsertMempoolTransaction:success", func(t *testing.T) {
9191
q := mockMempoolQuery.InsertMempoolTransaction()
92-
wantQ := "INSERT INTO mempool (id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_id," +
93-
" recipient_account_id) VALUES(:id, :fee_per_byte, :arrival_timestamp, :transaction_bytes," +
94-
" :sender_account_id, :recipient_account_id)"
92+
wantQ := "INSERT INTO mempool (id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_address," +
93+
" recipient_account_address) VALUES(:id, :fee_per_byte, :arrival_timestamp, :transaction_bytes," +
94+
" :sender_account_address, :recipient_account_address)"
9595
if q != wantQ {
9696
t.Errorf("query returned wrong: get: %s\nwant: %s", q, wantQ)
9797
}

core/service/mempoolCoreService_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ type (
2323
}
2424
)
2525

26-
var getTxByIDQuery = "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_id, " +
27-
"recipient_account_id FROM mempool WHERE id = :id"
26+
var getTxByIDQuery = "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_address, " +
27+
"recipient_account_address FROM mempool WHERE id = :id"
2828

2929
func (*mockMempoolQueryExecutorSuccess) ExecuteSelect(qe string, args ...interface{}) (*sql.Rows, error) {
3030
db, mock, _ := sqlmock.New()
3131
defer db.Close()
3232
switch qe {
3333

34-
case "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_id, recipient_account_id FROM mempool":
35-
mockedRows := sqlmock.NewRows([]string{"id", "fee_per_byte", "arrival_timestamp", "transaction_bytes", "sender_account_id",
36-
"recipient_account_id"})
34+
case "SELECT id, fee_per_byte, arrival_timestamp, transaction_bytes, sender_account_address, recipient_account_address FROM mempool":
35+
mockedRows := sqlmock.NewRows([]string{"id", "fee_per_byte", "arrival_timestamp", "transaction_bytes", "sender_account_address",
36+
"recipient_account_address"})
3737
mockedRows.AddRow(1, 1, 1562893305, getTestSignedMempoolTransaction(1, 1562893305).TransactionBytes, "A", "B")
3838
mockedRows.AddRow(2, 10, 1562893304, getTestSignedMempoolTransaction(2, 1562893304).TransactionBytes, "A", "B")
3939
mockedRows.AddRow(3, 1, 1562893302, getTestSignedMempoolTransaction(3, 1562893302).TransactionBytes, "A", "B")
@@ -75,7 +75,7 @@ func (*mockMempoolQueryExecutorFail) ExecuteSelect(qe string, args ...interface{
7575
// before adding mempool transactions to db we check for duplicate transactions
7676
case getTxByIDQuery:
7777
mock.ExpectQuery(regexp.QuoteMeta(qe)).WillReturnRows(sqlmock.NewRows([]string{
78-
"id", "fee_per_byte", "arrival_timestamp", "transaction_bytes", "sender_account_id", "recipient_account_id"},
78+
"id", "fee_per_byte", "arrival_timestamp", "transaction_bytes", "sender_account_address", "recipient_account_address"},
7979
).AddRow(3, 1, 1562893302, []byte{}, []byte{1}, []byte{2}))
8080
default:
8181
return nil, errors.New("MockedError")

0 commit comments

Comments
 (0)