"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const src_1 = require("../../src");
const testUtils_1 = require("../testUtils");
const XRPMccConnection = {
    url: process.env.XRP_URL || "",
    username: process.env.XRP_USERNAME || "",
    password: process.env.XRP_PASSWORD || "",
    apiTokenKey: process.env.FLARE_API_PORTAL_KEY || "",
};
describe("Failed transactions", function () {
    src_1.traceManager.displayRuntimeTrace = false;
    src_1.traceManager.displayStateOnException = false;
    const MccClient = new src_1.MCC.XRP(XRPMccConnection);
    describe("Transaction payment: receiver's fault", async function () {
        let transaction;
        const tx_id = "1EB2504C2632414C110D74EE2A1E9357CE2845672D2FEB5BC79160AB25067A8D";
        before(async function () {
            transaction = await MccClient.getTransaction(tx_id);
        });
        it("Should get txId", function () {
            (0, chai_1.expect)(transaction.txid).to.eq(tx_id);
        });
        it("Should get status", function () {
            (0, chai_1.expect)(transaction.successStatus, "status").to.eq(src_1.TransactionSuccessStatus.RECEIVER_FAILURE);
        });
        it("Should get intendedSpentAmounts", function () {
            const expected = [{ address: "rKbb74HAdKBWPyJC6Q7p8m2BMrBgRs5uWT", amount: (0, src_1.toBN)("142") }];
            (0, chai_1.assert)((0, testUtils_1.AddressAmountEqual)(transaction.intendedSpentAmounts, expected));
        });
        it("Should get intendedReceivedAmounts", function () {
            const expected = [{ address: "rfLyN2k3KShu6kEuXgzQsmiK4xRLsaU8Ad", amount: (0, src_1.toBN)("42") }];
            (0, chai_1.assert)((0, testUtils_1.AddressAmountEqual)(transaction.intendedReceivedAmounts, expected));
        });
    });
    describe("Transaction not payment: sender's fault", async function () {
        let transaction;
        const tx_id = "585D3AAEF6ABF72B6E43F54FDCFA3F6AFA463BA3C28B0D787F0C10AAD2178A5B";
        before(async function () {
            transaction = await MccClient.getTransaction(tx_id);
        });
        it("Should get txId", function () {
            (0, chai_1.expect)(transaction.txid).to.eq(tx_id);
        });
        it("Should get status", function () {
            (0, chai_1.expect)(transaction.successStatus, "status").to.eq(src_1.TransactionSuccessStatus.SENDER_FAILURE);
        });
        it("Should not get intendedSpentAmounts", function () {
            (0, chai_1.expect)(() => {
                transaction.intendedSpentAmounts;
            }).to.throw("Intended spend amounts for transaction type OfferCreate are not implemented");
        });
        it("Should not get intendedReceivedAmounts", function () {
            (0, chai_1.expect)(() => {
                transaction.intendedReceivedAmounts;
            }).to.throw("Intended received amounts for transaction type OfferCreate are not implemented");
        });
    });
    // TODO: explore how this should be handled
});
//# sourceMappingURL=failedTransaction.test.js.map