From 8c17ced894b68458ac6b245ba32ec2318f53c680 Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Tue, 17 Jan 2023 11:27:51 +0000 Subject: [PATCH] fix: VWT update --- CHANGELOG.md | 1 + perftest/perftest.go | 1 + perftest/wallet.go | 13 +++++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96fd5f5..0c2afa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ - [240](https://github.com/vegaprotocol/vegatools/issues/240) - Add support for filling price levels before perf testing begins - [247](https://github.com/vegaprotocol/vegatools/issues/247) - Made ganache value optional for perftool - [251](https://github.com/vegaprotocol/vegatools/issues/251) - Changed code to use wallet V2 and updated protobuf mod to correct version +- [254](https://github.com/vegaprotocol/vegatools/issues/254) - Updated auth to use VWT header value ### 🐛 Fixes - [78](https://github.com/vegaprotocol/vegatools/pull/78) - Fix build with missing dependency diff --git a/perftest/perftest.go b/perftest/perftest.go index c6dc7fb..f78c86f 100644 --- a/perftest/perftest.go +++ b/perftest/perftest.go @@ -298,6 +298,7 @@ func (p *perfLoadTesting) seedPeggedOrders(marketIDs []string, peggedOrderCount, if err != nil { return err } + time.Sleep(time.Millisecond * 25) } } return nil diff --git a/perftest/wallet.go b/perftest/wallet.go index 968549a..b2fcefc 100644 --- a/perftest/wallet.go +++ b/perftest/wallet.go @@ -50,7 +50,6 @@ func (w walletWrapper) sendTransaction(user UserDetails, subType string, subData "method": "client.send_transaction", "id": "1", "params": map[string]interface{}{ - "token": user.token, "publicKey": user.pubKey, "sendingMode": "TYPE_SYNC", "transaction": map[string]interface{}{ @@ -59,10 +58,10 @@ func (w walletWrapper) sendTransaction(user UserDetails, subType string, subData }, }) - return w.sendRequest(transaction) + return w.sendRequest(transaction, user.token) } -func (w walletWrapper) sendRequest(request []byte) ([]byte, error) { +func (w walletWrapper) sendRequest(request []byte, token string) ([]byte, error) { postBody := bytes.NewBuffer(request) URL := "http://" + w.walletURL + "/api/v2/requests" @@ -72,6 +71,7 @@ func (w walletWrapper) sendRequest(request []byte) ([]byte, error) { return nil, err } req.Header.Add("origin", "perfbot") + req.Header.Add("Authorization", fmt.Sprintf("VWT %s", token)) client := &http.Client{} resp, err := client.Do(req) @@ -183,16 +183,13 @@ func (w walletWrapper) NewMarket(offset int, user UserDetails) error { } // GetFirstKey gives us the first public key linked to our wallet -func (w walletWrapper) GetFirstKey(longLivenToken string) (string, error) { +func (w walletWrapper) GetFirstKey(longLivedToken string) (string, error) { post, _ := json.Marshal(map[string]interface{}{ "id": "1", "jsonrpc": "2.0", "method": "client.list_keys", - "params": map[string]string{ - "token": longLivenToken, - }, }) - body, err := w.sendRequest(post) + body, err := w.sendRequest(post, longLivedToken) var values listKeysResult = listKeysResult{} err = json.Unmarshal(body, &values)