Skip to content

Instantly share code, notes, and snippets.

@tomquisel
Created February 15, 2019 21:55
Show Gist options
  • Save tomquisel/12a1eda5094d85bac258639b76b23481 to your computer and use it in GitHub Desktop.
Save tomquisel/12a1eda5094d85bac258639b76b23481 to your computer and use it in GitHub Desktop.
Test cases for parse_xdr.ts
import { extrapolateFromXdr } from "./xdr";
jest.unmock("stellar-sdk");
const deleteOfferXdr =
"AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAAAAAACAAAAAA==";
const createOfferXdr =
"AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAVvtc2vNsygpxOUKCQKkmSJSQItaJ0LxMot3/9ups4/AAAAAAK1OXcAAAAAAAAAAVhDTgAAAAAAm466+JY4VR3PnqT3QyBxEGuHqw4ts9abdaU4InL3WdgAAAAAAOThwAAAABQAAAADAAAAAAAAAAAAAAAA";
describe("extrapolateFromXdr", () => {
test("deleteOffer", () => {
expect(extrapolateFromXdr(deleteOfferXdr, "TransactionResult")).toEqual({
ext: undefined,
feeCharged: "100",
result: {
txSuccess: [
{
opInner: {
manageOffer: {
manageOfferSuccess: {
offer: "manageOfferDeleted",
offersClaimed: [],
},
},
},
},
],
},
});
});
test("createOffer", () => {
expect(extrapolateFromXdr(createOfferXdr, "TransactionResult")).toEqual({
ext: undefined,
feeCharged: "100",
result: {
txSuccess: [
{
opInner: {
manageOffer: {
manageOfferSuccess: {
offer: {
manageOfferCreated: {
amount: "1.5",
buying: {
assetTypeCreditAlphanum4: {
assetCode: "XCN",
issuer: {
publicKeyTypeEd25519:
"GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY",
},
},
},
ext: undefined,
flags: "0",
offerId: "45431159",
price: { d: "3", n: "20" },
sellerId: {
publicKeyTypeEd25519:
"GACW7NONV43MZIFHCOKCQJAKSJSISSICFVUJ2C6EZIW5773OU3HD64VI",
},
selling: "assetTypeNative",
},
},
offersClaimed: [],
},
},
},
},
],
},
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment