Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatureDev committed Apr 11, 2023
1 parent 86988e9 commit 6e944eb
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
50 changes: 50 additions & 0 deletions model/client/path/deposit_authorized_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package path

import (
"testing"

"github.com/xyield/xrpl-go/model/client/common"
"github.com/xyield/xrpl-go/test"
)

func TestDepositAuthorizedRequest(t *testing.T) {
s := DepositAuthorizedRequest{
SourceAccount: "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
DestinationAccount: "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
LedgerIndex: common.VALIDATED,
}

j := `{
"source_account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
"destination_account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
"ledger_index": "validated"
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}

func TestDepositAuthorizedResponse(t *testing.T) {
s := DepositAuthorizedResponse{
DepositAuthorized: true,
DestinationAccount: "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
LedgerHash: "BD03A10653ED9D77DCA859B7A735BF0580088A8F287FA2C5403E0A19C58EF322",
LedgerIndex: 8,
SourceAccount: "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
Validated: true,
}

j := `{
"deposit_authorized": true,
"destination_account": "rsUiUMpnrgxQp24dJYZDhmV4bE3aBtQyt8",
"ledger_hash": "BD03A10653ED9D77DCA859B7A735BF0580088A8F287FA2C5403E0A19C58EF322",
"ledger_index": 8,
"source_account": "rEhxGqkqPPSxQ3P25J66ft5TwpzV14k2de",
"validated": true
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}
6 changes: 6 additions & 0 deletions model/client/path/nftoken_buy_offers_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func (r *NFTokenBuyOffersRequest) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
*r = NFTokenBuyOffersRequest{
NFTokenID: h.NFTokenID,
LedgerHash: h.LedgerHash,
Limit: h.Limit,
Marker: h.Marker,
}
var i common.LedgerSpecifier
i, err = common.UnmarshalLedgerSpecifier(h.LedgerIndex)
if err != nil {
Expand Down
55 changes: 55 additions & 0 deletions model/client/path/nftoken_buy_offers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package path

import (
"testing"

"github.com/xyield/xrpl-go/model/client/common"
"github.com/xyield/xrpl-go/model/transactions/types"
"github.com/xyield/xrpl-go/test"
)

func TestNFTokenBuyOffersRequest(t *testing.T) {
s := NFTokenBuyOffersRequest{
NFTokenID: "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
LedgerIndex: common.VALIDATED,
}

j := `{
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
"ledger_index": "validated"
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}

func TestNFTokenBuyOffersResponse(t *testing.T) {
s := NFTokenBuyOffersResponse{
NFTokenID: "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
Offers: []NFTokenOffer{
{
Amount: types.XRPCurrencyAmount(1500),
Flags: 0,
NFTokenOfferIndex: "3212D26DB00031889D4EF7D9129BB0FA673B5B40B1759564486C0F0946BA203F",
Owner: "rsuHaTvJh1bDmDoxX9QcKP7HEBSBt4XsHx",
},
},
}

j := `{
"nft_id": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007",
"offers": [
{
"amount": "1500",
"flags": 0,
"nft_offer_index": "3212D26DB00031889D4EF7D9129BB0FA673B5B40B1759564486C0F0946BA203F",
"owner": "rsuHaTvJh1bDmDoxX9QcKP7HEBSBt4XsHx"
}
]
}`

if err := test.SerializeAndDeserialize(t, s, j); err != nil {
t.Error(err)
}
}

0 comments on commit 6e944eb

Please sign in to comment.