testsuite/storjscan: add client claim wallet test
Adds integration test for storjscan client claim eth wallet method. Change-Id: I69d1e4f9417c1225e97d5e5c6f0f394eaf68fbef
This commit is contained in:
parent
53db7a897f
commit
a6ad86dc53
@ -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)
|
||||
}
|
||||
@ -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
testsuite/storjscan/client_test.go
Normal file
29
testsuite/storjscan/client_test.go
Normal file
@ -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))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user