From 0922c05839c4e304a71a6f71a1971cf4e55d2119 Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Wed, 31 Jan 2024 12:29:06 +0200 Subject: [PATCH 1/2] Removed UnreserveUtxos --- transactions.go | 5 ----- transactions_test.go | 17 ----------------- transports/http.go | 12 ------------ transports/interface.go | 1 - 4 files changed, 35 deletions(-) diff --git a/transactions.go b/transactions.go index 3c4bebc..063b997 100644 --- a/transactions.go +++ b/transactions.go @@ -75,8 +75,3 @@ func (b *BuxClient) SendToRecipients(ctx context.Context, recipients []*transpor return b.RecordTransaction(ctx, hex, draft.ID, metadata) } - -// UnreserveUtxos unreserves utxos from draft transaction -func (b *BuxClient) UnreserveUtxos(ctx context.Context, referenceID string) transports.ResponseError { - return b.transport.UnreserveUtxos(ctx, referenceID) -} diff --git a/transactions_test.go b/transactions_test.go index e2a85df..18dd437 100644 --- a/transactions_test.go +++ b/transactions_test.go @@ -263,23 +263,6 @@ func TestTransactions(t *testing.T) { assert.Len(t, txDraft.Inputs, len(fixtures.DraftTx.Configuration.Inputs)) assert.Len(t, txDraft.Outputs, len(fixtures.DraftTx.Configuration.Outputs)) }) - - t.Run("UnreserveUtxos", func(t *testing.T) { - // given - transportHandler := testTransportHandler{ - Type: fixtures.RequestType, - Path: "/utxo/unreserve", - ClientURL: fixtures.ServerURL, - Client: WithHTTPClient, - } - client := getTestBuxClient(transportHandler, false) - - // when - err := client.UnreserveUtxos(context.Background(), fixtures.DraftTx.Configuration.Outputs[0].PaymailP4.ReferenceID) - - // then - assert.NoError(t, err) - }) } // TestDraftTransactions will test the DraftTransaction methods diff --git a/transports/http.go b/transports/http.go index 9a8778b..71615fd 100644 --- a/transports/http.go +++ b/transports/http.go @@ -581,18 +581,6 @@ func (h *TransportHTTP) GetUtxosCount(ctx context.Context, conditions map[string return count, nil } -// UnreserveUtxos will unreserve utxos from draft transaction -func (h *TransportHTTP) UnreserveUtxos(ctx context.Context, referenceID string) ResponseError { - jsonStr, err := json.Marshal(map[string]interface{}{ - FieldReferenceID: referenceID, - }) - if err != nil { - return WrapError(err) - } - - return h.doHTTPRequest(ctx, http.MethodPatch, "/utxo/unreserve", jsonStr, h.xPriv, h.signRequest, nil) -} - // createSignatureAccessKey will create a signature for the given access key & body contents func createSignatureAccessKey(privateKeyHex, bodyString string) (payload *buxmodels.AuthPayload, err error) { // No key? diff --git a/transports/interface.go b/transports/interface.go index 1426627..a1f0136 100644 --- a/transports/interface.go +++ b/transports/interface.go @@ -49,7 +49,6 @@ type TransactionService interface { GetUtxo(ctx context.Context, txID string, outputIndex uint32) (*buxmodels.Utxo, ResponseError) GetUtxos(ctx context.Context, conditions map[string]interface{}, metadata *buxmodels.Metadata, queryParams *QueryParams) ([]*buxmodels.Utxo, ResponseError) GetUtxosCount(ctx context.Context, conditions map[string]interface{}, metadata *buxmodels.Metadata) (int64, ResponseError) - UnreserveUtxos(ctx context.Context, referenceID string) ResponseError } // PaymailService is the paymail related requests From 4bc46cfff1b1812f5ff5f8126bc9ecded03c1b06 Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Wed, 31 Jan 2024 12:49:38 +0200 Subject: [PATCH 2/2] Improved tests --- transactions_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/transactions_test.go b/transactions_test.go index 18dd437..5042410 100644 --- a/transactions_test.go +++ b/transactions_test.go @@ -263,6 +263,24 @@ func TestTransactions(t *testing.T) { assert.Len(t, txDraft.Inputs, len(fixtures.DraftTx.Configuration.Inputs)) assert.Len(t, txDraft.Outputs, len(fixtures.DraftTx.Configuration.Outputs)) }) + + t.Run("CountUtxos", func(t *testing.T) { + // given + transportHandler := testTransportHandler{ + Type: fixtures.RequestType, + Path: "/utxo/count", + ClientURL: fixtures.ServerURL, + Result: "0", + Client: WithHTTPClient, + } + client := getTestBuxClient(transportHandler, false) + + // when + _, err := client.GetUtxosCount(context.Background(), map[string]interface{}{}, fixtures.TestMetadata) + + // then + assert.NoError(t, err) + }) } // TestDraftTransactions will test the DraftTransaction methods