-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8619 from smartcontractkit/http_ws_load_groups
http/ws load groups for mercury-server + 1 DON
- Loading branch information
Showing
8 changed files
with
514 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package load | ||
|
||
import ( | ||
"fmt" | ||
"sync/atomic" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
"github.com/smartcontractkit/chainlink-testing-framework/blockchain" | ||
"github.com/smartcontractkit/chainlink-testing-framework/loadgen" | ||
"github.com/smartcontractkit/chainlink/integration-tests/client" | ||
"github.com/smartcontractkit/chainlink/integration-tests/testsetups" | ||
) | ||
|
||
var ReportTypes = GetReportTypes() | ||
|
||
func mustNewType(t string) abi.Type { | ||
result, err := abi.NewType(t, "", []abi.ArgumentMarshaling{}) | ||
if err != nil { | ||
panic(fmt.Sprintf("Unexpected error during abi.NewType: %s", err)) | ||
} | ||
return result | ||
} | ||
|
||
func GetReportTypes() abi.Arguments { | ||
return []abi.Argument{ | ||
{Name: "feedId", Type: mustNewType("bytes32")}, | ||
{Name: "observationsTimestamp", Type: mustNewType("uint32")}, | ||
{Name: "observationsBlocknumber", Type: mustNewType("uint64")}, | ||
{Name: "median", Type: mustNewType("int192")}, | ||
} | ||
} | ||
|
||
type MercuryHTTPGun struct { | ||
BaseURL string | ||
client *client.MercuryServer | ||
netclient blockchain.EVMClient | ||
feedID string | ||
bn atomic.Uint64 | ||
} | ||
|
||
func NewHTTPGun(baseURL string, client *client.MercuryServer, feedID string, bn uint64) *MercuryHTTPGun { | ||
g := &MercuryHTTPGun{ | ||
BaseURL: baseURL, | ||
client: client, | ||
feedID: feedID, | ||
} | ||
g.bn.Store(bn) | ||
return g | ||
} | ||
|
||
// Call implements example gun call, assertions on response bodies should be done here | ||
func (m *MercuryHTTPGun) Call(l *loadgen.Generator) loadgen.CallResult { | ||
answer, res, err := m.client.GetReports(m.feedID, m.bn.Load()) | ||
if err != nil { | ||
return loadgen.CallResult{Error: "connection error"} | ||
} | ||
if res.Status != "200 OK" { | ||
return loadgen.CallResult{Error: "not 200"} | ||
} | ||
reportElements := map[string]interface{}{} | ||
if err = ReportTypes.UnpackIntoMap(reportElements, []byte(answer.ChainlinkBlob)); err != nil { | ||
return loadgen.CallResult{Error: "blob unpacking error"} | ||
} | ||
if err := testsetups.ValidateReport(reportElements); err != nil { | ||
return loadgen.CallResult{Error: "report validation error"} | ||
} | ||
return loadgen.CallResult{} | ||
} |
Oops, something went wrong.