Skip to content

Commit

Permalink
Merge pull request #255 from vegaprotocol/254-vwt-auth-header
Browse files Browse the repository at this point in the history
VWT update
  • Loading branch information
peterbarrow authored Jan 17, 2023
2 parents d09ff18 + 8c17ced commit bb23f20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions perftest/perftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func (p *perfLoadTesting) seedPeggedOrders(marketIDs []string, peggedOrderCount,
if err != nil {
return err
}
time.Sleep(time.Millisecond * 25)
}
}
return nil
Expand Down
13 changes: 5 additions & 8 deletions perftest/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand All @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bb23f20

Please sign in to comment.