Skip to content

Commit

Permalink
testsuite/storjscan: add client claim wallet test
Browse files Browse the repository at this point in the history
Adds integration test for storjscan client claim eth wallet method.

Change-Id: I69d1e4f9417c1225e97d5e5c6f0f394eaf68fbef
  • Loading branch information
rikysya authored and Storj Robot committed Aug 5, 2022
1 parent 53db7a8 commit a6ad86d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
11 changes: 3 additions & 8 deletions satellite/payments/storjscan/client.go
Expand Up @@ -122,7 +122,7 @@ func (client *Client) ClaimNewEthAddress(ctx context.Context) (_ blockchain.Addr

p := client.endpoint + "/api/v0/wallets/claim"

req, err := http.NewRequestWithContext(ctx, http.MethodGet, p, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, p, nil)
if err != nil {
return blockchain.Address{}, ClientErr.Wrap(err)
}
Expand Down Expand Up @@ -153,16 +153,11 @@ func (client *Client) ClaimNewEthAddress(ctx context.Context) (_ blockchain.Addr
}
}

var addressHex string

if err = json.NewDecoder(resp.Body).Decode(&addressHex); err != nil {
return blockchain.Address{}, ClientErr.Wrap(err)
}

var address blockchain.Address

if err = address.UnmarshalJSON([]byte(addressHex)); err != nil {
if err = json.NewDecoder(resp.Body).Decode(&address); err != nil {
return blockchain.Address{}, ClientErr.Wrap(err)
}

return address, nil
}
29 changes: 29 additions & 0 deletions testsuite/storjscan/client_test.go
@@ -0,0 +1,29 @@
// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.

package storjscan_test

import (
"testing"

"github.com/stretchr/testify/require"

"storj.io/common/testcontext"
"storj.io/storj/private/testplanet"
"storj.io/storj/testsuite/storjscan/storjscantest"
"storj.io/storjscan/blockchain"
)

func TestClientWalletsClaim(t *testing.T) {
storjscantest.Run(t, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet, stack *storjscantest.Stack) {
expected, _ := blockchain.AddressFromHex("0x27e3d303B0B70B1b17f14525b48Ae7c45D34666f")
err := stack.App.Wallets.Service.Register(ctx, "eu", map[blockchain.Address]string{
expected: "test",
})
require.NoError(t, err)

addr, err := planet.Satellites[0].API.Payments.StorjscanClient.ClaimNewEthAddress(ctx)
require.NoError(t, err)
require.Equal(t, expected, blockchain.Address(addr))
})
}

1 comment on commit a6ad86d

@storjrobot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Storj Community Forum (official). There might be relevant details there:

https://forum.storj.io/t/release-preparation-v1-62/19444/1

Please sign in to comment.