From 9dfd6900f99377c672bdd5612ba9fb9fa5ea8430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=B6ckli?= Date: Thu, 4 Jan 2024 13:51:28 +0100 Subject: [PATCH] BAARC-96: fix tests --- metamorph/processor_test.go | 32 -------------------------------- metamorph/server_test.go | 10 ++++++---- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/metamorph/processor_test.go b/metamorph/processor_test.go index 326ed2c97..9b44c1e6d 100644 --- a/metamorph/processor_test.go +++ b/metamorph/processor_test.go @@ -108,7 +108,6 @@ func TestLoadUnmined(t *testing.T) { getTransactionBlockErr error delErr error - expectedDeletions int expectedItemTxHashesFinal []*chainhash.Hash }{ { @@ -187,20 +186,6 @@ func TestLoadUnmined(t *testing.T) { expectedItemTxHashesFinal: []*chainhash.Hash{testdata.TX2Hash}, }, - { - name: "delete expired", - storedData: []*store.StoreData{ - { - StoredAt: storedAt.Add(-400 * time.Hour), - AnnouncedAt: storedAt.Add(1 * time.Second), - Hash: testdata.TX2Hash, - Status: metamorph_api.Status_SEEN_ON_NETWORK, - }, - }, - - expectedDeletions: 1, - expectedItemTxHashesFinal: []*chainhash.Hash{}, - }, { name: "delete expired - deletion fails", storedData: []*store.StoreData{ @@ -213,22 +198,6 @@ func TestLoadUnmined(t *testing.T) { }, delErr: errors.New("failed to delete hash"), - expectedDeletions: 1, - expectedItemTxHashesFinal: []*chainhash.Hash{testdata.TX2Hash}, - }, - { - name: "delete expired - centralised storage", - isCentralised: true, - storedData: []*store.StoreData{ - { - StoredAt: storedAt.Add(-400 * time.Hour), - AnnouncedAt: storedAt.Add(1 * time.Second), - Hash: testdata.TX2Hash, - Status: metamorph_api.Status_SEEN_ON_NETWORK, - }, - }, - - expectedDeletions: 0, expectedItemTxHashesFinal: []*chainhash.Hash{testdata.TX2Hash}, }, } @@ -314,7 +283,6 @@ func TestLoadUnmined(t *testing.T) { allItemHashes = append(allItemHashes, item.Hash) } - require.Equal(t, tc.expectedDeletions, len(mtmStore.DelCalls())) require.ElementsMatch(t, tc.expectedItemTxHashesFinal, allItemHashes) }) } diff --git a/metamorph/server_test.go b/metamorph/server_test.go index 5176ca51c..4d57d0729 100644 --- a/metamorph/server_test.go +++ b/metamorph/server_test.go @@ -268,6 +268,7 @@ func TestServer_GetTransactionStatus(t *testing.T) { getTxMerklePathErr error getErr error status metamorph_api.Status + merklePath string want *metamorph_api.TransactionStatus wantErr assert.ErrorAssertionFunc @@ -289,7 +290,8 @@ func TestServer_GetTransactionStatus(t *testing.T) { req: &metamorph_api.TransactionStatusRequest{ Txid: testdata.TX1, }, - status: metamorph_api.Status_SENT_TO_NETWORK, + status: metamorph_api.Status_SENT_TO_NETWORK, + merklePath: "00000", want: &metamorph_api.TransactionStatus{ StoredAt: timestamppb.New(testdata.Time), @@ -315,7 +317,7 @@ func TestServer_GetTransactionStatus(t *testing.T) { MinedAt: timestamppb.New(testdata.Time.Add(2 * time.Second)), Txid: testdata.TX1, Status: metamorph_api.Status_SENT_TO_NETWORK, - MerklePath: "00000", + MerklePath: "", }, wantErr: assert.NoError, }, @@ -333,7 +335,7 @@ func TestServer_GetTransactionStatus(t *testing.T) { MinedAt: timestamppb.New(testdata.Time.Add(2 * time.Second)), Txid: testdata.TX1, Status: metamorph_api.Status_MINED, - MerklePath: "00000", + MerklePath: "", }, wantErr: assert.NoError, }, @@ -342,7 +344,7 @@ func TestServer_GetTransactionStatus(t *testing.T) { t.Run(tt.name, func(t *testing.T) { client := &ClientIMock{ GetTransactionMerklePathFunc: func(ctx context.Context, transaction *blocktx_api.Transaction) (string, error) { - return "00000", tt.getTxMerklePathErr + return tt.merklePath, tt.getTxMerklePathErr }, }