Skip to content

Commit

Permalink
rfqmsg: bump minimum supported request wire message version to 1
Browse files Browse the repository at this point in the history
Update the minimum supported request wire message version to 1. Adjust
the version check logic to ensure that only version 1 is accepted, and
not any version greater than 0.
  • Loading branch information
ffranr committed Oct 18, 2024
1 parent de8231a commit a14d21d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rfqmsg/buy_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const (
// latestBuyRequestVersion is the latest supported buy request wire
// message data field version.
latestBuyRequestVersion = V0
latestBuyRequestVersion = V1
)

// BuyRequest is a struct that represents an asset buy quote request.
Expand Down
4 changes: 2 additions & 2 deletions rfqmsg/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

// latestRequestWireMsgDataVersion is the latest supported quote request
// wire message data field version.
latestRequestWireMsgDataVersion = V0
latestRequestWireMsgDataVersion = V1
)

type (
Expand Down Expand Up @@ -233,7 +233,7 @@ func newRequestWireMsgDataFromSell(q SellRequest) (requestWireMsgData, error) {
// Validate ensures that the quote request is valid.
func (m *requestWireMsgData) Validate() error {
// Ensure the version specified in the version field is supported.
if m.Version.Val > latestRequestWireMsgDataVersion {
if m.Version.Val != latestRequestWireMsgDataVersion {
return fmt.Errorf("unsupported quote request message data "+
"version: %d", m.Version.Val)
}
Expand Down
8 changes: 4 additions & 4 deletions rfqmsg/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestRequestMsgDataEncodeDecode(t *testing.T) {
{
testName: "in asset ID, out asset ID zero, " +
"no asset group keys, suggested tick rate",
version: 0,
version: V1,
id: id,
expiry: expiry,
assetMaxAmount: 1000,
Expand All @@ -135,7 +135,7 @@ func TestRequestMsgDataEncodeDecode(t *testing.T) {
{
testName: "in asset ID, out asset ID zero, no asset " +
"group keys",
version: 0,
version: V1,
id: id,
expiry: expiry,
assetMaxAmount: 1000,
Expand All @@ -148,7 +148,7 @@ func TestRequestMsgDataEncodeDecode(t *testing.T) {
{
testName: "in asset group key, out asset " +
"ID zero",
version: 0,
version: V1,
id: id,
expiry: expiry,
assetMaxAmount: 1000,
Expand All @@ -160,7 +160,7 @@ func TestRequestMsgDataEncodeDecode(t *testing.T) {
{
testName: "in asset ID zero, out asset " +
"group key",
version: 0,
version: V1,
id: id,
expiry: expiry,
assetMaxAmount: 1000,
Expand Down
2 changes: 1 addition & 1 deletion rfqmsg/sell_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const (
// latestSellRequestVersion is the latest supported sell request wire
// message data field version.
latestSellRequestVersion = V0
latestSellRequestVersion = V1
)

// SellRequest is a struct that represents a asset sell quote request.
Expand Down

0 comments on commit a14d21d

Please sign in to comment.