Skip to content

Commit

Permalink
BAARC-96: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Jan 4, 2024
1 parent f63cf7d commit 9dfd690
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
32 changes: 0 additions & 32 deletions metamorph/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func TestLoadUnmined(t *testing.T) {
getTransactionBlockErr error
delErr error

expectedDeletions int
expectedItemTxHashesFinal []*chainhash.Hash
}{
{
Expand Down Expand Up @@ -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{
Expand All @@ -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},
},
}
Expand Down Expand Up @@ -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)
})
}
Expand Down
10 changes: 6 additions & 4 deletions metamorph/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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
},
}

Expand Down

0 comments on commit 9dfd690

Please sign in to comment.